add addtional log message in transportation

Signed-off-by: Leo Chen <leo@harmony.one>
pull/76/head
Leo Chen 6 years ago
parent 1323877d61
commit 13dfea2e84
  1. 6
      consensus/consensus_leader.go
  2. 11
      node/node_handler.go

@ -173,12 +173,13 @@ func (consensus *Consensus) processCommitMessage(payload []byte, targetState Sta
point := crypto.Ed25519Curve.Point() point := crypto.Ed25519Curve.Point()
point.UnmarshalBinary(commitment) point.UnmarshalBinary(commitment)
(*commitments)[validatorID] = point (*commitments)[validatorID] = point
consensus.Log.Debug("Received new commit message", "num", len(*commitments)) consensus.Log.Debug("Received new commit message", "num", len(*commitments), "validatorID", validatorID)
// Set the bitmap indicate this validate signed. TODO: figure out how to resolve the inconsistency of validators from commit and response messages // Set the bitmap indicate this validate signed. TODO: figure out how to resolve the inconsistency of validators from commit and response messages
bitmap.SetKey(value.PubKey, true) bitmap.SetKey(value.PubKey, true)
} }
if !shouldProcess { if !shouldProcess {
consensus.Log.Debug("Received new commit message", "validatorID", validatorID)
return return
} }
@ -310,13 +311,14 @@ func (consensus *Consensus) processResponseMessage(payload []byte, targetState S
shouldProcess = false shouldProcess = false
} else { } else {
(*responses)[validatorID] = responseScalar (*responses)[validatorID] = responseScalar
consensus.Log.Debug("Received new response message", "num", len(*responses)) consensus.Log.Debug("Received new response message", "num", len(*responses), "validatorID", validatorID)
// Set the bitmap indicate this validate signed. TODO: figure out how to resolve the inconsistency of validators from commit and response messages // Set the bitmap indicate this validate signed. TODO: figure out how to resolve the inconsistency of validators from commit and response messages
bitmap.SetKey(value.PubKey, true) bitmap.SetKey(value.PubKey, true)
} }
} }
if !shouldProcess { if !shouldProcess {
consensus.Log.Debug("Received new response message", "validatorID", validatorID)
return return
} }

@ -79,6 +79,7 @@ func (node *Node) NodeHandler(conn net.Conn) {
fmt.Println("received a identity message") fmt.Println("received a identity message")
// TODO(ak): fix it. // TODO(ak): fix it.
// node.processPOWMessage(msgPayload) // node.processPOWMessage(msgPayload)
node.log.Info("NET: received message: IDENTITY/REGISTER")
case proto_identity.Announce: case proto_identity.Announce:
node.log.Error("Announce message should be sent to IdentityChain") node.log.Error("Announce message should be sent to IdentityChain")
} }
@ -88,8 +89,10 @@ func (node *Node) NodeHandler(conn net.Conn) {
switch actionType { switch actionType {
case consensus.Consensus: case consensus.Consensus:
if consensusObj.IsLeader { if consensusObj.IsLeader {
node.log.Info("NET: received message: Consensus/Leader")
consensusObj.ProcessMessageLeader(msgPayload) consensusObj.ProcessMessageLeader(msgPayload)
} else { } else {
node.log.Info("NET: received message: Consensus/Validator")
consensusObj.ProcessMessageValidator(msgPayload) consensusObj.ProcessMessageValidator(msgPayload)
} }
} }
@ -97,8 +100,10 @@ func (node *Node) NodeHandler(conn net.Conn) {
actionType := proto_node.NodeMessageType(msgType) actionType := proto_node.NodeMessageType(msgType)
switch actionType { switch actionType {
case proto_node.Transaction: case proto_node.Transaction:
node.log.Info("NET: received message: Node/Transaction")
node.transactionMessageHandler(msgPayload) node.transactionMessageHandler(msgPayload)
case proto_node.BLOCK: case proto_node.BLOCK:
node.log.Info("NET: received message: Node/BLOCK")
blockMsgType := proto_node.BlockMessageType(msgPayload[0]) blockMsgType := proto_node.BlockMessageType(msgPayload[0])
switch blockMsgType { switch blockMsgType {
case proto_node.Sync: case proto_node.Sync:
@ -110,8 +115,10 @@ func (node *Node) NodeHandler(conn net.Conn) {
} }
} }
case proto_node.BlockchainSync: case proto_node.BlockchainSync:
node.log.Info("NET: received message: Node/BlockchainSync")
node.handleBlockchainSync(msgPayload, conn) node.handleBlockchainSync(msgPayload, conn)
case proto_node.CLIENT: case proto_node.CLIENT:
node.log.Info("NET: received message: Node/CLIENT")
clientMsgType := proto_node.ClientMessageType(msgPayload[0]) clientMsgType := proto_node.ClientMessageType(msgPayload[0])
switch clientMsgType { switch clientMsgType {
case proto_node.LookupUtxo: case proto_node.LookupUtxo:
@ -125,6 +132,7 @@ func (node *Node) NodeHandler(conn net.Conn) {
p2p.SendMessage(fetchUtxoMessage.Sender, client.ConstructFetchUtxoResponseMessage(&utxoMap, node.UtxoPool.ShardID)) p2p.SendMessage(fetchUtxoMessage.Sender, client.ConstructFetchUtxoResponseMessage(&utxoMap, node.UtxoPool.ShardID))
} }
case proto_node.CONTROL: case proto_node.CONTROL:
node.log.Info("NET: received message: Node/CONTROL")
controlType := msgPayload[0] controlType := msgPayload[0]
if proto_node.ControlMessageType(controlType) == proto_node.STOP { if proto_node.ControlMessageType(controlType) == proto_node.STOP {
node.log.Debug("Stopping Node", "node", node, "numBlocks", len(node.blockchain.Blocks), "numTxsProcessed", node.countNumTransactionsInBlockchain()) node.log.Debug("Stopping Node", "node", node, "numBlocks", len(node.blockchain.Blocks), "numTxsProcessed", node.countNumTransactionsInBlockchain())
@ -172,6 +180,7 @@ func (node *Node) NodeHandler(conn net.Conn) {
} }
case proto.CLIENT: case proto.CLIENT:
actionType := client.ClientMessageType(msgType) actionType := client.ClientMessageType(msgType)
node.log.Info("NET: received message: CLIENT/Transaction")
switch actionType { switch actionType {
case client.Transaction: case client.Transaction:
if node.Client != nil { if node.Client != nil {
@ -357,7 +366,7 @@ func (node *Node) SendBackProofOfAcceptOrReject() {
// NOTE: For now, just send to the client (basically not broadcasting) // NOTE: For now, just send to the client (basically not broadcasting)
func (node *Node) BroadcastNewBlock(newBlock *blockchain.Block) { func (node *Node) BroadcastNewBlock(newBlock *blockchain.Block) {
if node.ClientPeer != nil { if node.ClientPeer != nil {
node.log.Debug("SENDING NEW BLOCK TO CLIENT") node.log.Debug("NET: SENDING NEW BLOCK TO CLIENT")
p2p.SendMessage(*node.ClientPeer, proto_node.ConstructBlocksSyncMessage([]blockchain.Block{*newBlock})) p2p.SendMessage(*node.ClientPeer, proto_node.ConstructBlocksSyncMessage([]blockchain.Block{*newBlock}))
} }
} }

Loading…
Cancel
Save