switch result = foo to expression return; unexport rest of logtrace symbols (#2788)
This commit is contained in:
parent
a0c518cb4f
commit
6e46445da2
|
@ -41,7 +41,7 @@ const
|
||||||
|
|
||||||
func loadFragmentsLayout(contentLayout: string): ContentFragments {.
|
func loadFragmentsLayout(contentLayout: string): ContentFragments {.
|
||||||
raises: [Defect, ValueError].} =
|
raises: [Defect, ValueError].} =
|
||||||
result = toSeq(interpolatedFragments(strip contentLayout))
|
toSeq(interpolatedFragments(strip contentLayout))
|
||||||
|
|
||||||
func loadCellsLayout(cellsLayout: string): seq[StatusBarCell] {.
|
func loadCellsLayout(cellsLayout: string): seq[StatusBarCell] {.
|
||||||
raises: [Defect, ValueError].} =
|
raises: [Defect, ValueError].} =
|
||||||
|
|
|
@ -173,14 +173,14 @@ proc getShortMap*[T](req: SyncRequest[T],
|
||||||
else:
|
else:
|
||||||
res.add('.')
|
res.add('.')
|
||||||
slider = slider + req.step
|
slider = slider + req.step
|
||||||
result = res
|
res
|
||||||
|
|
||||||
proc contains*[T](req: SyncRequest[T], slot: Slot): bool {.inline.} =
|
proc contains*[T](req: SyncRequest[T], slot: Slot): bool {.inline.} =
|
||||||
slot >= req.slot and slot < req.slot + req.count * req.step and
|
slot >= req.slot and slot < req.slot + req.count * req.step and
|
||||||
((slot - req.slot) mod req.step == 0)
|
((slot - req.slot) mod req.step == 0)
|
||||||
|
|
||||||
proc cmp*[T](a, b: SyncRequest[T]): int =
|
proc cmp*[T](a, b: SyncRequest[T]): int =
|
||||||
result = cmp(uint64(a.slot), uint64(b.slot))
|
cmp(uint64(a.slot), uint64(b.slot))
|
||||||
|
|
||||||
proc checkResponse*[T](req: SyncRequest[T],
|
proc checkResponse*[T](req: SyncRequest[T],
|
||||||
data: openArray[ForkedSignedBeaconBlock]): bool =
|
data: openArray[ForkedSignedBeaconBlock]): bool =
|
||||||
|
@ -215,39 +215,39 @@ proc checkResponse*[T](req: SyncRequest[T],
|
||||||
proc getFullMap*[T](req: SyncRequest[T],
|
proc getFullMap*[T](req: SyncRequest[T],
|
||||||
data: openArray[ForkedSignedBeaconBlock]): string =
|
data: openArray[ForkedSignedBeaconBlock]): string =
|
||||||
# Returns all slot numbers in ``data`` as comma-delimeted string.
|
# Returns all slot numbers in ``data`` as comma-delimeted string.
|
||||||
result = mapIt(data, $it.message.slot).join(", ")
|
mapIt(data, $it.message.slot).join(", ")
|
||||||
|
|
||||||
proc init*[T](t1: typedesc[SyncRequest], t2: typedesc[T], slot: Slot,
|
proc init*[T](t1: typedesc[SyncRequest], t2: typedesc[T], slot: Slot,
|
||||||
count: uint64): SyncRequest[T] =
|
count: uint64): SyncRequest[T] =
|
||||||
result = SyncRequest[T](slot: slot, count: count, step: 1'u64)
|
SyncRequest[T](slot: slot, count: count, step: 1'u64)
|
||||||
|
|
||||||
proc init*[T](t1: typedesc[SyncRequest], t2: typedesc[T], start: Slot,
|
proc init*[T](t1: typedesc[SyncRequest], t2: typedesc[T], start: Slot,
|
||||||
finish: Slot): SyncRequest[T] =
|
finish: Slot): SyncRequest[T] =
|
||||||
let count = finish - start + 1'u64
|
let count = finish - start + 1'u64
|
||||||
result = SyncRequest[T](slot: start, count: count, step: 1'u64)
|
SyncRequest[T](slot: start, count: count, step: 1'u64)
|
||||||
|
|
||||||
proc init*[T](t1: typedesc[SyncRequest], t2: typedesc[T], slot: Slot,
|
proc init*[T](t1: typedesc[SyncRequest], t2: typedesc[T], slot: Slot,
|
||||||
count: uint64, item: T): SyncRequest[T] =
|
count: uint64, item: T): SyncRequest[T] =
|
||||||
result = SyncRequest[T](slot: slot, count: count, item: item, step: 1'u64)
|
SyncRequest[T](slot: slot, count: count, item: item, step: 1'u64)
|
||||||
|
|
||||||
proc init*[T](t1: typedesc[SyncRequest], t2: typedesc[T], start: Slot,
|
proc init*[T](t1: typedesc[SyncRequest], t2: typedesc[T], start: Slot,
|
||||||
finish: Slot, item: T): SyncRequest[T] =
|
finish: Slot, item: T): SyncRequest[T] =
|
||||||
let count = finish - start + 1'u64
|
let count = finish - start + 1'u64
|
||||||
result = SyncRequest[T](slot: start, count: count, step: 1'u64, item: item)
|
SyncRequest[T](slot: start, count: count, step: 1'u64, item: item)
|
||||||
|
|
||||||
proc init*[T](t1: typedesc[SyncFailure], kind: SyncFailureKind,
|
proc init*[T](t1: typedesc[SyncFailure], kind: SyncFailureKind,
|
||||||
peer: T): SyncFailure[T] =
|
peer: T): SyncFailure[T] =
|
||||||
result = SyncFailure[T](kind: kind, peer: peer, stamp: now(chronos.Moment))
|
SyncFailure[T](kind: kind, peer: peer, stamp: now(chronos.Moment))
|
||||||
|
|
||||||
proc empty*[T](t: typedesc[SyncRequest],
|
proc empty*[T](t: typedesc[SyncRequest],
|
||||||
t2: typedesc[T]): SyncRequest[T] {.inline.} =
|
t2: typedesc[T]): SyncRequest[T] {.inline.} =
|
||||||
result = SyncRequest[T](step: 0'u64, count: 0'u64)
|
SyncRequest[T](step: 0'u64, count: 0'u64)
|
||||||
|
|
||||||
proc setItem*[T](sr: var SyncRequest[T], item: T) =
|
proc setItem*[T](sr: var SyncRequest[T], item: T) =
|
||||||
sr.item = item
|
sr.item = item
|
||||||
|
|
||||||
proc isEmpty*[T](sr: SyncRequest[T]): bool {.inline.} =
|
proc isEmpty*[T](sr: SyncRequest[T]): bool {.inline.} =
|
||||||
result = (sr.step == 0'u64) and (sr.count == 0'u64)
|
(sr.step == 0'u64) and (sr.count == 0'u64)
|
||||||
|
|
||||||
proc init*[T](t1: typedesc[SyncQueue], t2: typedesc[T],
|
proc init*[T](t1: typedesc[SyncQueue], t2: typedesc[T],
|
||||||
start, last: Slot, chunkSize: uint64,
|
start, last: Slot, chunkSize: uint64,
|
||||||
|
@ -322,10 +322,10 @@ proc init*[T](t1: typedesc[SyncQueue], t2: typedesc[T],
|
||||||
)
|
)
|
||||||
|
|
||||||
proc `<`*[T](a, b: SyncRequest[T]): bool {.inline.} =
|
proc `<`*[T](a, b: SyncRequest[T]): bool {.inline.} =
|
||||||
result = (a.slot < b.slot)
|
a.slot < b.slot
|
||||||
|
|
||||||
proc `<`*[T](a, b: SyncResult[T]): bool {.inline.} =
|
proc `<`*[T](a, b: SyncResult[T]): bool {.inline.} =
|
||||||
result = (a.request.slot < b.request.slot)
|
a.request.slot < b.request.slot
|
||||||
|
|
||||||
proc `==`*[T](a, b: SyncRequest[T]): bool {.inline.} =
|
proc `==`*[T](a, b: SyncRequest[T]): bool {.inline.} =
|
||||||
result = ((a.slot == b.slot) and (a.count == b.count) and
|
result = ((a.slot == b.slot) and (a.count == b.count) and
|
||||||
|
@ -333,7 +333,7 @@ proc `==`*[T](a, b: SyncRequest[T]): bool {.inline.} =
|
||||||
|
|
||||||
proc lastSlot*[T](req: SyncRequest[T]): Slot {.inline.} =
|
proc lastSlot*[T](req: SyncRequest[T]): Slot {.inline.} =
|
||||||
## Returns last slot for request ``req``.
|
## Returns last slot for request ``req``.
|
||||||
result = req.slot + req.count - 1'u64
|
req.slot + req.count - 1'u64
|
||||||
|
|
||||||
proc makePending*[T](sq: SyncQueue[T], req: var SyncRequest[T]) =
|
proc makePending*[T](sq: SyncQueue[T], req: var SyncRequest[T]) =
|
||||||
req.index = sq.counter
|
req.index = sq.counter
|
||||||
|
@ -698,15 +698,15 @@ proc len*[T](sq: SyncQueue[T]): uint64 {.inline.} =
|
||||||
|
|
||||||
proc total*[T](sq: SyncQueue[T]): uint64 {.inline.} =
|
proc total*[T](sq: SyncQueue[T]): uint64 {.inline.} =
|
||||||
## Returns total number of slots in queue ``sq``.
|
## Returns total number of slots in queue ``sq``.
|
||||||
result = sq.lastSlot - sq.startSlot + 1'u64
|
sq.lastSlot - sq.startSlot + 1'u64
|
||||||
|
|
||||||
proc progress*[T](sq: SyncQueue[T]): uint64 =
|
proc progress*[T](sq: SyncQueue[T]): uint64 =
|
||||||
## Returns queue's ``sq`` progress string.
|
## Returns queue's ``sq`` progress string.
|
||||||
let curSlot = sq.outSlot - sq.startSlot
|
let curSlot = sq.outSlot - sq.startSlot
|
||||||
result = (curSlot * 100'u64) div sq.total()
|
(curSlot * 100'u64) div sq.total()
|
||||||
|
|
||||||
proc now*(sm: typedesc[SyncMoment], slot: Slot): SyncMoment {.inline.} =
|
proc now*(sm: typedesc[SyncMoment], slot: Slot): SyncMoment {.inline.} =
|
||||||
result = SyncMoment(stamp: now(chronos.Moment), slot: slot)
|
SyncMoment(stamp: now(chronos.Moment), slot: slot)
|
||||||
|
|
||||||
proc speed*(start, finish: SyncMoment): float {.inline.} =
|
proc speed*(start, finish: SyncMoment): float {.inline.} =
|
||||||
## Returns number of slots per second.
|
## Returns number of slots per second.
|
||||||
|
|
|
@ -390,7 +390,7 @@ proc updateStatus*(peer: Peer): Future[bool] {.async.} =
|
||||||
|
|
||||||
proc getHeadSlot*(peer: Peer): Slot =
|
proc getHeadSlot*(peer: Peer): Slot =
|
||||||
## Returns head slot for specific peer ``peer``.
|
## Returns head slot for specific peer ``peer``.
|
||||||
result = peer.state(BeaconSync).statusMsg.headSlot
|
peer.state(BeaconSync).statusMsg.headSlot
|
||||||
|
|
||||||
proc handleStatus(peer: Peer,
|
proc handleStatus(peer: Peer,
|
||||||
state: BeaconSyncNetworkState,
|
state: BeaconSyncNetworkState,
|
||||||
|
|
|
@ -163,7 +163,7 @@ type
|
||||||
aggSends: seq[AggregatedAttestationSentMessage]
|
aggSends: seq[AggregatedAttestationSentMessage]
|
||||||
aggRecvs: TableRef[string, AggregatedAttestationReceivedMessage]
|
aggRecvs: TableRef[string, AggregatedAttestationReceivedMessage]
|
||||||
|
|
||||||
proc readValue*(reader: var JsonReader, value: var DateTime) =
|
proc readValue(reader: var JsonReader, value: var DateTime) =
|
||||||
let s = reader.readValue(string)
|
let s = reader.readValue(string)
|
||||||
try:
|
try:
|
||||||
value = parse(s, "YYYY-MM-dd HH:mm:ss'.'fffzzz", utc())
|
value = parse(s, "YYYY-MM-dd HH:mm:ss'.'fffzzz", utc())
|
||||||
|
@ -178,8 +178,8 @@ proc init(t: typedesc[GossipMessage], kind: GossipDirection, id,
|
||||||
datetime: parse(datestr, "YYYY-MM-dd HH:mm:ss'.'fffzzz")
|
datetime: parse(datestr, "YYYY-MM-dd HH:mm:ss'.'fffzzz")
|
||||||
)
|
)
|
||||||
|
|
||||||
proc `$`*(msg: GossipMessage): string =
|
func `$`(msg: GossipMessage): string =
|
||||||
result = msg.id
|
msg.id
|
||||||
|
|
||||||
proc readLogFile(file: string): seq[JsonNode] =
|
proc readLogFile(file: string): seq[JsonNode] =
|
||||||
var res = newSeq[JsonNode]()
|
var res = newSeq[JsonNode]()
|
||||||
|
@ -351,7 +351,7 @@ proc filterGossipMessages(log: seq[JsonNode]): seq[GossipMessage] =
|
||||||
node["ts"].getStr())
|
node["ts"].getStr())
|
||||||
result.add(msg)
|
result.add(msg)
|
||||||
|
|
||||||
iterator simDirectoryLogFiles*(simdir: string): string =
|
iterator simDirectoryLogFiles(simdir: string): string =
|
||||||
let absPath = absolutePath(simdir)
|
let absPath = absolutePath(simdir)
|
||||||
let dataPath = absPath & DirSep & "data"
|
let dataPath = absPath & DirSep & "data"
|
||||||
if not dirExists(dataPath):
|
if not dirExists(dataPath):
|
||||||
|
@ -371,8 +371,8 @@ iterator simDirectoryLogFiles*(simdir: string): string =
|
||||||
break
|
break
|
||||||
inc(index)
|
inc(index)
|
||||||
|
|
||||||
proc getDirectoryLogFiles*(builddir: string,
|
proc getDirectoryLogFiles(builddir: string,
|
||||||
filter: seq[string]): seq[NodeDirectory] =
|
filter: seq[string]): seq[NodeDirectory] =
|
||||||
var res = newSeq[NodeDirectory]()
|
var res = newSeq[NodeDirectory]()
|
||||||
let absPath = absolutePath(builddir)
|
let absPath = absolutePath(builddir)
|
||||||
let dataPath = absPath & DirSep & "data"
|
let dataPath = absPath & DirSep & "data"
|
||||||
|
@ -392,8 +392,8 @@ proc getDirectoryLogFiles*(builddir: string,
|
||||||
res.add(nodeDir)
|
res.add(nodeDir)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
proc getLogFiles*(builddir: string,
|
proc getLogFiles(builddir: string,
|
||||||
filter: seq[string]): seq[NodeDirectory] =
|
filter: seq[string]): seq[NodeDirectory] =
|
||||||
var res = newSeq[NodeDirectory]()
|
var res = newSeq[NodeDirectory]()
|
||||||
let dataPath = absolutePath(builddir)
|
let dataPath = absolutePath(builddir)
|
||||||
if not dirExists(dataPath):
|
if not dirExists(dataPath):
|
||||||
|
@ -408,7 +408,7 @@ proc getLogFiles*(builddir: string,
|
||||||
res.add(nodeDir)
|
res.add(nodeDir)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
proc getMessage(logs: seq[GossipMessage],
|
func getMessage(logs: seq[GossipMessage],
|
||||||
msg: GossipMessage): Option[GossipMessage] =
|
msg: GossipMessage): Option[GossipMessage] =
|
||||||
{.push warning[ProveInit]: off.}
|
{.push warning[ProveInit]: off.}
|
||||||
result = none[GossipMessage]()
|
result = none[GossipMessage]()
|
||||||
|
@ -500,8 +500,8 @@ proc runAttSend(logConf: LogTraceConf, logFiles: seq[string]) =
|
||||||
slot_messages = slotMessagesCount,
|
slot_messages = slotMessagesCount,
|
||||||
late_attestation_messages = lateAttsMessagesCount
|
late_attestation_messages = lateAttsMessagesCount
|
||||||
|
|
||||||
proc toSimple*(s: seq[string]): string =
|
func toSimple(s: seq[string]): string =
|
||||||
result = "[" & s.mapIt("'" & it & "'").join(", ") & "]"
|
"[" & s.mapIt("'" & it & "'").join(", ") & "]"
|
||||||
|
|
||||||
proc runAttSendReceive(logConf: LogTraceConf, nodes: seq[NodeDirectory]) =
|
proc runAttSendReceive(logConf: LogTraceConf, nodes: seq[NodeDirectory]) =
|
||||||
info "Check for attestation sent/received messages"
|
info "Check for attestation sent/received messages"
|
||||||
|
|
|
@ -39,7 +39,7 @@ type Timers = enum
|
||||||
tAttest = "Have committee attest to block"
|
tAttest = "Have committee attest to block"
|
||||||
tReplay = "Replay all produced blocks"
|
tReplay = "Replay all produced blocks"
|
||||||
|
|
||||||
proc gauss(r: var Rand; mu = 0.0; sigma = 1.0): float =
|
func gauss(r: var Rand; mu = 0.0; sigma = 1.0): float =
|
||||||
# TODO This is present in Nim 1.4
|
# TODO This is present in Nim 1.4
|
||||||
const K = sqrt(2 / E)
|
const K = sqrt(2 / E)
|
||||||
var
|
var
|
||||||
|
@ -49,7 +49,7 @@ proc gauss(r: var Rand; mu = 0.0; sigma = 1.0): float =
|
||||||
a = rand(r, 1.0)
|
a = rand(r, 1.0)
|
||||||
b = (2.0 * rand(r, 1.0) - 1.0) * K
|
b = (2.0 * rand(r, 1.0) - 1.0) * K
|
||||||
if b * b <= -4.0 * a * a * ln(a): break
|
if b * b <= -4.0 * a * a * ln(a): break
|
||||||
result = mu + sigma * (b / a)
|
mu + sigma * (b / a)
|
||||||
|
|
||||||
# TODO confutils is an impenetrable black box. how can a help text be added here?
|
# TODO confutils is an impenetrable black box. how can a help text be added here?
|
||||||
cli do(slots = SLOTS_PER_EPOCH * 6,
|
cli do(slots = SLOTS_PER_EPOCH * 6,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# beacon_chain
|
# beacon_chain
|
||||||
# Copyright (c) 2019 Status Research & Development GmbH
|
# Copyright (c) 2019-2021 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * 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).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
@ -19,18 +19,18 @@ type
|
||||||
weight: int
|
weight: int
|
||||||
future: Future[void]
|
future: Future[void]
|
||||||
|
|
||||||
proc getKey*(peer: PeerTest): PeerTestID =
|
func getKey*(peer: PeerTest): PeerTestID =
|
||||||
result = peer.id
|
peer.id
|
||||||
|
|
||||||
proc getFuture*(peer: PeerTest): Future[void] =
|
func getFuture*(peer: PeerTest): Future[void] =
|
||||||
result = peer.future
|
peer.future
|
||||||
|
|
||||||
proc `<`*(a, b: PeerTest): bool =
|
func `<`*(a, b: PeerTest): bool =
|
||||||
result = `<`(a.weight, b.weight)
|
`<`(a.weight, b.weight)
|
||||||
|
|
||||||
proc init*(t: typedesc[PeerTest], id: string = "",
|
proc init*(t: typedesc[PeerTest], id: string = "",
|
||||||
weight: int = 0): PeerTest =
|
weight: int = 0): PeerTest =
|
||||||
result = PeerTest(id: id, weight: weight, future: newFuture[void]())
|
PeerTest(id: id, weight: weight, future: newFuture[void]())
|
||||||
|
|
||||||
proc close*(peer: PeerTest) =
|
proc close*(peer: PeerTest) =
|
||||||
peer.future.complete()
|
peer.future.complete()
|
||||||
|
|
Loading…
Reference in New Issue