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
fc85dd17
Commit
fc85dd17
authored
Jun 02, 2016
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: add missing lock in TxPool.{GetTransaction,RemoveTx}
Fixes #2650
parent
89ba380b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
tx_pool.go
core/tx_pool.go
+10
-1
No files found.
core/tx_pool.go
View file @
fc85dd17
...
@@ -368,6 +368,9 @@ func (self *TxPool) AddTransactions(txs []*types.Transaction) {
...
@@ -368,6 +368,9 @@ func (self *TxPool) AddTransactions(txs []*types.Transaction) {
// GetTransaction returns a transaction if it is contained in the pool
// GetTransaction returns a transaction if it is contained in the pool
// and nil otherwise.
// and nil otherwise.
func
(
tp
*
TxPool
)
GetTransaction
(
hash
common
.
Hash
)
*
types
.
Transaction
{
func
(
tp
*
TxPool
)
GetTransaction
(
hash
common
.
Hash
)
*
types
.
Transaction
{
tp
.
mu
.
RLock
()
defer
tp
.
mu
.
RUnlock
()
// check the txs first
// check the txs first
if
tx
,
ok
:=
tp
.
pending
[
hash
];
ok
{
if
tx
,
ok
:=
tp
.
pending
[
hash
];
ok
{
return
tx
return
tx
...
@@ -421,12 +424,18 @@ func (self *TxPool) RemoveTransactions(txs types.Transactions) {
...
@@ -421,12 +424,18 @@ func (self *TxPool) RemoveTransactions(txs types.Transactions) {
self
.
mu
.
Lock
()
self
.
mu
.
Lock
()
defer
self
.
mu
.
Unlock
()
defer
self
.
mu
.
Unlock
()
for
_
,
tx
:=
range
txs
{
for
_
,
tx
:=
range
txs
{
self
.
R
emoveTx
(
tx
.
Hash
())
self
.
r
emoveTx
(
tx
.
Hash
())
}
}
}
}
// RemoveTx removes the transaction with the given hash from the pool.
// RemoveTx removes the transaction with the given hash from the pool.
func
(
pool
*
TxPool
)
RemoveTx
(
hash
common
.
Hash
)
{
func
(
pool
*
TxPool
)
RemoveTx
(
hash
common
.
Hash
)
{
pool
.
mu
.
Lock
()
defer
pool
.
mu
.
Unlock
()
pool
.
removeTx
(
hash
)
}
func
(
pool
*
TxPool
)
removeTx
(
hash
common
.
Hash
)
{
// delete from pending pool
// delete from pending pool
delete
(
pool
.
pending
,
hash
)
delete
(
pool
.
pending
,
hash
)
// delete from queue
// delete from queue
...
...
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