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:
|
try:
|
||||||
let contentIds = transfers[nodeId]
|
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:
|
except KeyError as e:
|
||||||
raiseAssert(e.msg)
|
raiseAssert(e.msg)
|
||||||
|
|
||||||
|
|
|
@ -37,13 +37,7 @@ type
|
||||||
tx: TransactionRef
|
tx: TransactionRef
|
||||||
updatedCache: TrieDatabaseRef
|
updatedCache: TrieDatabaseRef
|
||||||
|
|
||||||
PreimagesBackendRef = ref object of RootObj
|
DatabaseBackendRef = AccountsBackendRef | StorageBackendRef | BytecodeBackendRef
|
||||||
cfHandle: ColFamilyHandleRef
|
|
||||||
tx: TransactionRef
|
|
||||||
updatedCache: TrieDatabaseRef
|
|
||||||
|
|
||||||
DatabaseBackendRef =
|
|
||||||
AccountsBackendRef | StorageBackendRef | BytecodeBackendRef | PreimagesBackendRef
|
|
||||||
|
|
||||||
DatabaseRef* = ref object
|
DatabaseRef* = ref object
|
||||||
rocksDb: OptimisticTxDbRef
|
rocksDb: OptimisticTxDbRef
|
||||||
|
@ -51,7 +45,6 @@ type
|
||||||
accountsBackend: AccountsBackendRef
|
accountsBackend: AccountsBackendRef
|
||||||
storageBackend: StorageBackendRef
|
storageBackend: StorageBackendRef
|
||||||
bytecodeBackend: BytecodeBackendRef
|
bytecodeBackend: BytecodeBackendRef
|
||||||
preimagesBackend: PreimagesBackendRef
|
|
||||||
|
|
||||||
proc init*(T: type DatabaseRef, baseDir: string): Result[T, string] =
|
proc init*(T: type DatabaseRef, baseDir: string): Result[T, string] =
|
||||||
let dbPath = baseDir / "db"
|
let dbPath = baseDir / "db"
|
||||||
|
@ -79,9 +72,6 @@ proc init*(T: type DatabaseRef, baseDir: string): Result[T, string] =
|
||||||
bytecodeBackend = BytecodeBackendRef(
|
bytecodeBackend = BytecodeBackendRef(
|
||||||
cfHandle: db.getColFamilyHandle(COL_FAMILY_NAME_BYTECODE).get()
|
cfHandle: db.getColFamilyHandle(COL_FAMILY_NAME_BYTECODE).get()
|
||||||
)
|
)
|
||||||
preimagesBackend = PreimagesBackendRef(
|
|
||||||
cfHandle: db.getColFamilyHandle(COL_FAMILY_NAME_PREIMAGES).get()
|
|
||||||
)
|
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
T(
|
T(
|
||||||
|
@ -90,7 +80,6 @@ proc init*(T: type DatabaseRef, baseDir: string): Result[T, string] =
|
||||||
accountsBackend: accountsBackend,
|
accountsBackend: accountsBackend,
|
||||||
storageBackend: storageBackend,
|
storageBackend: storageBackend,
|
||||||
bytecodeBackend: bytecodeBackend,
|
bytecodeBackend: bytecodeBackend,
|
||||||
preimagesBackend: preimagesBackend,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -138,9 +127,6 @@ proc getStorageBackend*(db: DatabaseRef): TrieDatabaseRef {.inline.} =
|
||||||
proc getBytecodeBackend*(db: DatabaseRef): TrieDatabaseRef {.inline.} =
|
proc getBytecodeBackend*(db: DatabaseRef): TrieDatabaseRef {.inline.} =
|
||||||
trieDB(db.bytecodeBackend)
|
trieDB(db.bytecodeBackend)
|
||||||
|
|
||||||
proc getPreimagesBackend*(db: DatabaseRef): TrieDatabaseRef {.inline.} =
|
|
||||||
trieDB(db.preimagesBackend)
|
|
||||||
|
|
||||||
proc getAccountsUpdatedCache*(db: DatabaseRef): TrieDatabaseRef {.inline.} =
|
proc getAccountsUpdatedCache*(db: DatabaseRef): TrieDatabaseRef {.inline.} =
|
||||||
db.accountsBackend.updatedCache
|
db.accountsBackend.updatedCache
|
||||||
|
|
||||||
|
@ -179,12 +165,10 @@ proc beginTransaction*(db: DatabaseRef): Result[void, string] =
|
||||||
db.accountsBackend.tx = tx
|
db.accountsBackend.tx = tx
|
||||||
db.storageBackend.tx = tx
|
db.storageBackend.tx = tx
|
||||||
db.bytecodeBackend.tx = tx
|
db.bytecodeBackend.tx = tx
|
||||||
db.preimagesBackend.tx = tx
|
|
||||||
|
|
||||||
db.accountsBackend.updatedCache = newMemoryDB()
|
db.accountsBackend.updatedCache = newMemoryDB()
|
||||||
db.storageBackend.updatedCache = newMemoryDB()
|
db.storageBackend.updatedCache = newMemoryDB()
|
||||||
db.bytecodeBackend.updatedCache = newMemoryDB()
|
db.bytecodeBackend.updatedCache = newMemoryDB()
|
||||||
db.preimagesBackend.updatedCache = nil # not used
|
|
||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue