Merge pull request #431 from tgerring/jsonlogs

Structured logging updates
This commit is contained in:
Taylor Gerring
2015-03-05 14:32:41 -06:00
3 changed files with 26 additions and 11 deletions

View File

@@ -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)