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
f5737b92
Commit
f5737b92
authored
Feb 23, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a secondary processor
parent
c66cf95b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
transaction_pool.go
ethchain/transaction_pool.go
+9
-3
No files found.
ethchain/transaction_pool.go
View file @
f5737b92
...
...
@@ -34,6 +34,10 @@ type PublicSpeaker interface {
Broadcast
(
msgType
ethwire
.
MsgType
,
data
[]
interface
{})
}
type
TxProcessor
interface
{
ProcessTransaction
(
tx
*
Transaction
)
}
// The tx pool a thread safe transaction pool handler. In order to
// guarantee a non blocking pool we use a queue channel which can be
// independently read without needing access to the actual pool. If the
...
...
@@ -54,7 +58,7 @@ type TxPool struct {
BlockManager
*
BlockManager
Hook
TxPoolHook
SecondaryProcessor
TxProcessor
}
func
NewTxPool
()
*
TxPool
{
...
...
@@ -69,12 +73,14 @@ func NewTxPool() *TxPool {
// Blocking function. Don't use directly. Use QueueTransaction instead
func
(
pool
*
TxPool
)
addTransaction
(
tx
*
Transaction
)
{
log
.
Println
(
"Adding tx to pool"
)
pool
.
mutex
.
Lock
()
pool
.
pool
.
PushBack
(
tx
)
pool
.
mutex
.
Unlock
()
// Broadcast the transaction to the rest of the peers
pool
.
Speaker
.
Broadcast
(
ethwire
.
MsgTxTy
,
[]
interface
{}{
tx
.
RlpData
()})
log
.
Println
(
"broadcasting it"
)
}
// Process transaction validates the Tx and processes funds from the
...
...
@@ -179,8 +185,8 @@ out:
// doesn't matter since this is a goroutine
pool
.
addTransaction
(
tx
)
if
pool
.
Hook
!=
nil
{
pool
.
Hook
<-
tx
if
pool
.
SecondaryProcessor
!=
nil
{
pool
.
SecondaryProcessor
.
ProcessTransaction
(
tx
)
}
}
case
<-
pool
.
quit
:
...
...
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