AbstractChainDb -> AbstractChainDB (#18)

This commit is contained in:
Ștefan Talpalaru 2019-03-13 02:37:04 +01:00 committed by Jacek Sieka
parent 3efec171a6
commit 4329cc1cb6
5 changed files with 10 additions and 10 deletions

View File

@ -353,10 +353,10 @@ method getStateDb*(db: AbstractChainDB): TrieDatabaseRef {.base, gcsafe.} =
method getCodeByHash*(db: AbstractChainDB, hash: KeccakHash): Blob {.base, gcsafe.} =
notImplemented()
method getSetting*(db: AbstractChainDb, key: string): Bytes {.base, gcsafe.} =
method getSetting*(db: AbstractChainDB, key: string): Bytes {.base, gcsafe.} =
notImplemented()
method setSetting*(db: AbstractChainDb, key: string, val: openarray[byte]) {.base, gcsafe.} =
method setSetting*(db: AbstractChainDB, key: string, val: openarray[byte]) {.base, gcsafe.} =
notImplemented()
method getHeaderProof*(db: AbstractChainDB, req: ProofRequest): Blob {.base, gcsafe.} =

View File

@ -12,13 +12,13 @@ proc getAccount*(db: TrieDatabaseRef,
else:
result = newAccount()
proc getContractCode*(chain: AbstractChainDb, req: ContractCodeRequest): Blob {.gcsafe.} =
proc getContractCode*(chain: AbstractChainDB, req: ContractCodeRequest): Blob {.gcsafe.} =
let b = chain.getBlockHeader(req.blockHash)
if b.hasData:
let acc = getAccount(chain.getStateDb, b.stateRoot, req.key)
result = chain.getCodeByHash(acc.codeHash)
proc getStorageNode*(chain: AbstractChainDb, hash: KeccakHash): Blob =
proc getStorageNode*(chain: AbstractChainDB, hash: KeccakHash): Blob =
let db = chain.getStateDb
return db.get(hash.data)
# let trie = initSecureHexaryTrie(db, emptyRlpHash) # TODO emptyRlpHash is not correct here

View File

@ -3,7 +3,7 @@ import
# TODO: Perhaps we can move this to eth-common
proc getBlockHeaders*(db: AbstractChainDb,
proc getBlockHeaders*(db: AbstractChainDB,
req: BlocksRequest): seq[BlockHeader] {.gcsafe.} =
result = newSeqOfCap[BlockHeader](req.maxResults)
@ -17,7 +17,7 @@ proc getBlockHeaders*(db: AbstractChainDb,
result.add foundBlock
template fetcher*(fetcherName, fetchingFunc, InputType, ResultType: untyped) =
proc fetcherName*(db: AbstractChainDb,
proc fetcherName*(db: AbstractChainDB,
lookups: openarray[InputType]): seq[ResultType] {.gcsafe.} =
for lookup in lookups:
let fetched = fetchingFunc(db, lookup)
@ -34,7 +34,7 @@ fetcher getReceipts, getReceipt, KeccakHash, Receipt
fetcher getProofs, getProof, ProofRequest, Blob
fetcher getHeaderProofs, getHeaderProof, ProofRequest, Blob
proc getHelperTrieProofs*(db: AbstractChainDb,
proc getHelperTrieProofs*(db: AbstractChainDB,
reqs: openarray[HelperTrieProofRequest],
outNodes: var seq[Blob], outAuxData: var seq[Blob]) =
discard

View File

@ -18,7 +18,7 @@ type
keys*: KeyPair
address*: Address
networkId*: uint
chain*: AbstractChainDb
chain*: AbstractChainDB
clientId*: string
waitForHello*: bool

View File

@ -92,7 +92,7 @@ proc persistMessageStats*(db: AbstractChainDB,
proc loadMessageStats*(network: LesNetwork,
les: ProtocolInfo,
db: AbstractChainDb): bool =
db: AbstractChainDB): bool =
block readFromDB:
if db == nil:
break readFromDB
@ -262,7 +262,7 @@ proc delistFromFlowControl*(network: LesNetwork, peer: LesPeer) =
proc initFlowControl*(network: LesNetwork, les: ProtocolInfo,
maxReqCount, maxReqCostSum, reqCostTarget: int,
db: AbstractChainDb = nil) =
db: AbstractChainDB = nil) =
network.rechargingRate = (rechargingScale * rechargingScale) /
(100 * rechargingScale / reqCostTarget - rechargingScale)
network.maxReqCount = maxReqCount