aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-24 23:45:51 +0800
committerobscuren <geffobscura@gmail.com>2015-04-24 23:48:13 +0800
commit405720b218c74ec730541cdcb360db54deb75474 (patch)
treeb403e8c1e35884aac71bd51cff8489e4305adba8 /core/chain_manager.go
parent3bb6da9bd3111c8083cdefde1aa93a7ac55d19d2 (diff)
downloadgo-tangerine-405720b218c74ec730541cdcb360db54deb75474.tar.gz
go-tangerine-405720b218c74ec730541cdcb360db54deb75474.tar.zst
go-tangerine-405720b218c74ec730541cdcb360db54deb75474.zip
xeth, core, cmd/utils: Transaction can not be over block gas limit
Transactions will be invalidated when the tx.gas_limit > block.gas_limit
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r--core/chain_manager.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index a09b2e63b..bfe156262 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -78,11 +78,12 @@ type ChainManager struct {
eventMux *event.TypeMux
genesisBlock *types.Block
// Last known total difficulty
- mu sync.RWMutex
- tsmu sync.RWMutex
- td *big.Int
- currentBlock *types.Block
- lastBlockHash common.Hash
+ mu sync.RWMutex
+ tsmu sync.RWMutex
+ td *big.Int
+ currentBlock *types.Block
+ lastBlockHash common.Hash
+ currentGasLimit *big.Int
transState *state.StateDB
txState *state.ManagedState
@@ -95,12 +96,13 @@ type ChainManager struct {
func NewChainManager(blockDb, stateDb common.Database, mux *event.TypeMux) *ChainManager {
bc := &ChainManager{
- blockDb: blockDb,
- stateDb: stateDb,
- genesisBlock: GenesisBlock(stateDb),
- eventMux: mux,
- quit: make(chan struct{}),
- cache: NewBlockCache(blockCacheLimit),
+ blockDb: blockDb,
+ stateDb: stateDb,
+ genesisBlock: GenesisBlock(stateDb),
+ eventMux: mux,
+ quit: make(chan struct{}),
+ cache: NewBlockCache(blockCacheLimit),
+ currentGasLimit: new(big.Int),
}
bc.setLastBlock()
@@ -157,6 +159,10 @@ func (self *ChainManager) Td() *big.Int {
return self.td
}
+func (self *ChainManager) GasLimit() *big.Int {
+ return self.currentGasLimit
+}
+
func (self *ChainManager) LastBlockHash() common.Hash {
self.mu.RLock()
defer self.mu.RUnlock()
@@ -652,6 +658,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.eventMux.Post(ChainHeadEvent{event.Block})
}
case ChainSplitEvent: