diff --git a/consensus/consensus.go b/consensus/consensus.go index 03e60669e..3148c0b3d 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -36,7 +36,7 @@ type Consensus struct { // BlockHeader to run consensus on blockHeader []byte // Shard Id which this node belongs to - ShardId uint32 + ShardIDShardID uint32 // Signal channel for starting a new consensus process ReadySignal chan int @@ -80,8 +80,10 @@ func (state ConsensusState) String() string { return names[state] } -// Create a new Consensus object -func NewConsensus(ip, port, shardId string, peers []p2p.Peer, leader p2p.Peer) Consensus { +// NewConsensus creates a new Consensus object +// TODO(minhdoan): Maybe convert it into just New +// FYI, see https://golang.org/doc/effective_go.html?#package-names +func NewConsensus(ip, port, ShardID string, peers []p2p.Peer, leader p2p.Peer) Consensus { // The first Ip, port passed will be leader. consensus := Consensus{} peer := p2p.Peer{Port: port, Ip: ip} @@ -104,11 +106,11 @@ func NewConsensus(ip, port, shardId string, peers []p2p.Peer, leader p2p.Peer) C consensus.Log.Crit("Regex Compilation Failed", "err", err, "consensus", consensus) } consensus.consensusId = 0 - myShardId, err := strconv.Atoi(shardId) + myShardIDShardID, err := strconv.Atoi(ShardID) if err != nil { - panic("Unparseable shard Id" + shardId) + panic("Unparseable shard Id" + ShardID) } - consensus.ShardId = uint32(myShardId) + consensus.ShardIDShardID = uint32(myShardIDShardID) // For now use socket address as 16 byte Id // TODO: populate with correct Id @@ -146,5 +148,5 @@ func (consensus *Consensus) String() string { } else { duty = "VLD" // validator } - return fmt.Sprintf("[%s, %s, %v, %v]", duty, consensus.priKey, consensus.ShardId, consensus.nodeId) + return fmt.Sprintf("[%s, %s, %v, %v]", duty, consensus.priKey, consensus.ShardIDShardID, consensus.nodeId) } diff --git a/log/doc.go b/log/doc.go index bff2f4966..9aa72bf42 100644 --- a/log/doc.go +++ b/log/doc.go @@ -1,3 +1,5 @@ +package log + /* Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable. It is modeled after the standard library's io and net/http @@ -330,4 +332,3 @@ The Name https://xkcd.com/927/ */ -package log diff --git a/log/format.go b/log/format.go index bed32bd2d..2db2e6bf6 100644 --- a/log/format.go +++ b/log/format.go @@ -50,6 +50,7 @@ var fieldPadding = make(map[string]int) // fieldPaddingLock is a global mutex protecting the field padding map. var fieldPaddingLock sync.RWMutex +// Format interface. type Format interface { Format(r *Record) []byte } diff --git a/log/logger.go b/log/logger.go index 438aa548f..5e5924a3d 100644 --- a/log/logger.go +++ b/log/logger.go @@ -14,8 +14,10 @@ const msgKey = "msg" const errorKey = "LOG15_ERROR" const skipLevel = 2 +// Lvl type. type Lvl int +// Constants. const ( LvlCrit Lvl = iota LvlError diff --git a/log/root.go b/log/root.go index 9fb4c5ae0..32366a0d8 100644 --- a/log/root.go +++ b/log/root.go @@ -5,8 +5,10 @@ import ( ) var ( - root = &logger{[]interface{}{}, new(swapHandler)} + root = &logger{[]interface{}{}, new(swapHandler)} + // StdoutHandler handles stdout StdoutHandler = StreamHandler(os.Stdout, LogfmtFormat()) + // StderrHandler handles stderr StderrHandler = StreamHandler(os.Stderr, LogfmtFormat()) )