Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
phearnot committed Mar 7, 2024
1 parent 845d172 commit 734c8d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions node/src/main/scala/com/wavesplatform/Explorer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ object Explorer extends ScorexLogging {
val result = new util.HashMap[Short, Stats]
Seq(rdb.db.getDefaultColumnFamily, rdb.txHandle.handle, rdb.txSnapshotHandle.handle, rdb.txMetaHandle.handle).foreach { cf =>
Using.Manager { use =>
val ro = use(new ReadOptions().setTotalOrderSeek(true))
val ro = use(new ReadOptions().setTotalOrderSeek(true).setVerifyChecksums(false))
val iterator = use(rdb.db.newIterator(cf, ro))
iterator.seekToFirst()

Expand Down Expand Up @@ -373,7 +373,7 @@ object Explorer extends ScorexLogging {
log.info("Counting transaction IDs")
var counter = 0
Using.Manager { use =>
val ro = use(new ReadOptions().setTotalOrderSeek(true))
val ro = use(new ReadOptions().setTotalOrderSeek(true).setVerifyChecksums(false))
val iter = use(rdb.db.newIterator(rdb.txMetaHandle.handle, ro))
iter.seekToFirst()
// iter.seek(KeyTags.TransactionMetaById.prefixBytes) // Doesn't work, because of CappedPrefixExtractor(10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ trait DBResource extends AutoCloseable {
object DBResource {
def apply(db: RocksDB, iteratorCfHandle: Option[ColumnFamilyHandle] = None): DBResource = new DBResource {
private[this] val snapshot = db.getSnapshot
// checksum may be verification is **very** expensive, so it's explicitly disabled
private[this] val readOptions = new ReadOptions().setSnapshot(snapshot).setVerifyChecksums(false)

override def get[V](key: Key[V]): V = key.parse(db.get(key.columnFamilyHandle.getOrElse(db.getDefaultColumnFamily), readOptions, key.keyBytes))
Expand Down
15 changes: 9 additions & 6 deletions node/src/main/scala/com/wavesplatform/database/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ package object database {

def withReadOptions[A](f: ReadOptions => A): A = {
val snapshot = db.getSnapshot
val ro = new ReadOptions().setSnapshot(snapshot).setVerifyChecksums(false)
// checksum may be verification is **very** expensive, so it's explicitly disabled
val ro = new ReadOptions().setSnapshot(snapshot).setVerifyChecksums(false)
try f(ro)
finally {
ro.close()
Expand Down Expand Up @@ -529,11 +530,13 @@ package object database {
} else ()
}

val iterator = db.newIterator(cfh.getOrElse(db.getDefaultColumnFamily), new ReadOptions().setTotalOrderSeek(true).setVerifyChecksums(false))
try {
iterator.seek(prefix)
loop(iterator)
} finally iterator.close()
withReadOptions { ro =>
val iterator = db.newIterator(cfh.getOrElse(db.getDefaultColumnFamily), ro.setTotalOrderSeek(true))
try {
iterator.seek(prefix)
loop(iterator)
} finally iterator.close()
}
}

def resourceObservable: Observable[DBResource] =
Expand Down

0 comments on commit 734c8d1

Please sign in to comment.