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
88b4fe7d
Unverified
Commit
88b4fe7d
authored
Jul 05, 2017
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: handle nolocals during add, exepmt locals from expiration
parent
5e38f7a6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
tx_pool.go
core/tx_pool.go
+9
-4
No files found.
core/tx_pool.go
View file @
88b4fe7d
...
@@ -396,7 +396,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
...
@@ -396,7 +396,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
}
}
// Drop non-local transactions under our own minimal accepted gas price
// Drop non-local transactions under our own minimal accepted gas price
local
=
local
||
pool
.
locals
.
contains
(
from
)
// account may be local even if the transaction arrived from the network
local
=
local
||
pool
.
locals
.
contains
(
from
)
// account may be local even if the transaction arrived from the network
if
(
!
local
||
pool
.
config
.
NoLocals
)
&&
pool
.
gasPrice
.
Cmp
(
tx
.
GasPrice
())
>
0
{
if
!
local
&&
pool
.
gasPrice
.
Cmp
(
tx
.
GasPrice
())
>
0
{
return
ErrUnderpriced
return
ErrUnderpriced
}
}
// Ensure the transaction adheres to nonce ordering
// Ensure the transaction adheres to nonce ordering
...
@@ -482,7 +482,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (bool, error) {
...
@@ -482,7 +482,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (bool, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
if
local
&&
!
pool
.
config
.
NoLocals
{
if
local
{
pool
.
locals
.
add
(
from
)
pool
.
locals
.
add
(
from
)
}
}
log
.
Trace
(
"Pooled new future transaction"
,
"hash"
,
hash
,
"from"
,
from
,
"to"
,
tx
.
To
())
log
.
Trace
(
"Pooled new future transaction"
,
"hash"
,
hash
,
"from"
,
from
,
"to"
,
tx
.
To
())
...
@@ -556,7 +556,7 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
...
@@ -556,7 +556,7 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
// the sender as a local one in the mean time, ensuring it goes around the local
// the sender as a local one in the mean time, ensuring it goes around the local
// pricing constraints.
// pricing constraints.
func
(
pool
*
TxPool
)
AddLocal
(
tx
*
types
.
Transaction
)
error
{
func
(
pool
*
TxPool
)
AddLocal
(
tx
*
types
.
Transaction
)
error
{
return
pool
.
addTx
(
tx
,
true
)
return
pool
.
addTx
(
tx
,
!
pool
.
config
.
NoLocals
)
}
}
// AddRemote enqueues a single transaction into the pool if it is valid. If the
// AddRemote enqueues a single transaction into the pool if it is valid. If the
...
@@ -570,7 +570,7 @@ func (pool *TxPool) AddRemote(tx *types.Transaction) error {
...
@@ -570,7 +570,7 @@ func (pool *TxPool) AddRemote(tx *types.Transaction) error {
// marking the senders as a local ones in the mean time, ensuring they go around
// marking the senders as a local ones in the mean time, ensuring they go around
// the local pricing constraints.
// the local pricing constraints.
func
(
pool
*
TxPool
)
AddLocals
(
txs
[]
*
types
.
Transaction
)
error
{
func
(
pool
*
TxPool
)
AddLocals
(
txs
[]
*
types
.
Transaction
)
error
{
return
pool
.
addTxs
(
txs
,
true
)
return
pool
.
addTxs
(
txs
,
!
pool
.
config
.
NoLocals
)
}
}
// AddRemotes enqueues a batch of transactions into the pool if they are valid.
// AddRemotes enqueues a batch of transactions into the pool if they are valid.
...
@@ -924,6 +924,11 @@ func (pool *TxPool) expirationLoop() {
...
@@ -924,6 +924,11 @@ func (pool *TxPool) expirationLoop() {
case
<-
evict
.
C
:
case
<-
evict
.
C
:
pool
.
mu
.
Lock
()
pool
.
mu
.
Lock
()
for
addr
:=
range
pool
.
queue
{
for
addr
:=
range
pool
.
queue
{
// Skip local transactions from the eviction mechanism
if
pool
.
locals
.
contains
(
addr
)
{
continue
}
// Any non-locals old enough should be removed
if
time
.
Since
(
pool
.
beats
[
addr
])
>
pool
.
config
.
Lifetime
{
if
time
.
Since
(
pool
.
beats
[
addr
])
>
pool
.
config
.
Lifetime
{
for
_
,
tx
:=
range
pool
.
queue
[
addr
]
.
Flatten
()
{
for
_
,
tx
:=
range
pool
.
queue
[
addr
]
.
Flatten
()
{
pool
.
removeTx
(
tx
.
Hash
())
pool
.
removeTx
(
tx
.
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