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
88292f35
Commit
88292f35
authored
Apr 29, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: remove txs from queue in addition to removal of pending
parent
2590a7da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
transaction_pool.go
core/transaction_pool.go
+22
-1
transaction_pool_test.go
core/transaction_pool_test.go
+27
-0
No files found.
core/transaction_pool.go
View file @
88292f35
...
@@ -306,6 +306,27 @@ func (pool *TxPool) checkQueue() {
...
@@ -306,6 +306,27 @@ func (pool *TxPool) checkQueue() {
}
}
}
}
func
(
pool
*
TxPool
)
removeTx
(
hash
common
.
Hash
)
{
// delete from pending pool
delete
(
pool
.
txs
,
hash
)
// delete from queue
out
:
for
address
,
txs
:=
range
pool
.
queue
{
for
i
,
tx
:=
range
txs
{
if
tx
.
Hash
()
==
hash
{
if
len
(
txs
)
==
1
{
// if only one tx, remove entire address entry
delete
(
pool
.
queue
,
address
)
}
else
{
pool
.
queue
[
address
][
len
(
txs
)
-
1
],
pool
.
queue
[
address
]
=
nil
,
append
(
txs
[
:
i
],
txs
[
i
+
1
:
]
...
)
}
break
out
}
}
}
}
func
(
pool
*
TxPool
)
validatePool
()
{
func
(
pool
*
TxPool
)
validatePool
()
{
pool
.
mu
.
Lock
()
pool
.
mu
.
Lock
()
defer
pool
.
mu
.
Unlock
()
defer
pool
.
mu
.
Unlock
()
...
@@ -316,7 +337,7 @@ func (pool *TxPool) validatePool() {
...
@@ -316,7 +337,7 @@ func (pool *TxPool) validatePool() {
glog
.
Infof
(
"removed tx (%x) from pool: %v
\n
"
,
hash
[
:
4
],
err
)
glog
.
Infof
(
"removed tx (%x) from pool: %v
\n
"
,
hash
[
:
4
],
err
)
}
}
delete
(
pool
.
txs
,
hash
)
pool
.
removeTx
(
hash
)
}
}
}
}
}
}
core/transaction_pool_test.go
View file @
88292f35
...
@@ -111,3 +111,30 @@ func TestTransactionQueue(t *testing.T) {
...
@@ -111,3 +111,30 @@ func TestTransactionQueue(t *testing.T) {
t
.
Error
(
"expected transaction queue to be empty. is"
,
len
(
pool
.
queue
[
from
]))
t
.
Error
(
"expected transaction queue to be empty. is"
,
len
(
pool
.
queue
[
from
]))
}
}
}
}
func
TestRemoveTx
(
t
*
testing
.
T
)
{
pool
,
key
:=
setupTxPool
()
tx
:=
transaction
()
tx
.
SignECDSA
(
key
)
from
,
_
:=
tx
.
From
()
pool
.
currentState
()
.
AddBalance
(
from
,
big
.
NewInt
(
1
))
pool
.
queueTx
(
tx
)
pool
.
addTx
(
tx
)
if
len
(
pool
.
queue
)
!=
1
{
t
.
Error
(
"expected queue to be 1, got"
,
len
(
pool
.
queue
))
}
if
len
(
pool
.
txs
)
!=
1
{
t
.
Error
(
"expected txs to be 1, got"
,
len
(
pool
.
txs
))
}
pool
.
removeTx
(
tx
.
Hash
())
if
len
(
pool
.
queue
)
>
0
{
t
.
Error
(
"expected queue to be 0, got"
,
len
(
pool
.
queue
))
}
if
len
(
pool
.
txs
)
>
0
{
t
.
Error
(
"expected txs to be 0, got"
,
len
(
pool
.
txs
))
}
}
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