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
7f14fbd5
Commit
7f14fbd5
authored
Apr 23, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: pending txs now re-validated once every second
parent
48135657
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
transaction_pool.go
core/transaction_pool.go
+27
-3
No files found.
core/transaction_pool.go
View file @
7f14fbd5
...
...
@@ -77,12 +77,18 @@ func NewTxPool(eventMux *event.TypeMux, currentStateFn stateFn) *TxPool {
}
func
(
pool
*
TxPool
)
Start
()
{
ticker
:=
time
.
NewTicker
(
300
*
time
.
Millisecond
)
// Queue timer will tick so we can attempt to move items from the queue to the
// main transaction pool.
queueTimer
:=
time
.
NewTicker
(
300
*
time
.
Millisecond
)
// Removal timer will tick and attempt to remove bad transactions (account.nonce>tx.nonce)
removalTimer
:=
time
.
NewTicker
(
1
*
time
.
Second
)
done
:
for
{
select
{
case
<-
tick
er
.
C
:
case
<-
queueTim
er
.
C
:
pool
.
checkQueue
()
case
<-
removalTimer
.
C
:
pool
.
validatePool
()
case
<-
pool
.
quit
:
break
done
}
...
...
@@ -253,11 +259,12 @@ func (pool *TxPool) checkQueue() {
pool
.
mu
.
Lock
()
defer
pool
.
mu
.
Unlock
()
statedb
:=
pool
.
currentState
()
for
address
,
txs
:=
range
pool
.
queue
{
sort
.
Sort
(
types
.
TxByNonce
{
txs
})
var
(
nonce
=
pool
.
currentState
()
.
GetNonce
(
address
)
nonce
=
statedb
.
GetNonce
(
address
)
start
int
)
// Clean up the transactions first and determine the start of the nonces
...
...
@@ -288,3 +295,20 @@ func (pool *TxPool) checkQueue() {
}
}
}
func
(
pool
*
TxPool
)
validatePool
()
{
pool
.
mu
.
Lock
()
defer
pool
.
mu
.
Unlock
()
statedb
:=
pool
.
currentState
()
for
hash
,
tx
:=
range
pool
.
txs
{
from
,
_
:=
tx
.
From
()
if
nonce
:=
statedb
.
GetNonce
(
from
);
nonce
>
tx
.
Nonce
()
{
if
glog
.
V
(
logger
.
Debug
)
{
glog
.
Infof
(
"removed tx (%x) from pool due to nonce error. state=%d tx=%d
\n
"
,
hash
[
:
4
],
nonce
,
tx
.
Nonce
())
}
delete
(
pool
.
txs
,
hash
)
}
}
}
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