aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-04 03:30:05 +0800
committerobscuren <geffobscura@gmail.com>2015-03-04 03:30:05 +0800
commitf0b2ea64fc331fe6ef9f15097ac2d129dd9b7207 (patch)
treeb54c28e87d0a64cab079c08108672b8d7e39d5f2 /core
parent27078919669ad99bfb51b468f7c475120e6e148a (diff)
parent6c2856df2335dec946a5ebc14a4438b261e0c881 (diff)
downloadgo-tangerine-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar
go-tangerine-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar.gz
go-tangerine-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar.bz2
go-tangerine-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar.lz
go-tangerine-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar.xz
go-tangerine-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.tar.zst
go-tangerine-f0b2ea64fc331fe6ef9f15097ac2d129dd9b7207.zip
Merge branch 'jsonlogs' of https://github.com/ethersphere/go-ethereum into ethersphere-jsonlogs
Conflicts: eth/block_pool.go eth/block_pool_test.go eth/protocol_test.go miner/worker.go
Diffstat (limited to 'core')
-rw-r--r--core/chain_manager.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 2f6c36382..13edeea95 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -14,7 +14,10 @@ import (
"github.com/ethereum/go-ethereum/state"
)
-var chainlogger = logger.NewLogger("CHAIN")
+var (
+ chainlogger = logger.NewLogger("CHAIN")
+ jsonlogger = logger.NewJsonLogger()
+)
type ChainEvent struct {
Block *types.Block
@@ -124,7 +127,7 @@ func (self *ChainManager) Status() (td *big.Int, currentBlock []byte, genesisBlo
self.mu.RLock()
defer self.mu.RUnlock()
- return self.td, self.currentBlock.Hash(), self.Genesis().Hash()
+ return self.td, self.currentBlock.Hash(), self.genesisBlock.Hash()
}
func (self *ChainManager) SetProcessor(proc types.BlockProcessor) {
@@ -397,11 +400,11 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
var canonical, split bool
self.mu.Lock()
+ cblock := self.currentBlock
{
// Write block to database. Eventually we'll have to improve on this and throw away blocks that are
// not in the canonical chain.
self.write(block)
- cblock := self.currentBlock
// Compare the TD of the last known block in the canonical chain to make sure it's greater.
// At this point it's possible that a different chain (fork) becomes the new canonical chain.
if td.Cmp(self.td) > 0 {
@@ -419,6 +422,12 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
self.mu.Unlock()
if canonical {
+ jsonlogger.LogJson(&logger.EthChainNewHead{
+ BlockHash: ethutil.Bytes2Hex(block.Hash()),
+ BlockNumber: block.Number(),
+ ChainHeadHash: ethutil.Bytes2Hex(cblock.Hash()),
+ BlockPrevHash: ethutil.Bytes2Hex(block.ParentHash()),
+ })
self.setTransState(state.New(block.Root(), self.db))
self.eventMux.Post(ChainEvent{block, td})
}