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
b8b4fb00
Unverified
Commit
b8b4fb00
authored
Mar 26, 2019
by
Péter Szilágyi
Committed by
GitHub
Mar 26, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19308 from holiman/fix_reset_txpool
core: make txpool handle reorg due to setHead
parents
f0340223
650ad19c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
tx_pool.go
core/tx_pool.go
+16
-1
No files found.
core/tx_pool.go
View file @
b8b4fb00
...
...
@@ -387,11 +387,26 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
}
else
{
// Reorg seems shallow enough to pull in all transactions into memory
var
discarded
,
included
types
.
Transactions
var
(
rem
=
pool
.
chain
.
GetBlock
(
oldHead
.
Hash
(),
oldHead
.
Number
.
Uint64
())
add
=
pool
.
chain
.
GetBlock
(
newHead
.
Hash
(),
newHead
.
Number
.
Uint64
())
)
if
rem
==
nil
{
// This can happen if a setHead is performed, where we simply discard the old
// head from the chain.
// If that is the case, we don't have the lost transactions any more, and
// there's nothing to add
if
newNum
<
oldNum
{
// If the reorg ended up on a lower number, it's indicative of setHead being the cause
log
.
Debug
(
"Skipping transaction reset caused by setHead"
,
"old"
,
oldHead
.
Hash
(),
"oldnum"
,
oldNum
,
"new"
,
newHead
.
Hash
(),
"newnum"
,
newNum
)
}
else
{
// If we reorged to a same or higher number, then it's not a case of setHead
log
.
Warn
(
"Transaction pool reset with missing oldhead"
,
"old"
,
oldHead
.
Hash
(),
"oldnum"
,
oldNum
,
"new"
,
newHead
.
Hash
(),
"newnum"
,
newNum
)
}
return
}
for
rem
.
NumberU64
()
>
add
.
NumberU64
()
{
discarded
=
append
(
discarded
,
rem
.
Transactions
()
...
)
if
rem
=
pool
.
chain
.
GetBlock
(
rem
.
ParentHash
(),
rem
.
NumberU64
()
-
1
);
rem
==
nil
{
...
...
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