Cosmetic improvements to the status bar; Attempt to fix the CI

This commit is contained in:
Zahary Karadjov 2019-10-07 17:29:39 +09:00 committed by zah
parent f72a58595f
commit c23b011c77
4 changed files with 29 additions and 2 deletions

View File

@ -865,6 +865,11 @@ when hasPrompt:
else:
p[].writeLine("Unknown command: " & cmd)
proc slotOrZero(time: BeaconTime): Slot =
let exSlot = time.toSlot
if exSlot.afterGenesis: exSlot.slot
else: Slot(0)
proc initPrompt(node: BeaconNode) =
if isatty(stdout) and node.config.statusbar:
enableTrueColors()
@ -892,7 +897,21 @@ when hasPrompt:
of "last_finalized_epoch":
var head = node.blockPool.finalizedHead
# TODO: Should we display a state root instead?
$(head.slot) & "(" & shortLog(head.blck.root) & ")"
$(head.slot.epoch) & " (" & shortLog(head.blck.root) & ")"
of "epoch":
$node.beaconClock.now.slotOrZero.epoch
of "epoch_slot":
$(node.beaconClock.now.slotOrZero mod SLOTS_PER_EPOCH)
of "slots_per_epoch":
$SLOTS_PER_EPOCH
of "slot_trailing_digits":
var slotStr = $node.beaconClock.now.slotOrZero
if slotStr.len > 3: slotStr = slotStr[^3..^1]
slotStr
of "attached_validators_balance":
var balance = uint64(0)

View File

@ -54,7 +54,9 @@ type
statusbarContents* {.
desc: ""
defaultValue: "peers: $connected_peers; finalized epoch: $last_finalized_epoch |" &
defaultValue: "peers: $connected_peers; " &
"epoch: $epoch, slot: $epoch_slot/$slots_per_epoch (..$slot_trailing_digits); " &
"finalized epoch: $last_finalized_epoch |" &
"ETH: $attached_validators_balance" }: string
case cmd* {.

View File

@ -68,6 +68,9 @@ func compute_epoch_of_slot*(slot: Slot|uint64): Epoch =
# Return the epoch number of the given ``slot``.
(slot div SLOTS_PER_EPOCH).Epoch
template epoch*(slot: Slot): Epoch =
compute_epoch_of_slot(slot)
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.3/specs/core/0_beacon-chain.md#compute_start_slot_of_epoch
func compute_start_slot_of_epoch*(epoch: Epoch): Slot =
# Return the start slot of ``epoch``.

View File

@ -11,6 +11,9 @@
--passL:"-Wl,--stack,8388608"
# https://github.com/nim-lang/Nim/issues/4057
--tlsEmulation:off
# The dynamic Chronicles output currently prevents us from using colors on Windows
# because these require direct manipulations of the stdout File object.
-d:"chronicles_colors=off"
@end
@if testnet_docker_node: