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.} = method getCodeByHash*(db: AbstractChainDB, hash: KeccakHash): Blob {.base, gcsafe.} =
notImplemented() notImplemented()
method getSetting*(db: AbstractChainDb, key: string): Bytes {.base, gcsafe.} = method getSetting*(db: AbstractChainDB, key: string): Bytes {.base, gcsafe.} =
notImplemented() notImplemented()
method setSetting*(db: AbstractChainDb, key: string, val: openarray[byte]) {.base, gcsafe.} = method setSetting*(db: AbstractChainDB, key: string, val: openarray[byte]) {.base, gcsafe.} =
notImplemented() notImplemented()
method getHeaderProof*(db: AbstractChainDB, req: ProofRequest): Blob {.base, gcsafe.} = method getHeaderProof*(db: AbstractChainDB, req: ProofRequest): Blob {.base, gcsafe.} =

View File

@ -12,13 +12,13 @@ proc getAccount*(db: TrieDatabaseRef,
else: else:
result = newAccount() result = newAccount()
proc getContractCode*(chain: AbstractChainDb, req: ContractCodeRequest): Blob {.gcsafe.} = proc getContractCode*(chain: AbstractChainDB, req: ContractCodeRequest): Blob {.gcsafe.} =
let b = chain.getBlockHeader(req.blockHash) let b = chain.getBlockHeader(req.blockHash)
if b.hasData: if b.hasData:
let acc = getAccount(chain.getStateDb, b.stateRoot, req.key) let acc = getAccount(chain.getStateDb, b.stateRoot, req.key)
result = chain.getCodeByHash(acc.codeHash) result = chain.getCodeByHash(acc.codeHash)
proc getStorageNode*(chain: AbstractChainDb, hash: KeccakHash): Blob = proc getStorageNode*(chain: AbstractChainDB, hash: KeccakHash): Blob =
let db = chain.getStateDb let db = chain.getStateDb
return db.get(hash.data) return db.get(hash.data)
# let trie = initSecureHexaryTrie(db, emptyRlpHash) # TODO emptyRlpHash is not correct here # 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 # TODO: Perhaps we can move this to eth-common
proc getBlockHeaders*(db: AbstractChainDb, proc getBlockHeaders*(db: AbstractChainDB,
req: BlocksRequest): seq[BlockHeader] {.gcsafe.} = req: BlocksRequest): seq[BlockHeader] {.gcsafe.} =
result = newSeqOfCap[BlockHeader](req.maxResults) result = newSeqOfCap[BlockHeader](req.maxResults)
@ -17,7 +17,7 @@ proc getBlockHeaders*(db: AbstractChainDb,
result.add foundBlock result.add foundBlock
template fetcher*(fetcherName, fetchingFunc, InputType, ResultType: untyped) = template fetcher*(fetcherName, fetchingFunc, InputType, ResultType: untyped) =
proc fetcherName*(db: AbstractChainDb, proc fetcherName*(db: AbstractChainDB,
lookups: openarray[InputType]): seq[ResultType] {.gcsafe.} = lookups: openarray[InputType]): seq[ResultType] {.gcsafe.} =
for lookup in lookups: for lookup in lookups:
let fetched = fetchingFunc(db, lookup) let fetched = fetchingFunc(db, lookup)
@ -34,7 +34,7 @@ fetcher getReceipts, getReceipt, KeccakHash, Receipt
fetcher getProofs, getProof, ProofRequest, Blob fetcher getProofs, getProof, ProofRequest, Blob
fetcher getHeaderProofs, getHeaderProof, ProofRequest, Blob fetcher getHeaderProofs, getHeaderProof, ProofRequest, Blob
proc getHelperTrieProofs*(db: AbstractChainDb, proc getHelperTrieProofs*(db: AbstractChainDB,
reqs: openarray[HelperTrieProofRequest], reqs: openarray[HelperTrieProofRequest],
outNodes: var seq[Blob], outAuxData: var seq[Blob]) = outNodes: var seq[Blob], outAuxData: var seq[Blob]) =
discard discard

View File

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

View File

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