mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-23 13:00:34 +00:00
reduce ncli/research imports (#5275)
* reduce ncli/research imports avoids ssl, most of chronos etc, speeds up compiles * copyright
This commit is contained in:
parent
a154a42205
commit
3c9fc49411
@ -9,12 +9,12 @@
|
||||
|
||||
import
|
||||
std/math,
|
||||
chronos, chronicles,
|
||||
chronos/timer, chronicles,
|
||||
./spec/beacon_time
|
||||
|
||||
from times import Time, getTime, fromUnix, `<`, `-`, inNanoseconds
|
||||
|
||||
export chronos.Duration, Moment, now
|
||||
export timer.Duration, Moment, now
|
||||
|
||||
type
|
||||
BeaconClock* = object
|
||||
@ -62,9 +62,9 @@ func getBeaconTimeFn*(c: BeaconClock): GetBeaconTimeFn =
|
||||
proc fromNow*(c: BeaconClock, t: BeaconTime): tuple[inFuture: bool, offset: Duration] =
|
||||
let now = c.now()
|
||||
if t > now:
|
||||
(true, chronos.nanoseconds((t - now).nanoseconds))
|
||||
(true, nanoseconds((t - now).nanoseconds))
|
||||
else:
|
||||
(false, chronos.nanoseconds((now - t).nanoseconds))
|
||||
(false, nanoseconds((now - t).nanoseconds))
|
||||
|
||||
proc fromNow*(c: BeaconClock, slot: Slot): tuple[inFuture: bool, offset: Duration] =
|
||||
c.fromNow(slot.start_beacon_time())
|
||||
@ -76,7 +76,7 @@ proc durationToNextSlot*(c: BeaconClock): Duration =
|
||||
|
||||
if currentSlot.afterGenesis:
|
||||
let nextSlot = currentSlot.slot + 1
|
||||
chronos.nanoseconds(
|
||||
nanoseconds(
|
||||
(nextSlot.start_beacon_time() - currentTime).nanoseconds)
|
||||
else:
|
||||
# absoluteTime = BeaconTime(-currentTime.ns_since_genesis).
|
||||
@ -84,7 +84,7 @@ proc durationToNextSlot*(c: BeaconClock): Duration =
|
||||
absoluteTime = Slot(0).start_beacon_time() +
|
||||
(Slot(0).start_beacon_time() - currentTime)
|
||||
timeToNextSlot = absoluteTime - currentSlot.slot.start_beacon_time()
|
||||
chronos.nanoseconds(timeToNextSlot.nanoseconds)
|
||||
nanoseconds(timeToNextSlot.nanoseconds)
|
||||
|
||||
proc durationToNextEpoch*(c: BeaconClock): Duration =
|
||||
let
|
||||
@ -93,7 +93,7 @@ proc durationToNextEpoch*(c: BeaconClock): Duration =
|
||||
|
||||
if currentSlot.afterGenesis:
|
||||
let nextEpochSlot = (currentSlot.slot.epoch() + 1).start_slot()
|
||||
chronos.nanoseconds(
|
||||
nanoseconds(
|
||||
(nextEpochSlot.start_beacon_time() - currentTime).nanoseconds)
|
||||
else:
|
||||
# absoluteTime = BeaconTime(-currentTime.ns_since_genesis).
|
||||
@ -102,15 +102,11 @@ proc durationToNextEpoch*(c: BeaconClock): Duration =
|
||||
(Slot(0).start_beacon_time() - currentTime)
|
||||
timeToNextEpoch = absoluteTime -
|
||||
currentSlot.slot.epoch().start_slot().start_beacon_time()
|
||||
chronos.nanoseconds(timeToNextEpoch.nanoseconds)
|
||||
nanoseconds(timeToNextEpoch.nanoseconds)
|
||||
|
||||
func saturate*(d: tuple[inFuture: bool, offset: Duration]): Duration =
|
||||
if d.inFuture: d.offset else: seconds(0)
|
||||
|
||||
proc sleepAsync*(t: TimeDiff): Future[void] =
|
||||
sleepAsync(chronos.nanoseconds(
|
||||
if t.nanoseconds < 0: 0'i64 else: t.nanoseconds))
|
||||
|
||||
func shortLog*(d: Duration): string =
|
||||
$d
|
||||
|
||||
|
@ -262,6 +262,10 @@ proc runKeystoreCachePruningLoop*(cache: KeystoreCacheRef) {.async.} =
|
||||
if exitLoop: break
|
||||
cache.pruneExpiredKeys()
|
||||
|
||||
proc sleepAsync*(t: TimeDiff): Future[void] =
|
||||
sleepAsync(nanoseconds(
|
||||
if t.nanoseconds < 0: 0'i64 else: t.nanoseconds))
|
||||
|
||||
proc runSlotLoop*[T](node: T, startTime: BeaconTime,
|
||||
slotProc: SlotStartProc[T]) {.async.} =
|
||||
var
|
||||
|
@ -1,4 +1,12 @@
|
||||
# beacon_chain
|
||||
# Copyright (c) 2020-2023 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
std/strutils,
|
||||
confutils, json_serialization,
|
||||
snappy,
|
||||
../beacon_chain/spec/eth2_apis/eth2_rest_serialization,
|
||||
|
@ -7,11 +7,11 @@
|
||||
|
||||
import
|
||||
stats, strformat, times,
|
||||
stew/io2,
|
||||
../tests/testblockutil, ../tests/consensus_spec/os_ops,
|
||||
../beacon_chain/[beacon_chain_db, filepath],
|
||||
../beacon_chain/[filepath],
|
||||
../beacon_chain/spec/datatypes/[phase0, altair],
|
||||
../beacon_chain/spec/[beaconstate, deposit_snapshots, forks, helpers],
|
||||
../beacon_chain/consensus_object_pools/[blockchain_dag, block_pools_types]
|
||||
../beacon_chain/spec/[beaconstate, deposit_snapshots, forks, helpers]
|
||||
|
||||
template withTimer*(stats: var RunningStat, body: untyped) =
|
||||
# TODO unify timing somehow
|
||||
|
2
vendor/nim-presto
vendored
2
vendor/nim-presto
vendored
@ -1 +1 @@
|
||||
Subproject commit 42552611cfe04ca7838243d0a0e88fb9a5e9701a
|
||||
Subproject commit 8bb4a54f4751dc560efc24003be4b3b2b28316e7
|
Loading…
x
Reference in New Issue
Block a user