mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-16 23:31:16 +00:00
5f0e89a41e
* Provided common scheduler API, applied to `full` sync * Use hexary trie as storage for proofs_db records also: + Store metadata with account for keeping track of account state + add iterator over accounts * Common scheduler API applied to `snap` sync * Prepare for accounts bulk import details: + Added some ad-hoc checks for proving accounts data received from the snap/1 (will be replaced by proper database version when ready) + Added code that dumps some of the received snap/1 data into a file (turned of by default, see `worker_desc.nim`)
72 lines
2.0 KiB
Nim
72 lines
2.0 KiB
Nim
# Nimbus
|
|
# Copyright (c) 2021 Status Research & Development GmbH
|
|
# Licensed under either of
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
# http://opensource.org/licenses/MIT)
|
|
# at your option. This file may not be copied, modified, or distributed
|
|
# except according to those terms.
|
|
|
|
import
|
|
eth/[common/eth_types, p2p],
|
|
chronicles,
|
|
chronos,
|
|
stew/[interval_set, sorted_set],
|
|
"."/[full/worker, sync_desc, sync_sched, protocol]
|
|
|
|
{.push raises: [Defect].}
|
|
|
|
logScope:
|
|
topics = "full-sync"
|
|
|
|
type
|
|
FullSyncRef* = RunnerSyncRef[CtxData,BuddyData]
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Virtual methods/interface, `mixin` functions
|
|
# ------------------------------------------------------------------------------
|
|
|
|
proc runSetup(ctx: FullCtxRef; ticker: bool): bool =
|
|
worker.setup(ctx,ticker)
|
|
|
|
proc runRelease(ctx: FullCtxRef) =
|
|
worker.release(ctx)
|
|
|
|
proc runStart(buddy: FullBuddyRef): bool =
|
|
worker.start(buddy)
|
|
|
|
proc runStop(buddy: FullBuddyRef) =
|
|
worker.stop(buddy)
|
|
|
|
proc runPool(buddy: FullBuddyRef) =
|
|
worker.runPool(buddy)
|
|
|
|
proc runSingle(buddy: FullBuddyRef) {.async.} =
|
|
await worker.runSingle(buddy)
|
|
|
|
proc runMulti(buddy: FullBuddyRef) {.async.} =
|
|
await worker.runMulti(buddy)
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Public functions
|
|
# ------------------------------------------------------------------------------
|
|
|
|
proc init*(
|
|
T: type FullSyncRef;
|
|
ethNode: EthereumNode;
|
|
maxPeers: int;
|
|
enableTicker = false): T =
|
|
new result
|
|
result.initSync(ethNode, maxPeers, enableTicker)
|
|
|
|
proc start*(ctx: FullSyncRef) =
|
|
doAssert ctx.startSync()
|
|
|
|
proc stop*(ctx: FullSyncRef) =
|
|
ctx.stopSync()
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# End
|
|
# ------------------------------------------------------------------------------
|