Skip to content

Commit

Permalink
Block tree enhancements (prysmaticlabs#4764)
Browse files Browse the repository at this point in the history
* Add votes, correct conversion and green for head

* Starting testing

* Fix for run time
  • Loading branch information
terencechain authored and cryptomental committed Feb 24, 2020
1 parent 77dc539 commit 346858f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions beacon-chain/blockchain/info.go
Expand Up @@ -79,17 +79,25 @@ func (s *Service) TreeHandler(w http.ResponseWriter, _ *http.Request) {
graph.Attr("labeljust", "l")

dotNodes := make([]*dot.Node, len(nodes))
avgBalance := uint64(averageBalance(s.headState.Balances()))

for i := len(nodes) - 1; i >= 0; i-- {
// Construct label for each node.
slot := strconv.Itoa(int(nodes[i].Slot))
weight := strconv.Itoa(int(nodes[i].Weight / 10e9))
weight := strconv.Itoa(int(nodes[i].Weight / 1e9)) // Convert unit Gwei to unit ETH.
votes := strconv.Itoa(int(nodes[i].Weight / 1e9 / avgBalance))
bestDescendent := strconv.Itoa(int(nodes[i].BestDescendent))
index := strconv.Itoa(int(i))
label := "slot: " + slot + "\n index: " + index + "\n bestDescendent: " + bestDescendent + "\n weight: " + weight
label := "slot: " + slot + "\n index: " + index + "\n bestDescendent: " + bestDescendent + "\n votes: " + votes + "\n weight: " + weight
var dotN dot.Node
if nodes[i].Parent != ^uint64(0) {
dotN = graph.Node(index).Box().Attr("label", label)
}

if nodes[i].Slot == s.headSlot {
dotN = dotN.Attr("color", "green")
}

dotNodes[i] = &dotN
}

Expand Down

0 comments on commit 346858f

Please sign in to comment.