diff --git a/node/node_handler.go b/node/node_handler.go index 9a30d317a..bf055dab1 100644 --- a/node/node_handler.go +++ b/node/node_handler.go @@ -208,14 +208,13 @@ func (node *Node) WaitForConsensusReady(readySignal chan struct{}) { } for { - node.log.Debug("Start creating new block") // threshold and firstTime are for the test-only built-in smart contract tx. TODO: remove in production threshold := 1 if firstTime { threshold = 2 firstTime = false } - + node.log.Debug("STARTING BLOCK", "threshold", threshold, "pendingTransactions", len(node.pendingTransactions)) if len(node.pendingTransactions) >= threshold { // Normal tx block consensus selectedTxs := node.getTransactionsForNewBlock(MaxNumberOfTransactionsPerBlock) diff --git a/p2p/helper.go b/p2p/helper.go index e3619e68d..18fa6da63 100644 --- a/p2p/helper.go +++ b/p2p/helper.go @@ -4,8 +4,8 @@ import ( "bufio" "bytes" "encoding/binary" + "github.com/harmony-one/harmony/log" "io" - "log" "time" ) @@ -38,12 +38,12 @@ func ReadMessageContent(s Stream) ([]byte, error) { _, err := r.ReadByte() switch err { case io.EOF: - log.Printf("Error reading the p2p message type field: %s", err) + log.Error("Error reading the p2p message type field", "msg", err) return contentBuf.Bytes(), err case nil: //log.Printf("Received p2p message type: %x\n", msgType) default: - log.Printf("Error reading the p2p message type field: %s", err) + log.Error("Error reading the p2p message type field", "msg", err) return contentBuf.Bytes(), err } // TODO: check on msgType and take actions accordingly @@ -51,10 +51,10 @@ func ReadMessageContent(s Stream) ([]byte, error) { fourBytes := make([]byte, 4) n, err := r.Read(fourBytes) if err != nil { - log.Printf("Error reading the p2p message size field") + log.Error("Error reading the p2p message size field") return contentBuf.Bytes(), err } else if n < len(fourBytes) { - log.Printf("Failed reading the p2p message size field: only read %d bytes", n) + log.Error("Failed reading the p2p message size field: only read", "Num of bytes", n) return contentBuf.Bytes(), err } //log.Print(fourBytes) @@ -76,7 +76,7 @@ ILOOP: switch err { case io.EOF: // TODO: should we return error here, or just ignore it? - log.Printf("EOF reached while reading p2p message") + log.Error("EOF reached while reading p2p message") break ILOOP case nil: bytesToRead -= uint32(n) // TODO: think about avoid the casting in every loop @@ -84,7 +84,7 @@ ILOOP: break ILOOP } default: - log.Printf("Error reading p2p message") + log.Error("Error reading p2p message") return []byte{}, err } }