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
be6a3696
Commit
be6a3696
authored
Oct 10, 2016
by
Felix Lange
Committed by
GitHub
Oct 10, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3104 from fjl/core-import-log
core: print import stats more often
parents
7943ecb8
82b14a05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
12 deletions
+43
-12
blockchain.go
core/blockchain.go
+42
-11
handler.go
eth/handler.go
+1
-1
No files found.
core/blockchain.go
View file @
be6a3696
...
...
@@ -834,19 +834,16 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
// faster than direct delivery and requires much less mutex
// acquiring.
var
(
stats
struct
{
queued
,
processed
,
ignored
int
}
stats
=
insertStats
{
startTime
:
time
.
Now
()
}
events
=
make
([]
interface
{},
0
,
len
(
chain
))
coalescedLogs
vm
.
Logs
tstart
=
time
.
Now
()
nonceChecked
=
make
([]
bool
,
len
(
chain
))
nonceChecked
=
make
([]
bool
,
len
(
chain
))
)
// Start the parallel nonce verifier.
nonceAbort
,
nonceResults
:=
verifyNoncesFromBlocks
(
self
.
pow
,
chain
)
defer
close
(
nonceAbort
)
txcount
:=
0
for
i
,
block
:=
range
chain
{
if
atomic
.
LoadInt32
(
&
self
.
procInterrupt
)
==
1
{
glog
.
V
(
logger
.
Debug
)
.
Infoln
(
"Premature abort during block chain processing"
)
...
...
@@ -941,7 +938,6 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
return
i
,
err
}
txcount
+=
len
(
block
.
Transactions
())
// write the block to the chain and get the status
status
,
err
:=
self
.
WriteBlock
(
block
)
if
err
!=
nil
{
...
...
@@ -976,19 +972,54 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
case
SplitStatTy
:
events
=
append
(
events
,
ChainSplitEvent
{
block
,
logs
})
}
stats
.
processed
++
if
glog
.
V
(
logger
.
Info
)
{
stats
.
report
(
chain
,
i
)
}
}
if
(
stats
.
queued
>
0
||
stats
.
processed
>
0
||
stats
.
ignored
>
0
)
&&
bool
(
glog
.
V
(
logger
.
Info
))
{
tend
:=
time
.
Since
(
tstart
)
start
,
end
:=
chain
[
0
],
chain
[
len
(
chain
)
-
1
]
glog
.
Infof
(
"imported %d block(s) (%d queued %d ignored) including %d txs in %v. #%v [%x / %x]
\n
"
,
stats
.
processed
,
stats
.
queued
,
stats
.
ignored
,
txcount
,
tend
,
end
.
Number
(),
start
.
Hash
()
.
Bytes
()[
:
4
],
end
.
Hash
()
.
Bytes
()[
:
4
])
}
go
self
.
postChainEvents
(
events
,
coalescedLogs
)
return
0
,
nil
}
// insertStats tracks and reports on block insertion.
type
insertStats
struct
{
queued
,
processed
,
ignored
int
lastIndex
int
startTime
time
.
Time
}
const
(
statsReportLimit
=
1024
statsReportTimeLimit
=
8
*
time
.
Second
)
// report prints statistics if some number of blocks have been processed
// or more than a few seconds have passed since the last message.
func
(
st
*
insertStats
)
report
(
chain
[]
*
types
.
Block
,
index
int
)
{
limit
:=
statsReportLimit
if
index
==
len
(
chain
)
-
1
{
limit
=
0
// Always print a message for the last block.
}
now
:=
time
.
Now
()
duration
:=
now
.
Sub
(
st
.
startTime
)
if
duration
>
statsReportTimeLimit
||
st
.
queued
>
limit
||
st
.
processed
>
limit
||
st
.
ignored
>
limit
{
start
,
end
:=
chain
[
st
.
lastIndex
],
chain
[
index
]
txcount
:=
countTransactions
(
chain
[
st
.
lastIndex
:
index
])
glog
.
Infof
(
"imported %d block(s) (%d queued %d ignored) including %d txs in %v. #%v [%x / %x]
\n
"
,
st
.
processed
,
st
.
queued
,
st
.
ignored
,
txcount
,
duration
,
end
.
Number
(),
start
.
Hash
()
.
Bytes
()[
:
4
],
end
.
Hash
()
.
Bytes
()[
:
4
])
*
st
=
insertStats
{
startTime
:
now
,
lastIndex
:
index
}
}
}
func
countTransactions
(
chain
[]
*
types
.
Block
)
(
c
int
)
{
for
_
,
b
:=
range
chain
{
c
+=
len
(
b
.
Transactions
())
}
return
c
}
// reorgs takes two blocks, an old chain and a new chain and will reconstruct the blocks and inserts them
// to be part of the new canonical chain and accumulates potential missing transactions and post an
// event about them
...
...
eth/handler.go
View file @
be6a3696
...
...
@@ -288,7 +288,7 @@ func (pm *ProtocolManager) handle(p *peer) error {
}
// Start a timer to disconnect if the peer doesn't reply in time
p
.
forkDrop
=
time
.
AfterFunc
(
daoChallengeTimeout
,
func
()
{
glog
.
V
(
logger
.
Warn
)
.
Infof
(
"%v: timed out DAO fork-check, dropping"
,
p
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"%v: timed out DAO fork-check, dropping"
,
p
)
pm
.
removePeer
(
p
.
id
)
})
// Make sure it's cleaned up if the peer dies off
...
...
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