11package simple
22
33import (
4+ "fmt"
5+ "strings"
6+
47 "github.com/ethereum/go-ethereum/consensus"
58 "github.com/ethereum/go-ethereum/log"
69)
@@ -11,10 +14,23 @@ type API struct {
1114 backend * simpleBackend
1215}
1316
14- func (self * API ) ConsensusState () {
15- log .Info ("Dump PBFT state" )
17+ // Snapshot returns current state and proposer
18+ func (api * API ) Snapshot () {
19+ state , snapshot := api .backend .core .Snapshot ()
20+ p := api .backend .valSet .GetProposer ().Address ()
21+ log .Info ("Snapshot" , "sequence" , snapshot .Sequence , "Round" , snapshot .Round ,
22+ "state" , state , "proposer" , p .Hex (),
23+ "hash" , snapshot .Preprepare .Proposal .Hash ().Hex (),
24+ "prepares" , snapshot .Prepares , "commits" , snapshot .Commits ,
25+ "checkpoint" , snapshot .Checkpoints )
1626}
1727
18- func (self * API ) ViewChange () {
19- log .Info ("Force view change" )
28+ // Backlog returns backlogs
29+ func (api * API ) Backlog () {
30+ backlog := api .backend .core .Backlog ()
31+ logs := make ([]string , 0 , len (backlog ))
32+ for address , q := range backlog {
33+ logs = append (logs , fmt .Sprintf ("{%v, %v}" , address .Address ().Hex (), q .Size ()))
34+ }
35+ log .Info ("Backlog" , "logs" , fmt .Sprintf ("[%v]" , strings .Join (logs , ", " )))
2036}
0 commit comments