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
8dbca75d
Commit
8dbca75d
authored
10 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Skip mining on transactions that don't meet the min accepted gas price
parent
3db9c800
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/block_manager.go
+12
-16
12 additions, 16 deletions
core/block_manager.go
core/transaction_pool.go
+4
-4
4 additions, 4 deletions
core/transaction_pool.go
miner/miner.go
+16
-6
16 additions, 6 deletions
miner/miner.go
with
32 additions
and
26 deletions
core/block_manager.go
+
12
−
16
View file @
8dbca75d
...
...
@@ -231,7 +231,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.I
return
}
_
,
err
=
sm
.
TransitionState
(
state
,
parent
,
block
)
receipts
,
err
:
=
sm
.
TransitionState
(
state
,
parent
,
block
)
if
err
!=
nil
{
return
}
...
...
@@ -242,26 +242,22 @@ func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.I
return
}
/*
receiptSha := types.DeriveSha(receipts)
if bytes.Compare(receiptSha, block.ReceiptSha) != 0 {
err = fmt.Errorf("validating receipt root. received=%x got=%x", block.ReceiptSha, receiptSha)
return
}
*/
receiptSha
:=
types
.
DeriveSha
(
receipts
)
if
bytes
.
Compare
(
receiptSha
,
block
.
ReceiptSha
)
!=
0
{
err
=
fmt
.
Errorf
(
"validating receipt root. received=%x got=%x"
,
block
.
ReceiptSha
,
receiptSha
)
return
}
if
err
=
sm
.
AccumelateRewards
(
state
,
block
,
parent
);
err
!=
nil
{
return
}
/*
//block.receipts = receipts // although this isn't necessary it be in the future
rbloom := types.CreateBloom(receipts)
if bytes.Compare(rbloom, block.LogsBloom) != 0 {
err = fmt.Errorf("unable to replicate block's bloom=%x", rbloom)
return
}
*/
//block.receipts = receipts // although this isn't necessary it be in the future
rbloom
:=
types
.
CreateBloom
(
receipts
)
if
bytes
.
Compare
(
rbloom
,
block
.
LogsBloom
)
!=
0
{
err
=
fmt
.
Errorf
(
"unable to replicate block's bloom=%x"
,
rbloom
)
return
}
state
.
Update
(
ethutil
.
Big0
)
...
...
This diff is collapsed.
Click to expand it.
core/transaction_pool.go
+
4
−
4
View file @
8dbca75d
...
...
@@ -115,10 +115,6 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
return
fmt
.
Errorf
(
"tx.v != (28 || 27)"
)
}
if
tx
.
GasPrice
.
Cmp
(
MinGasPrice
)
<
0
{
return
fmt
.
Errorf
(
"Gas price to low. Require %v > Got %v"
,
MinGasPrice
,
tx
.
GasPrice
)
}
// Get the sender
sender
:=
pool
.
Ethereum
.
BlockManager
()
.
CurrentState
()
.
GetAccount
(
tx
.
Sender
())
...
...
@@ -169,6 +165,10 @@ func (self *TxPool) Add(tx *types.Transaction) error {
return
nil
}
func
(
self
*
TxPool
)
Size
()
int
{
return
self
.
pool
.
Len
()
}
func
(
pool
*
TxPool
)
CurrentTransactions
()
[]
*
types
.
Transaction
{
pool
.
mutex
.
Lock
()
defer
pool
.
mutex
.
Unlock
()
...
...
This diff is collapsed.
Click to expand it.
miner/miner.go
+
16
−
6
View file @
8dbca75d
...
...
@@ -228,23 +228,33 @@ func (self *Miner) mine() {
func
(
self
*
Miner
)
finiliseTxs
()
types
.
Transactions
{
// Sort the transactions by nonce in case of odd network propagation
var
txs
types
.
Transactions
actualSize
:=
len
(
self
.
localTxs
)
// See copy below
txs
:=
make
(
types
.
Transactions
,
actualSize
+
self
.
eth
.
TxPool
()
.
Size
())
state
:=
self
.
eth
.
BlockManager
()
.
TransState
()
// XXX This has to change. Coinbase is, for new, same as key.
key
:=
self
.
eth
.
KeyManager
()
for
_
,
ltx
:=
range
self
.
localTxs
{
for
i
,
ltx
:=
range
self
.
localTxs
{
tx
:=
types
.
NewTransactionMessage
(
ltx
.
To
,
ethutil
.
Big
(
ltx
.
Value
),
ethutil
.
Big
(
ltx
.
Gas
),
ethutil
.
Big
(
ltx
.
GasPrice
),
ltx
.
Data
)
tx
.
Nonce
=
state
.
GetNonce
(
self
.
Coinbase
)
state
.
SetNonce
(
self
.
Coinbase
,
tx
.
Nonce
+
1
)
tx
.
Sign
(
key
.
PrivateKey
())
txs
=
append
(
txs
,
tx
)
txs
[
i
]
=
tx
}
txs
=
append
(
txs
,
self
.
eth
.
TxPool
()
.
CurrentTransactions
()
...
)
sort
.
Sort
(
types
.
TxByNonce
{
txs
})
// Faster than append
for
_
,
tx
:=
range
self
.
eth
.
TxPool
()
.
CurrentTransactions
()
{
if
tx
.
GasPrice
.
Cmp
(
self
.
MinAcceptedGasPrice
)
>=
0
{
txs
[
actualSize
]
=
tx
actualSize
++
}
}
newTransactions
:=
make
(
types
.
Transactions
,
actualSize
)
copy
(
newTransactions
,
txs
[
:
actualSize
])
sort
.
Sort
(
types
.
TxByNonce
{
newTransactions
})
return
tx
s
return
newTransaction
s
}
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