Skip mining on transactions that don't meet the min accepted gas price
This commit is contained in:
parent
3db9c80070
commit
8dbca75d85
@ -231,7 +231,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.I
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = sm.TransitionState(state, parent, block)
|
receipts, err := sm.TransitionState(state, parent, block)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -242,26 +242,22 @@ func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.I
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
receiptSha := types.DeriveSha(receipts)
|
receiptSha := types.DeriveSha(receipts)
|
||||||
if bytes.Compare(receiptSha, block.ReceiptSha) != 0 {
|
if bytes.Compare(receiptSha, block.ReceiptSha) != 0 {
|
||||||
err = fmt.Errorf("validating receipt root. received=%x got=%x", block.ReceiptSha, receiptSha)
|
err = fmt.Errorf("validating receipt root. received=%x got=%x", block.ReceiptSha, receiptSha)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
if err = sm.AccumelateRewards(state, block, parent); err != nil {
|
if err = sm.AccumelateRewards(state, block, parent); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
//block.receipts = receipts // although this isn't necessary it be in the future
|
//block.receipts = receipts // although this isn't necessary it be in the future
|
||||||
rbloom := types.CreateBloom(receipts)
|
rbloom := types.CreateBloom(receipts)
|
||||||
if bytes.Compare(rbloom, block.LogsBloom) != 0 {
|
if bytes.Compare(rbloom, block.LogsBloom) != 0 {
|
||||||
err = fmt.Errorf("unable to replicate block's bloom=%x", rbloom)
|
err = fmt.Errorf("unable to replicate block's bloom=%x", rbloom)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
state.Update(ethutil.Big0)
|
state.Update(ethutil.Big0)
|
||||||
|
|
||||||
|
@ -115,10 +115,6 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
|
|||||||
return fmt.Errorf("tx.v != (28 || 27)")
|
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
|
// Get the sender
|
||||||
sender := pool.Ethereum.BlockManager().CurrentState().GetAccount(tx.Sender())
|
sender := pool.Ethereum.BlockManager().CurrentState().GetAccount(tx.Sender())
|
||||||
|
|
||||||
@ -169,6 +165,10 @@ func (self *TxPool) Add(tx *types.Transaction) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *TxPool) Size() int {
|
||||||
|
return self.pool.Len()
|
||||||
|
}
|
||||||
|
|
||||||
func (pool *TxPool) CurrentTransactions() []*types.Transaction {
|
func (pool *TxPool) CurrentTransactions() []*types.Transaction {
|
||||||
pool.mutex.Lock()
|
pool.mutex.Lock()
|
||||||
defer pool.mutex.Unlock()
|
defer pool.mutex.Unlock()
|
||||||
|
@ -228,23 +228,33 @@ func (self *Miner) mine() {
|
|||||||
|
|
||||||
func (self *Miner) finiliseTxs() types.Transactions {
|
func (self *Miner) finiliseTxs() types.Transactions {
|
||||||
// Sort the transactions by nonce in case of odd network propagation
|
// 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()
|
state := self.eth.BlockManager().TransState()
|
||||||
// XXX This has to change. Coinbase is, for new, same as key.
|
// XXX This has to change. Coinbase is, for new, same as key.
|
||||||
key := self.eth.KeyManager()
|
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 := types.NewTransactionMessage(ltx.To, ethutil.Big(ltx.Value), ethutil.Big(ltx.Gas), ethutil.Big(ltx.GasPrice), ltx.Data)
|
||||||
tx.Nonce = state.GetNonce(self.Coinbase)
|
tx.Nonce = state.GetNonce(self.Coinbase)
|
||||||
state.SetNonce(self.Coinbase, tx.Nonce+1)
|
state.SetNonce(self.Coinbase, tx.Nonce+1)
|
||||||
|
|
||||||
tx.Sign(key.PrivateKey())
|
tx.Sign(key.PrivateKey())
|
||||||
|
|
||||||
txs = append(txs, tx)
|
txs[i] = tx
|
||||||
}
|
}
|
||||||
|
|
||||||
txs = append(txs, self.eth.TxPool().CurrentTransactions()...)
|
// Faster than append
|
||||||
sort.Sort(types.TxByNonce{txs})
|
for _, tx := range self.eth.TxPool().CurrentTransactions() {
|
||||||
|
if tx.GasPrice.Cmp(self.MinAcceptedGasPrice) >= 0 {
|
||||||
|
txs[actualSize] = tx
|
||||||
|
actualSize++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return txs
|
newTransactions := make(types.Transactions, actualSize)
|
||||||
|
copy(newTransactions, txs[:actualSize])
|
||||||
|
sort.Sort(types.TxByNonce{newTransactions})
|
||||||
|
|
||||||
|
return newTransactions
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user