diff options
-rw-r--r-- | core/types/block-randomness.go | 4 | ||||
-rw-r--r-- | core/types/block.go | 2 | ||||
-rw-r--r-- | core/types/dkg/dkg.go | 8 | ||||
-rw-r--r-- | core/types/position.go | 3 | ||||
-rw-r--r-- | core/types/vote.go | 3 | ||||
-rw-r--r-- | simulation/node.go | 6 |
6 files changed, 16 insertions, 10 deletions
diff --git a/core/types/block-randomness.go b/core/types/block-randomness.go index 1eaa3e3..6df245b 100644 --- a/core/types/block-randomness.go +++ b/core/types/block-randomness.go @@ -31,8 +31,8 @@ type AgreementResult struct { } func (r *AgreementResult) String() string { - return fmt.Sprintf( - "agreementResult[%s:%s]", r.BlockHash, &r.Position) + return fmt.Sprintf("agreementResult{Hash:%s %s}", + r.BlockHash.String()[:6], &r.Position) } // BlockRandomnessResult describes a block randomness result diff --git a/core/types/block.go b/core/types/block.go index b24e1f7..f42b702 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -221,7 +221,7 @@ func (b *Block) DecodeRLP(s *rlp.Stream) error { } func (b *Block) String() string { - return fmt.Sprintf("Block(%v:%s)", b.Hash.String()[:6], &b.Position) + return fmt.Sprintf("Block{Hash:%v %s}", b.Hash.String()[:6], &b.Position) } // Clone returns a deep copy of a block. diff --git a/core/types/dkg/dkg.go b/core/types/dkg/dkg.go index 4053c5a..cecc4f1 100644 --- a/core/types/dkg/dkg.go +++ b/core/types/dkg/dkg.go @@ -61,7 +61,7 @@ type MasterPublicKey struct { } func (d *MasterPublicKey) String() string { - return fmt.Sprintf("MasterPublicKey[%s:%d]", + return fmt.Sprintf("MasterPublicKey{KP:%s Round:%d}", d.ProposerID.String()[:6], d.Round) } @@ -141,11 +141,11 @@ type Complaint struct { func (c *Complaint) String() string { if c.IsNack() { - return fmt.Sprintf("DKGNackComplaint[%s:%d]%s", + return fmt.Sprintf("DKGNackComplaint{CP:%s Round:%d PSP:%s}", c.ProposerID.String()[:6], c.Round, c.PrivateShare.ProposerID.String()[:6]) } - return fmt.Sprintf("Complaint[%s:%d]%v", + return fmt.Sprintf("DKGComplaint{CP:%s Round:%d PrivateShare:%v}", c.ProposerID.String()[:6], c.Round, c.PrivateShare) } @@ -175,7 +175,7 @@ type Finalize struct { } func (final *Finalize) String() string { - return fmt.Sprintf("DKGFinal[%s:%d]", + return fmt.Sprintf("DKGFinal{FP:%s Round:%d}", final.ProposerID.String()[:6], final.Round) } diff --git a/core/types/position.go b/core/types/position.go index 1fc7e6b..8822f6e 100644 --- a/core/types/position.go +++ b/core/types/position.go @@ -29,7 +29,8 @@ type Position struct { } func (pos *Position) String() string { - return fmt.Sprintf("[%d:%d:%d]", pos.Round, pos.ChainID, pos.Height) + return fmt.Sprintf("Position{Round:%d Chain:%d Height:%d}", + pos.Round, pos.ChainID, pos.Height) } // Equal checks if two positions are equal, it panics when their chainIDs diff --git a/core/types/vote.go b/core/types/vote.go index 12c3af8..7601542 100644 --- a/core/types/vote.go +++ b/core/types/vote.go @@ -52,7 +52,8 @@ type Vote struct { } func (v *Vote) String() string { - return fmt.Sprintf("Vote[%s:%s](%d:%d):%s", v.ProposerID.String()[:6], + return fmt.Sprintf("Vote{BP:%s %s Period:%d Type:%d Hash:%s}", + v.ProposerID.String()[:6], &v.Position, v.Period, v.Type, v.BlockHash.String()[:6]) } diff --git a/simulation/node.go b/simulation/node.go index ef54ffc..8c37f65 100644 --- a/simulation/node.go +++ b/simulation/node.go @@ -20,6 +20,7 @@ package simulation import ( "encoding/json" "fmt" + "os" "time" "github.com/dexon-foundation/dexon-consensus/common" @@ -29,6 +30,7 @@ import ( "github.com/dexon-foundation/dexon-consensus/core/test" "github.com/dexon-foundation/dexon-consensus/core/types" "github.com/dexon-foundation/dexon-consensus/simulation/config" + "github.com/dexon-foundation/dexon/log" ) type infoStatus string @@ -144,6 +146,8 @@ func (n *node) run(serverEndpoint interface{}, dMoment time.Time) { // Setup of governance is ready, can be switched to remote mode. n.gov.SwitchToRemoteMode(n.netModule) // Setup Consensus. + logger := log.New() + logger.SetHandler(log.StreamHandler(os.Stderr, log.LogfmtFormat())) n.consensus = core.NewConsensus( dMoment, n.app, @@ -151,7 +155,7 @@ func (n *node) run(serverEndpoint interface{}, dMoment time.Time) { n.db, n.netModule, n.prvKey, - &common.SimpleLogger{}) + logger) go n.consensus.Run(&types.Block{}) // Blocks forever. |