mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 21:34:33 +00:00
parent
56f169b23e
commit
4cf2ab661c
@ -61,8 +61,6 @@ type
|
|||||||
|
|
||||||
LegacySyncRef* = ref object
|
LegacySyncRef* = ref object
|
||||||
workQueue: seq[WantedBlocks]
|
workQueue: seq[WantedBlocks]
|
||||||
endBlockNumber: BlockNumber
|
|
||||||
finalizedBlock: BlockNumber # Block which was downloaded and verified
|
|
||||||
chain: ChainRef
|
chain: ChainRef
|
||||||
peerPool: PeerPool
|
peerPool: PeerPool
|
||||||
trustedPeers: HashSet[Peer]
|
trustedPeers: HashSet[Peer]
|
||||||
@ -71,6 +69,24 @@ type
|
|||||||
knownByPeer: Table[Peer, HashToTime]
|
knownByPeer: Table[Peer, HashToTime]
|
||||||
lastCleanup: Time
|
lastCleanup: Time
|
||||||
|
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Private functions: sync progress
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template endBlockNumber(ctx: LegacySyncRef): BlockNumber =
|
||||||
|
ctx.chain.com.syncHighest
|
||||||
|
|
||||||
|
template `endBlockNumber=`(ctx: LegacySyncRef, number: BlockNumber) =
|
||||||
|
ctx.chain.com.syncHighest = number
|
||||||
|
|
||||||
|
# Block which was downloaded and verified
|
||||||
|
template finalizedBlock(ctx: LegacySyncRef): BlockNumber =
|
||||||
|
ctx.chain.com.syncCurrent
|
||||||
|
|
||||||
|
template `finalizedBlock=`(ctx: LegacySyncRef, number: BlockNumber) =
|
||||||
|
ctx.chain.com.syncCurrent = number
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Private functions: peers related functions
|
# Private functions: peers related functions
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -908,14 +924,16 @@ proc onPeerDisconnected(ctx: LegacySyncRef, p: Peer) =
|
|||||||
|
|
||||||
proc new*(T: type LegacySyncRef; ethNode: EthereumNode; chain: ChainRef): T
|
proc new*(T: type LegacySyncRef; ethNode: EthereumNode; chain: ChainRef): T
|
||||||
{.gcsafe, raises:[Defect,CatchableError].} =
|
{.gcsafe, raises:[Defect,CatchableError].} =
|
||||||
LegacySyncRef(
|
result = LegacySyncRef(
|
||||||
# workQueue: n/a
|
# workQueue: n/a
|
||||||
# endBlockNumber: n/a
|
# endBlockNumber: n/a
|
||||||
# hasOutOfOrderBlocks: n/a
|
# hasOutOfOrderBlocks: n/a
|
||||||
chain: chain,
|
chain: chain,
|
||||||
peerPool: ethNode.peerPool,
|
peerPool: ethNode.peerPool,
|
||||||
trustedPeers: initHashSet[Peer](),
|
trustedPeers: initHashSet[Peer]())
|
||||||
finalizedBlock: chain.db.getCanonicalHead().blockNumber)
|
|
||||||
|
# finalizedBlock
|
||||||
|
chain.com.syncCurrent = chain.db.getCanonicalHead().blockNumber
|
||||||
|
|
||||||
proc start*(ctx: LegacySyncRef) =
|
proc start*(ctx: LegacySyncRef) =
|
||||||
## Code for the fast blockchain sync procedure:
|
## Code for the fast blockchain sync procedure:
|
||||||
@ -937,8 +955,9 @@ proc start*(ctx: LegacySyncRef) =
|
|||||||
debug "Fast sync is disabled after POS merge"
|
debug "Fast sync is disabled after POS merge"
|
||||||
return
|
return
|
||||||
|
|
||||||
|
ctx.chain.com.syncStart = ctx.finalizedBlock
|
||||||
info "Fast Sync: start sync from",
|
info "Fast Sync: start sync from",
|
||||||
number=ctx.finalizedBlock,
|
number=ctx.chain.com.syncStart,
|
||||||
hash=blockHash
|
hash=blockHash
|
||||||
|
|
||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user