From 60a2704b049a2bc8de417c8f50155ec69b071a9e Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sun, 1 Mar 2015 16:09:59 +0100 Subject: Implement eth.miner.new_block event --- miner/worker.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'miner') diff --git a/miner/worker.go b/miner/worker.go index 4f0909302..6f43a9c39 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -10,11 +10,14 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/pow" "github.com/ethereum/go-ethereum/state" "gopkg.in/fatih/set.v0" ) +var jsonlogger = logger.NewJsonLogger() + type environment struct { totalUsedGas *big.Int state *state.StateDB @@ -141,7 +144,12 @@ func (self *worker) wait() { block := self.current.block if block.Number().Uint64() == work.Number && block.Nonce() == nil { self.current.block.Header().Nonce = work.Nonce - + jsonlogger.LogJson(&logger.EthMinerNewBlock{ + BlockHash: ethutil.Bytes2Hex(block.Hash()), + BlockNumber: block.Number(), + ChainHeadHash: ethutil.Bytes2Hex(block.ParentHeaderHash), + BlockPrevHash: ethutil.Bytes2Hex(block.ParentHeaderHash), + }) if err := self.chain.InsertChain(types.Blocks{self.current.block}); err == nil { self.mux.Post(core.NewMinedBlockEvent{self.current.block}) } else { -- cgit