Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
6c2856df
Commit
6c2856df
authored
Mar 03, 2015
by
zelig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add eth.chain.new_head log to core/chain_manager
parent
fc47f0f2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
chain_manager.go
core/chain_manager.go
+12
-3
No files found.
core/chain_manager.go
View file @
6c2856df
...
@@ -14,7 +14,10 @@ import (
...
@@ -14,7 +14,10 @@ import (
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/state"
)
)
var
chainlogger
=
logger
.
NewLogger
(
"CHAIN"
)
var
(
chainlogger
=
logger
.
NewLogger
(
"CHAIN"
)
jsonlogger
=
logger
.
NewJsonLogger
()
)
type
ChainEvent
struct
{
type
ChainEvent
struct
{
Block
*
types
.
Block
Block
*
types
.
Block
...
@@ -122,7 +125,7 @@ func (self *ChainManager) Status() (td *big.Int, currentBlock []byte, genesisBlo
...
@@ -122,7 +125,7 @@ func (self *ChainManager) Status() (td *big.Int, currentBlock []byte, genesisBlo
self
.
mu
.
RLock
()
self
.
mu
.
RLock
()
defer
self
.
mu
.
RUnlock
()
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
)
{
func
(
self
*
ChainManager
)
SetProcessor
(
proc
types
.
BlockProcessor
)
{
...
@@ -395,11 +398,11 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -395,11 +398,11 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
var
canonical
,
split
bool
var
canonical
,
split
bool
self
.
mu
.
Lock
()
self
.
mu
.
Lock
()
cblock
:=
self
.
currentBlock
{
{
// Write block to database. Eventually we'll have to improve on this and throw away blocks that are
// Write block to database. Eventually we'll have to improve on this and throw away blocks that are
// not in the canonical chain.
// not in the canonical chain.
self
.
write
(
block
)
self
.
write
(
block
)
cblock
:=
self
.
currentBlock
// Compare the TD of the last known block in the canonical chain to make sure it's greater.
// 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.
// At this point it's possible that a different chain (fork) becomes the new canonical chain.
if
td
.
Cmp
(
self
.
td
)
>
0
{
if
td
.
Cmp
(
self
.
td
)
>
0
{
...
@@ -417,6 +420,12 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -417,6 +420,12 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
self
.
mu
.
Unlock
()
self
.
mu
.
Unlock
()
if
canonical
{
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
.
setTransState
(
state
.
New
(
block
.
Root
(),
self
.
db
))
self
.
eventMux
.
Post
(
ChainEvent
{
block
,
td
})
self
.
eventMux
.
Post
(
ChainEvent
{
block
,
td
})
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment