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
9988b1a0
Commit
9988b1a0
authored
May 28, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sort transactions based on the nonce
* Added a transaction sorter
parent
73761f7a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
17 deletions
+16
-17
transaction.go
ethchain/transaction.go
+12
-16
miner.go
ethminer/miner.go
+4
-1
No files found.
ethchain/transaction.go
View file @
9988b1a0
...
@@ -147,22 +147,6 @@ func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) {
...
@@ -147,22 +147,6 @@ func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) {
if
len
(
tx
.
Recipient
)
==
0
{
if
len
(
tx
.
Recipient
)
==
0
{
tx
.
contractCreation
=
true
tx
.
contractCreation
=
true
}
}
/*
// If the list is of length 10 it's a contract creation tx
if decoder.Len() == 10 {
tx.contractCreation = true
tx.Init = decoder.Get(6).Bytes()
tx.v = byte(decoder.Get(7).Uint())
tx.r = decoder.Get(8).Bytes()
tx.s = decoder.Get(9).Bytes()
} else {
tx.v = byte(decoder.Get(6).Uint())
tx.r = decoder.Get(7).Bytes()
tx.s = decoder.Get(8).Bytes()
}
*/
}
}
func
(
tx
*
Transaction
)
String
()
string
{
func
(
tx
*
Transaction
)
String
()
string
{
...
@@ -228,3 +212,15 @@ func (self *Receipt) String() string {
...
@@ -228,3 +212,15 @@ func (self *Receipt) String() string {
self
.
PostState
,
self
.
PostState
,
self
.
CumulativeGasUsed
)
self
.
CumulativeGasUsed
)
}
}
// Transaction slice type for basic sorting
type
Transactions
[]
*
Transaction
func
(
s
Transactions
)
Len
()
int
{
return
len
(
s
)
}
func
(
s
Transactions
)
Swap
(
i
,
j
int
)
{
s
[
i
],
s
[
j
]
=
s
[
j
],
s
[
i
]
}
type
TxByNonce
struct
{
Transactions
}
func
(
s
TxByNonce
)
Less
(
i
,
j
int
)
bool
{
return
s
.
Transactions
[
i
]
.
Nonce
<
s
.
Transactions
[
j
]
.
Nonce
}
ethminer/miner.go
View file @
9988b1a0
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/eth-go/ethwire"
"sort"
)
)
type
Miner
struct
{
type
Miner
struct
{
...
@@ -12,7 +13,7 @@ type Miner struct {
...
@@ -12,7 +13,7 @@ type Miner struct {
ethereum
ethchain
.
EthManager
ethereum
ethchain
.
EthManager
coinbase
[]
byte
coinbase
[]
byte
reactChan
chan
ethutil
.
React
reactChan
chan
ethutil
.
React
txs
[]
*
ethchain
.
Transaction
txs
ethchain
.
Transactions
uncles
[]
*
ethchain
.
Block
uncles
[]
*
ethchain
.
Block
block
*
ethchain
.
Block
block
*
ethchain
.
Block
powChan
chan
[]
byte
powChan
chan
[]
byte
...
@@ -132,6 +133,8 @@ func (self *Miner) mineNewBlock() {
...
@@ -132,6 +133,8 @@ func (self *Miner) mineNewBlock() {
self
.
block
.
SetUncles
(
self
.
uncles
)
self
.
block
.
SetUncles
(
self
.
uncles
)
}
}
// Sort the transactions by nonce in case of odd network propagation
sort
.
Sort
(
ethchain
.
TxByNonce
{
self
.
txs
})
// Accumulate all valid transaction and apply them to the new state
// Accumulate all valid transaction and apply them to the new state
receipts
,
txs
:=
stateManager
.
ApplyTransactions
(
self
.
block
.
State
(),
self
.
block
,
self
.
txs
)
receipts
,
txs
:=
stateManager
.
ApplyTransactions
(
self
.
block
.
State
(),
self
.
block
,
self
.
txs
)
self
.
txs
=
txs
self
.
txs
=
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