good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
69e745c5
Commit
69e745c5
authored
10 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Return erroneous txs (so we can remove them from the pool)
parent
00328088
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ethchain/state_manager.go
+9
-6
9 additions, 6 deletions
ethchain/state_manager.go
ethchain/transaction.go
+1
-1
1 addition, 1 deletion
ethchain/transaction.go
ethchain/transaction_pool.go
+26
-0
26 additions, 0 deletions
ethchain/transaction_pool.go
with
36 additions
and
7 deletions
ethchain/state_manager.go
+
9
−
6
View file @
69e745c5
...
...
@@ -17,7 +17,7 @@ import (
"github.com/ethereum/go-ethereum/event"
)
var
statelogger
=
ethlog
.
NewLogger
(
"
STATE
"
)
var
statelogger
=
ethlog
.
NewLogger
(
"
BLOCK
"
)
type
Peer
interface
{
Inbound
()
bool
...
...
@@ -134,10 +134,11 @@ func (sm *StateManager) ChainManager() *ChainManager {
return
sm
.
bc
}
func
(
self
*
StateManager
)
ProcessTransactions
(
coinbase
*
ethstate
.
StateObject
,
state
*
ethstate
.
State
,
block
,
parent
*
Block
,
txs
Transactions
)
(
Receipts
,
Transactions
,
Transactions
,
error
)
{
func
(
self
*
StateManager
)
ProcessTransactions
(
coinbase
*
ethstate
.
StateObject
,
state
*
ethstate
.
State
,
block
,
parent
*
Block
,
txs
Transactions
)
(
Receipts
,
Transactions
,
Transactions
,
Transactions
,
error
)
{
var
(
receipts
Receipts
handled
,
unhandled
Transactions
erroneous
Transactions
totalUsedGas
=
big
.
NewInt
(
0
)
err
error
)
...
...
@@ -161,7 +162,9 @@ done:
break
done
default
:
statelogger
.
Infoln
(
err
)
erroneous
=
append
(
erroneous
,
tx
)
err
=
nil
continue
//return nil, nil, nil, err
}
}
...
...
@@ -182,7 +185,7 @@ done:
err
:=
fmt
.
Errorf
(
"#%d receipt failed (r) %v ~ %x <=> (c) %v ~ %x (%x...)"
,
i
+
1
,
original
.
CumulativeGasUsed
,
original
.
PostState
[
0
:
4
],
receipt
.
CumulativeGasUsed
,
receipt
.
PostState
[
0
:
4
],
receipt
.
Tx
.
Hash
()[
0
:
4
])
return
nil
,
nil
,
nil
,
err
return
nil
,
nil
,
nil
,
nil
,
err
}
}
...
...
@@ -199,7 +202,7 @@ done:
parent
.
GasUsed
=
totalUsedGas
return
receipts
,
handled
,
unhandled
,
err
return
receipts
,
handled
,
unhandled
,
err
oneous
,
err
}
func
(
sm
*
StateManager
)
Process
(
block
*
Block
,
dontReact
bool
)
(
err
error
)
{
...
...
@@ -283,7 +286,7 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
state
.
Manifest
()
.
Reset
()
}
sm
.
eth
.
TxPool
()
.
Remove
Invalid
(
state
)
sm
.
eth
.
TxPool
()
.
Remove
Set
(
block
.
Transactions
()
)
}
else
{
statelogger
.
Errorln
(
"total diff failed"
)
}
...
...
@@ -296,7 +299,7 @@ func (sm *StateManager) ApplyDiff(state *ethstate.State, parent, block *Block) (
coinbase
.
SetGasPool
(
block
.
CalcGasLimit
(
parent
))
// Process the transactions on to current block
receipts
,
_
,
_
,
err
=
sm
.
ProcessTransactions
(
coinbase
,
state
,
block
,
parent
,
block
.
Transactions
())
receipts
,
_
,
_
,
_
,
err
=
sm
.
ProcessTransactions
(
coinbase
,
state
,
block
,
parent
,
block
.
Transactions
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
ethchain/transaction.go
+
1
−
1
View file @
69e745c5
...
...
@@ -40,7 +40,7 @@ func NewContractCreationTx(value, gas, gasPrice *big.Int, script []byte) *Transa
}
func
NewTransactionMessage
(
to
[]
byte
,
value
,
gas
,
gasPrice
*
big
.
Int
,
data
[]
byte
)
*
Transaction
{
return
&
Transaction
{
Recipient
:
to
,
Value
:
value
,
GasPrice
:
gasPrice
,
Gas
:
gas
,
Data
:
data
}
return
&
Transaction
{
Recipient
:
to
,
Value
:
value
,
GasPrice
:
gasPrice
,
Gas
:
gas
,
Data
:
data
,
contractCreation
:
IsContractAddr
(
to
)
}
}
func
NewTransactionFromBytes
(
data
[]
byte
)
*
Transaction
{
...
...
This diff is collapsed.
Click to expand it.
ethchain/transaction_pool.go
+
26
−
0
View file @
69e745c5
...
...
@@ -35,6 +35,14 @@ type TxMsg struct {
Type
TxMsgTy
}
func
EachTx
(
pool
*
list
.
List
,
it
func
(
*
Transaction
,
*
list
.
Element
)
bool
)
{
for
e
:=
pool
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
if
it
(
e
.
Value
.
(
*
Transaction
),
e
)
{
break
}
}
}
func
FindTx
(
pool
*
list
.
List
,
finder
func
(
*
Transaction
,
*
list
.
Element
)
bool
)
*
Transaction
{
for
e
:=
pool
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
if
tx
,
ok
:=
e
.
Value
.
(
*
Transaction
);
ok
{
...
...
@@ -191,6 +199,9 @@ func (pool *TxPool) CurrentTransactions() []*Transaction {
}
func
(
pool
*
TxPool
)
RemoveInvalid
(
state
*
ethstate
.
State
)
{
pool
.
mutex
.
Lock
()
defer
pool
.
mutex
.
Unlock
()
for
e
:=
pool
.
pool
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
tx
:=
e
.
Value
.
(
*
Transaction
)
sender
:=
state
.
GetAccount
(
tx
.
Sender
())
...
...
@@ -201,6 +212,21 @@ func (pool *TxPool) RemoveInvalid(state *ethstate.State) {
}
}
func
(
self
*
TxPool
)
RemoveSet
(
txs
Transactions
)
{
self
.
mutex
.
Lock
()
defer
self
.
mutex
.
Unlock
()
for
_
,
tx
:=
range
txs
{
EachTx
(
self
.
pool
,
func
(
t
*
Transaction
,
element
*
list
.
Element
)
bool
{
if
t
==
tx
{
self
.
pool
.
Remove
(
element
)
return
true
// To stop the loop
}
return
false
})
}
}
func
(
pool
*
TxPool
)
Flush
()
[]
*
Transaction
{
txList
:=
pool
.
CurrentTransactions
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment