Răsfoiți Sursa

Added eth.chain.received.new_block

Taylor Gerring 10 ani în urmă
părinte
comite
5948adfa10
2 a modificat fișierele cu 13 adăugiri și 5 ștergeri
  1. 8 0
      eth/protocol.go
  2. 5 5
      logger/types.go

+ 8 - 0
eth/protocol.go

@@ -224,6 +224,14 @@ func (self *ethProtocol) handle() error {
 			return self.protoError(ErrDecode, "msg %v: %v", msg, err)
 		}
 		hash := request.Block.Hash()
+		_, chainHead, _ := self.chainManager.Status()
+		jsonlogger.LogJson(&logger.EthChainReceivedNewBlock{
+			BlockHash:     ethutil.Bytes2Hex(hash),
+			BlockNumber:   request.Block.Number(), // this surely must be zero
+			ChainHeadHash: ethutil.Bytes2Hex(chainHead),
+			BlockPrevHash: ethutil.Bytes2Hex(request.Block.ParentHash()),
+			RemoteId:      self.peer.ID().String(),
+		})
 		// to simplify backend interface adding a new block
 		// uses AddPeer followed by AddHashes, AddBlock only if peer is the best peer
 		// (or selected as new best peer)

+ 5 - 5
logger/types.go

@@ -66,11 +66,11 @@ func (l *EthMinerNewBlock) EventName() string {
 }
 
 type EthChainReceivedNewBlock struct {
-	BlockHash     string `json:"block_hash"`
-	BlockNumber   int    `json:"block_number"`
-	ChainHeadHash string `json:"chain_head_hash"`
-	BlockPrevHash string `json:"block_prev_hash"`
-	RemoteId      int    `json:"remote_id"`
+	BlockHash     string   `json:"block_hash"`
+	BlockNumber   *big.Int `json:"block_number"`
+	ChainHeadHash string   `json:"chain_head_hash"`
+	BlockPrevHash string   `json:"block_prev_hash"`
+	RemoteId      string   `json:"remote_id"`
 	LogEvent
 }