Fluffy: Cleanup state bridge preimages backend and add logging for transfer limit reached (#2896)
This commit is contained in:
parent
b3cb51e89e
commit
b446d2a2e8
|
@ -91,7 +91,11 @@ proc canAddPendingTransfer(
|
|||
|
||||
try:
|
||||
let contentIds = transfers[nodeId]
|
||||
(contentIds.len() < limit) and not contentIds.contains(contentId)
|
||||
if (contentIds.len() < limit) and not contentIds.contains(contentId):
|
||||
return true
|
||||
else:
|
||||
debug "Pending transfer limit reached for peer", nodeId, contentId
|
||||
return false
|
||||
except KeyError as e:
|
||||
raiseAssert(e.msg)
|
||||
|
||||
|
|
|
@ -37,13 +37,7 @@ type
|
|||
tx: TransactionRef
|
||||
updatedCache: TrieDatabaseRef
|
||||
|
||||
PreimagesBackendRef = ref object of RootObj
|
||||
cfHandle: ColFamilyHandleRef
|
||||
tx: TransactionRef
|
||||
updatedCache: TrieDatabaseRef
|
||||
|
||||
DatabaseBackendRef =
|
||||
AccountsBackendRef | StorageBackendRef | BytecodeBackendRef | PreimagesBackendRef
|
||||
DatabaseBackendRef = AccountsBackendRef | StorageBackendRef | BytecodeBackendRef
|
||||
|
||||
DatabaseRef* = ref object
|
||||
rocksDb: OptimisticTxDbRef
|
||||
|
@ -51,7 +45,6 @@ type
|
|||
accountsBackend: AccountsBackendRef
|
||||
storageBackend: StorageBackendRef
|
||||
bytecodeBackend: BytecodeBackendRef
|
||||
preimagesBackend: PreimagesBackendRef
|
||||
|
||||
proc init*(T: type DatabaseRef, baseDir: string): Result[T, string] =
|
||||
let dbPath = baseDir / "db"
|
||||
|
@ -79,9 +72,6 @@ proc init*(T: type DatabaseRef, baseDir: string): Result[T, string] =
|
|||
bytecodeBackend = BytecodeBackendRef(
|
||||
cfHandle: db.getColFamilyHandle(COL_FAMILY_NAME_BYTECODE).get()
|
||||
)
|
||||
preimagesBackend = PreimagesBackendRef(
|
||||
cfHandle: db.getColFamilyHandle(COL_FAMILY_NAME_PREIMAGES).get()
|
||||
)
|
||||
|
||||
ok(
|
||||
T(
|
||||
|
@ -90,7 +80,6 @@ proc init*(T: type DatabaseRef, baseDir: string): Result[T, string] =
|
|||
accountsBackend: accountsBackend,
|
||||
storageBackend: storageBackend,
|
||||
bytecodeBackend: bytecodeBackend,
|
||||
preimagesBackend: preimagesBackend,
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -138,9 +127,6 @@ proc getStorageBackend*(db: DatabaseRef): TrieDatabaseRef {.inline.} =
|
|||
proc getBytecodeBackend*(db: DatabaseRef): TrieDatabaseRef {.inline.} =
|
||||
trieDB(db.bytecodeBackend)
|
||||
|
||||
proc getPreimagesBackend*(db: DatabaseRef): TrieDatabaseRef {.inline.} =
|
||||
trieDB(db.preimagesBackend)
|
||||
|
||||
proc getAccountsUpdatedCache*(db: DatabaseRef): TrieDatabaseRef {.inline.} =
|
||||
db.accountsBackend.updatedCache
|
||||
|
||||
|
@ -179,12 +165,10 @@ proc beginTransaction*(db: DatabaseRef): Result[void, string] =
|
|||
db.accountsBackend.tx = tx
|
||||
db.storageBackend.tx = tx
|
||||
db.bytecodeBackend.tx = tx
|
||||
db.preimagesBackend.tx = tx
|
||||
|
||||
db.accountsBackend.updatedCache = newMemoryDB()
|
||||
db.storageBackend.updatedCache = newMemoryDB()
|
||||
db.bytecodeBackend.updatedCache = newMemoryDB()
|
||||
db.preimagesBackend.updatedCache = nil # not used
|
||||
|
||||
ok()
|
||||
|
||||
|
|
Loading…
Reference in New Issue