aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-26 17:19:40 +0800
committerobscuren <geffobscura@gmail.com>2015-04-26 17:19:40 +0800
commit145e02fc5444eb878f67c58e310e7c5e324bb27a (patch)
tree8e0ffc8003c8f3b58cb8cb6edcc2fce2865e59ad /core/chain_manager.go
parent8d09f95bc7a73aaf567b05028ebdb4f2ac5129e4 (diff)
downloadgo-tangerine-145e02fc5444eb878f67c58e310e7c5e324bb27a.tar
go-tangerine-145e02fc5444eb878f67c58e310e7c5e324bb27a.tar.gz
go-tangerine-145e02fc5444eb878f67c58e310e7c5e324bb27a.tar.bz2
go-tangerine-145e02fc5444eb878f67c58e310e7c5e324bb27a.tar.lz
go-tangerine-145e02fc5444eb878f67c58e310e7c5e324bb27a.tar.xz
go-tangerine-145e02fc5444eb878f67c58e310e7c5e324bb27a.tar.zst
go-tangerine-145e02fc5444eb878f67c58e310e7c5e324bb27a.zip
core, miner: added value check on tx validation
* Changed CalcGasLimit to no longer need current block * Added a gas * price + value on tx validation * Transactions in the pool are now re-validated once every X
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r--core/chain_manager.go10
1 files changed, 3 insertions, 7 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index bfe156262..fb2af0280 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -54,11 +54,7 @@ func CalculateTD(block, parent *types.Block) *big.Int {
return td
}
-func CalcGasLimit(parent, block *types.Block) *big.Int {
- if block.Number().Cmp(big.NewInt(0)) == 0 {
- return common.BigPow(10, 6)
- }
-
+func CalcGasLimit(parent *types.Block) *big.Int {
// ((1024-1) * parent.gasLimit + (gasUsed * 6 / 5)) / 1024
previous := new(big.Int).Mul(big.NewInt(1024-1), parent.GasLimit())
current := new(big.Rat).Mul(new(big.Rat).SetInt(parent.GasUsed()), big.NewRat(6, 5))
@@ -277,7 +273,7 @@ func (bc *ChainManager) NewBlock(coinbase common.Address) *types.Block {
header := block.Header()
header.Difficulty = CalcDifficulty(block.Header(), parent.Header())
header.Number = new(big.Int).Add(parent.Header().Number, common.Big1)
- header.GasLimit = CalcGasLimit(parent, block)
+ header.GasLimit = CalcGasLimit(parent)
}
@@ -658,7 +654,7 @@ out:
// We need some control over the mining operation. Acquiring locks and waiting for the miner to create new block takes too long
// and in most cases isn't even necessary.
if i+1 == ev.canonicalCount {
- self.currentGasLimit = CalcGasLimit(self.GetBlock(event.Block.ParentHash()), event.Block)
+ self.currentGasLimit = CalcGasLimit(event.Block)
self.eventMux.Post(ChainHeadEvent{event.Block})
}
case ChainSplitEvent: