From 8dbca75d85553f2d9451ee563a919850f05ea1dd Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 4 Dec 2014 23:54:07 +0100 Subject: Skip mining on transactions that don't meet the min accepted gas price --- core/block_manager.go | 28 ++++++++++++---------------- core/transaction_pool.go | 8 ++++---- 2 files changed, 16 insertions(+), 20 deletions(-) (limited to 'core') diff --git a/core/block_manager.go b/core/block_manager.go index b648166ec..909f26a1b 100644 --- a/core/block_manager.go +++ b/core/block_manager.go @@ -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) diff --git a/core/transaction_pool.go b/core/transaction_pool.go index c48d3d8a4..1d1f478e4 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -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() -- cgit v1.2.3