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
d336e24d
Commit
d336e24d
authored
Jan 02, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed the need of having a backend for the tx pool
parent
ae2c90cc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
17 deletions
+14
-17
chain_manager_test.go
core/chain_manager_test.go
+2
-2
transaction_pool.go
core/transaction_pool.go
+10
-13
transaction_pool_test.go
core/transaction_pool_test.go
+1
-1
backend.go
eth/backend.go
+1
-1
No files found.
core/chain_manager_test.go
View file @
d336e24d
...
@@ -78,7 +78,7 @@ func TestChainInsertions(t *testing.T) {
...
@@ -78,7 +78,7 @@ func TestChainInsertions(t *testing.T) {
var
eventMux
event
.
TypeMux
var
eventMux
event
.
TypeMux
chainMan
:=
NewChainManager
(
&
eventMux
)
chainMan
:=
NewChainManager
(
&
eventMux
)
txPool
:=
NewTxPool
(
chainMan
,
&
eventMux
)
txPool
:=
NewTxPool
(
&
eventMux
)
blockMan
:=
NewBlockManager
(
txPool
,
chainMan
,
&
eventMux
)
blockMan
:=
NewBlockManager
(
txPool
,
chainMan
,
&
eventMux
)
chainMan
.
SetProcessor
(
blockMan
)
chainMan
.
SetProcessor
(
blockMan
)
...
@@ -122,7 +122,7 @@ func TestChainMultipleInsertions(t *testing.T) {
...
@@ -122,7 +122,7 @@ func TestChainMultipleInsertions(t *testing.T) {
}
}
var
eventMux
event
.
TypeMux
var
eventMux
event
.
TypeMux
chainMan
:=
NewChainManager
(
&
eventMux
)
chainMan
:=
NewChainManager
(
&
eventMux
)
txPool
:=
NewTxPool
(
chainMan
,
&
eventMux
)
txPool
:=
NewTxPool
(
&
eventMux
)
blockMan
:=
NewBlockManager
(
txPool
,
chainMan
,
&
eventMux
)
blockMan
:=
NewBlockManager
(
txPool
,
chainMan
,
&
eventMux
)
chainMan
.
SetProcessor
(
blockMan
)
chainMan
.
SetProcessor
(
blockMan
)
done
:=
make
(
chan
bool
,
max
)
done
:=
make
(
chan
bool
,
max
)
...
...
core/transaction_pool.go
View file @
d336e24d
...
@@ -43,22 +43,19 @@ type TxPool struct {
...
@@ -43,22 +43,19 @@ type TxPool struct {
subscribers
[]
chan
TxMsg
subscribers
[]
chan
TxMsg
stateQuery
StateQuery
eventMux
*
event
.
TypeMux
eventMux
*
event
.
TypeMux
}
}
func
NewTxPool
(
stateQuery
StateQuery
,
eventMux
*
event
.
TypeMux
)
*
TxPool
{
func
NewTxPool
(
eventMux
*
event
.
TypeMux
)
*
TxPool
{
return
&
TxPool
{
return
&
TxPool
{
pool
:
set
.
New
(),
pool
:
set
.
New
(),
queueChan
:
make
(
chan
*
types
.
Transaction
,
txPoolQueueSize
),
queueChan
:
make
(
chan
*
types
.
Transaction
,
txPoolQueueSize
),
quit
:
make
(
chan
bool
),
quit
:
make
(
chan
bool
),
stateQuery
:
stateQuery
,
eventMux
:
eventMux
,
eventMux
:
eventMux
,
}
}
}
}
func
(
pool
*
TxPool
)
addTransaction
(
tx
*
types
.
Transaction
)
{
func
(
pool
*
TxPool
)
addTransaction
(
tx
*
types
.
Transaction
)
{
pool
.
pool
.
Add
(
tx
)
pool
.
pool
.
Add
(
tx
)
// Broadcast the transaction to the rest of the peers
// Broadcast the transaction to the rest of the peers
...
@@ -75,6 +72,10 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
...
@@ -75,6 +72,10 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
return
fmt
.
Errorf
(
"tx.v != (28 || 27) => %v"
,
v
)
return
fmt
.
Errorf
(
"tx.v != (28 || 27) => %v"
,
v
)
}
}
/* XXX this kind of validation needs to happen elsewhere in the gui when sending txs.
Other clients should do their own validation. Value transfer could throw error
but doesn't necessarily invalidate the tx. Gas can still be payed for and miner
can still be rewarded for their inclusion and processing.
// Get the sender
// Get the sender
senderAddr := tx.From()
senderAddr := tx.From()
if senderAddr == nil {
if senderAddr == nil {
...
@@ -82,10 +83,6 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
...
@@ -82,10 +83,6 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
}
}
sender := pool.stateQuery.GetAccount(senderAddr)
sender := pool.stateQuery.GetAccount(senderAddr)
/* XXX this kind of validation needs to happen elsewhere in the gui when sending txs.
Other clients should do their own validation. Value transfer could be throw error
but doesn't necessarily invalidate the tx. Gas can still be payed for and miner
can still be rewarded for their inclusion and processing.
totAmount := new(big.Int).Set(tx.Value())
totAmount := new(big.Int).Set(tx.Value())
// Make sure there's enough in the sender's account. Having insufficient
// Make sure there's enough in the sender's account. Having insufficient
// funds won't invalidate this transaction but simple ignores it.
// funds won't invalidate this transaction but simple ignores it.
...
...
core/transaction_pool_test.go
View file @
d336e24d
...
@@ -25,7 +25,7 @@ func transaction() *types.Transaction {
...
@@ -25,7 +25,7 @@ func transaction() *types.Transaction {
func
setup
()
(
*
TxPool
,
*
ecdsa
.
PrivateKey
)
{
func
setup
()
(
*
TxPool
,
*
ecdsa
.
PrivateKey
)
{
var
m
event
.
TypeMux
var
m
event
.
TypeMux
key
,
_
:=
crypto
.
GenerateKey
()
key
,
_
:=
crypto
.
GenerateKey
()
return
NewTxPool
(
stateQuery
{},
&
m
),
key
return
NewTxPool
(
&
m
),
key
}
}
func
TestTxAdding
(
t
*
testing
.
T
)
{
func
TestTxAdding
(
t
*
testing
.
T
)
{
...
...
eth/backend.go
View file @
d336e24d
...
@@ -70,7 +70,7 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
...
@@ -70,7 +70,7 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
}
}
eth
.
chainManager
=
core
.
NewChainManager
(
eth
.
EventMux
())
eth
.
chainManager
=
core
.
NewChainManager
(
eth
.
EventMux
())
eth
.
txPool
=
core
.
NewTxPool
(
eth
.
chainManager
,
eth
.
EventMux
())
eth
.
txPool
=
core
.
NewTxPool
(
eth
.
EventMux
())
eth
.
blockManager
=
core
.
NewBlockManager
(
eth
.
txPool
,
eth
.
chainManager
,
eth
.
EventMux
())
eth
.
blockManager
=
core
.
NewBlockManager
(
eth
.
txPool
,
eth
.
chainManager
,
eth
.
EventMux
())
eth
.
chainManager
.
SetProcessor
(
eth
.
blockManager
)
eth
.
chainManager
.
SetProcessor
(
eth
.
blockManager
)
eth
.
whisper
=
whisper
.
New
()
eth
.
whisper
=
whisper
.
New
()
...
...
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