Fixed minor issue with the gas pool

This commit is contained in:
obscuren 2014-06-16 11:51:16 +02:00
parent 9f62d441a7
commit 48bca30e61
4 changed files with 13 additions and 9 deletions

View File

@ -178,7 +178,7 @@ func (sm *StateManager) ProcessBlock(state *State, parent, block *Block, dontRea
fmt.Println(block.Receipts()) fmt.Println(block.Receipts())
coinbase := state.GetOrNewStateObject(block.Coinbase) coinbase := state.GetOrNewStateObject(block.Coinbase)
coinbase.gasPool = block.CalcGasLimit(parent) coinbase.SetGasPool(block.CalcGasLimit(parent))
// Process the transactions on to current block // Process the transactions on to current block
//sm.ApplyTransactions(block.Coinbase, state, parent, block.Transactions()) //sm.ApplyTransactions(block.Coinbase, state, parent, block.Transactions())

View File

@ -120,13 +120,13 @@ func (c *StateObject) ReturnGas(gas, price *big.Int, state *State) {
func (c *StateObject) AddAmount(amount *big.Int) { func (c *StateObject) AddAmount(amount *big.Int) {
c.SetAmount(new(big.Int).Add(c.Amount, amount)) c.SetAmount(new(big.Int).Add(c.Amount, amount))
ethutil.Config.Log.Debugf("%x: #%d %v (+ %v)", c.Address(), c.Nonce, c.Amount, amount) ethutil.Config.Log.Printf(ethutil.LogLevelSystem, "%x: #%d %v (+ %v)\n", c.Address(), c.Nonce, c.Amount, amount)
} }
func (c *StateObject) SubAmount(amount *big.Int) { func (c *StateObject) SubAmount(amount *big.Int) {
c.SetAmount(new(big.Int).Sub(c.Amount, amount)) c.SetAmount(new(big.Int).Sub(c.Amount, amount))
ethutil.Config.Log.Debugf("%x: #%d %v (- %v)", c.Address(), c.Nonce, c.Amount, amount) ethutil.Config.Log.Printf(ethutil.LogLevelSystem, "%x: #%d %v (- %v)\n", c.Address(), c.Nonce, c.Amount, amount)
} }
func (c *StateObject) SetAmount(amount *big.Int) { func (c *StateObject) SetAmount(amount *big.Int) {

View File

@ -113,12 +113,14 @@ func (self *StateTransition) BuyGas() error {
func (self *StateTransition) TransitionState() (err error) { func (self *StateTransition) TransitionState() (err error) {
//snapshot := st.state.Snapshot() //snapshot := st.state.Snapshot()
defer func() { /*
if r := recover(); r != nil { defer func() {
ethutil.Config.Log.Infoln(r) if r := recover(); r != nil {
err = fmt.Errorf("state transition err %v", r) ethutil.Config.Log.Infoln(r)
} err = fmt.Errorf("state transition err %v", r)
}() }
}()
*/
var ( var (
tx = self.tx tx = self.tx

View File

@ -139,7 +139,9 @@ func (self *Miner) mineNewBlock() {
// Accumulate all valid transaction and apply them to the new state // Accumulate all valid transaction and apply them to the new state
// Error may be ignored. It's not important during mining // Error may be ignored. It's not important during mining
parent := self.ethereum.BlockChain().GetBlock(self.block.PrevHash)
coinbase := self.block.State().GetOrNewStateObject(self.block.Coinbase) coinbase := self.block.State().GetOrNewStateObject(self.block.Coinbase)
coinbase.SetGasPool(self.block.CalcGasLimit(parent))
receipts, txs, unhandledTxs, err := stateManager.ProcessTransactions(coinbase, self.block.State(), self.block, self.block, self.txs) receipts, txs, unhandledTxs, err := stateManager.ProcessTransactions(coinbase, self.block.State(), self.block, self.block, self.txs)
if err != nil { if err != nil {
ethutil.Config.Log.Debugln("[MINER]", err) ethutil.Config.Log.Debugln("[MINER]", err)