aboutsummaryrefslogtreecommitdiffstats
path: root/core/types
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-10-19 18:39:17 +0800
committerGitHub <noreply@github.com>2018-10-19 18:39:17 +0800
commit1f7491df37caf974ffa0c824c4c02a8fe2aafcd9 (patch)
tree55c6e653c3d78ab34e3fbe8627ba1c0a62cb53a8 /core/types
parentbec97aadfa95ebb42ef042bd53c7976ae410c496 (diff)
downloadtangerine-consensus-1f7491df37caf974ffa0c824c4c02a8fe2aafcd9.tar
tangerine-consensus-1f7491df37caf974ffa0c824c4c02a8fe2aafcd9.tar.gz
tangerine-consensus-1f7491df37caf974ffa0c824c4c02a8fe2aafcd9.tar.bz2
tangerine-consensus-1f7491df37caf974ffa0c824c4c02a8fe2aafcd9.tar.lz
tangerine-consensus-1f7491df37caf974ffa0c824c4c02a8fe2aafcd9.tar.xz
tangerine-consensus-1f7491df37caf974ffa0c824c4c02a8fe2aafcd9.tar.zst
tangerine-consensus-1f7491df37caf974ffa0c824c4c02a8fe2aafcd9.zip
core: initial commit for logger (#228)
* Replace "log.*" with logger. * Add simple logger to log with log package. * Add debug logs to all calls to these interfaces: - core.Application - core.Governance - core.Network * Add Stringer to these types: - types.DKGComplaint - types.AgreementResult - types.DKGMasterPublicKey - types.DKGFinalize
Diffstat (limited to 'core/types')
-rw-r--r--core/types/block-randomness.go7
-rw-r--r--core/types/dkg.go17
-rw-r--r--core/types/position.go9
3 files changed, 32 insertions, 1 deletions
diff --git a/core/types/block-randomness.go b/core/types/block-randomness.go
index b101e22..ebffd2b 100644
--- a/core/types/block-randomness.go
+++ b/core/types/block-randomness.go
@@ -18,6 +18,8 @@
package types
import (
+ "fmt"
+
"github.com/dexon-foundation/dexon-consensus-core/common"
)
@@ -28,6 +30,11 @@ type AgreementResult struct {
Votes []Vote `json:"votes"`
}
+func (r *AgreementResult) String() string {
+ return fmt.Sprintf(
+ "agreementResult[%s:%s]", r.BlockHash, &r.Position)
+}
+
// BlockRandomnessResult describes a block randomness result
type BlockRandomnessResult struct {
BlockHash common.Hash `json:"block_hash"`
diff --git a/core/types/dkg.go b/core/types/dkg.go
index c13740b..6018ebd 100644
--- a/core/types/dkg.go
+++ b/core/types/dkg.go
@@ -53,6 +53,12 @@ type DKGMasterPublicKey struct {
Signature crypto.Signature `json:"signature"`
}
+func (d *DKGMasterPublicKey) String() string {
+ return fmt.Sprintf("MasterPublicKey[%s:%d]",
+ d.ProposerID.String()[:6],
+ d.Round)
+}
+
// NewDKGMasterPublicKey returns a new DKGMasterPublicKey instance.
func NewDKGMasterPublicKey() *DKGMasterPublicKey {
return &DKGMasterPublicKey{
@@ -75,6 +81,11 @@ type DKGComplaint struct {
Signature crypto.Signature `json:"signature"`
}
+func (c *DKGComplaint) String() string {
+ return fmt.Sprintf("DKGComplaint[%s:%d]%s",
+ c.ProposerID.String()[:6], c.Round, &c.PrivateShare)
+}
+
// DKGPartialSignature describe a partial signature in DKG protocol.
type DKGPartialSignature struct {
ProposerID NodeID `json:"proposer_id"`
@@ -91,6 +102,12 @@ type DKGFinalize struct {
Signature crypto.Signature `json:"signature"`
}
+func (final *DKGFinalize) String() string {
+ return fmt.Sprintf("DKGFinal[%s:%d]",
+ final.ProposerID.String()[:6],
+ final.Round)
+}
+
// IsNack returns true if it's a nack complaint in DKG protocol.
func (c *DKGComplaint) IsNack() bool {
return len(c.PrivateShare.Signature.Signature) == 0
diff --git a/core/types/position.go b/core/types/position.go
index 4e254ba..51de405 100644
--- a/core/types/position.go
+++ b/core/types/position.go
@@ -17,7 +17,10 @@
package types
-import "errors"
+import (
+ "errors"
+ "fmt"
+)
// ErrComparePositionOnDifferentChains raised when attempting to
// compare two positions with different chain ID.
@@ -31,6 +34,10 @@ type Position struct {
Height uint64 `json:"height"`
}
+func (pos *Position) String() string {
+ return fmt.Sprintf("pos[%d:%d:%d]", pos.ChainID, pos.Round, pos.Height)
+}
+
// Equal checks if two positions are equal, it panics when their chainIDs
// are different.
func (pos *Position) Equal(other *Position) bool {