good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
94e543bc
Commit
94e543bc
authored
Mar 5, 2015
by
Taylor Gerring
Browse files
Options
Downloads
Plain Diff
Merge pull request #431 from tgerring/jsonlogs
Structured logging updates
parents
f01d745d
5948adfa
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/chain_manager.go
+9
-2
9 additions, 2 deletions
core/chain_manager.go
eth/protocol.go
+8
-0
8 additions, 0 deletions
eth/protocol.go
logger/types.go
+9
-9
9 additions, 9 deletions
logger/types.go
with
26 additions
and
11 deletions
core/chain_manager.go
+
9
−
2
View file @
94e543bc
...
@@ -15,6 +15,7 @@ import (
...
@@ -15,6 +15,7 @@ import (
)
)
var
chainlogger
=
logger
.
NewLogger
(
"CHAIN"
)
var
chainlogger
=
logger
.
NewLogger
(
"CHAIN"
)
var
jsonlogger
=
logger
.
NewJsonLogger
()
type
ChainEvent
struct
{
type
ChainEvent
struct
{
Block
*
types
.
Block
Block
*
types
.
Block
...
@@ -122,7 +123,7 @@ func (self *ChainManager) Status() (td *big.Int, currentBlock []byte, genesisBlo
...
@@ -122,7 +123,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
.
G
enesis
()
.
Hash
()
return
self
.
td
,
self
.
currentBlock
.
Hash
(),
self
.
g
enesis
Block
.
Hash
()
}
}
func
(
self
*
ChainManager
)
SetProcessor
(
proc
types
.
BlockProcessor
)
{
func
(
self
*
ChainManager
)
SetProcessor
(
proc
types
.
BlockProcessor
)
{
...
@@ -395,11 +396,11 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -395,11 +396,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 +418,12 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -417,6 +418,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
})
}
}
...
...
This diff is collapsed.
Click to expand it.
eth/protocol.go
+
8
−
0
View file @
94e543bc
...
@@ -224,6 +224,14 @@ func (self *ethProtocol) handle() error {
...
@@ -224,6 +224,14 @@ func (self *ethProtocol) handle() error {
return
self
.
protoError
(
ErrDecode
,
"msg %v: %v"
,
msg
,
err
)
return
self
.
protoError
(
ErrDecode
,
"msg %v: %v"
,
msg
,
err
)
}
}
hash
:=
request
.
Block
.
Hash
()
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
// to simplify backend interface adding a new block
// uses AddPeer followed by AddHashes, AddBlock only if peer is the best peer
// uses AddPeer followed by AddHashes, AddBlock only if peer is the best peer
// (or selected as new best peer)
// (or selected as new best peer)
...
...
This diff is collapsed.
Click to expand it.
logger/types.go
+
9
−
9
View file @
94e543bc
...
@@ -67,10 +67,10 @@ func (l *EthMinerNewBlock) EventName() string {
...
@@ -67,10 +67,10 @@ func (l *EthMinerNewBlock) EventName() string {
type
EthChainReceivedNewBlock
struct
{
type
EthChainReceivedNewBlock
struct
{
BlockHash
string
`json:"block_hash"`
BlockHash
string
`json:"block_hash"`
BlockNumber
int
`json:"block_number"`
BlockNumber
*
big
.
Int
`json:"block_number"`
ChainHeadHash
string
`json:"chain_head_hash"`
ChainHeadHash
string
`json:"chain_head_hash"`
BlockPrevHash
string
`json:"block_prev_hash"`
BlockPrevHash
string
`json:"block_prev_hash"`
RemoteId
int
`json:"remote_id"`
RemoteId
string
`json:"remote_id"`
LogEvent
LogEvent
}
}
...
@@ -80,7 +80,7 @@ func (l *EthChainReceivedNewBlock) EventName() string {
...
@@ -80,7 +80,7 @@ func (l *EthChainReceivedNewBlock) EventName() string {
type
EthChainNewHead
struct
{
type
EthChainNewHead
struct
{
BlockHash
string
`json:"block_hash"`
BlockHash
string
`json:"block_hash"`
BlockNumber
int
`json:"block_number"`
BlockNumber
*
big
.
Int
`json:"block_number"`
ChainHeadHash
string
`json:"chain_head_hash"`
ChainHeadHash
string
`json:"chain_head_hash"`
BlockPrevHash
string
`json:"block_prev_hash"`
BlockPrevHash
string
`json:"block_prev_hash"`
LogEvent
LogEvent
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment