diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-04-21 18:14:38 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-04-21 18:14:38 +0800 |
commit | 4ad8b28794c3fe620a1665fec02ff4280c5f79b8 (patch) | |
tree | b704e953b177086703269de4643a3ecdbdbbfa3b /core | |
parent | 1dc91975ad801418f6756381275d52549949f4dd (diff) | |
parent | 6c2b703c5871f5d8adf3bc4032385135e665018b (diff) | |
download | dexon-4ad8b28794c3fe620a1665fec02ff4280c5f79b8.tar dexon-4ad8b28794c3fe620a1665fec02ff4280c5f79b8.tar.gz dexon-4ad8b28794c3fe620a1665fec02ff4280c5f79b8.tar.bz2 dexon-4ad8b28794c3fe620a1665fec02ff4280c5f79b8.tar.lz dexon-4ad8b28794c3fe620a1665fec02ff4280c5f79b8.tar.xz dexon-4ad8b28794c3fe620a1665fec02ff4280c5f79b8.tar.zst dexon-4ad8b28794c3fe620a1665fec02ff4280c5f79b8.zip |
Merge pull request #760 from obscuren/develop
core: transaction fixes
Diffstat (limited to 'core')
-rw-r--r-- | core/block_processor.go | 4 | ||||
-rw-r--r-- | core/chain_manager.go | 20 | ||||
-rw-r--r-- | core/filter.go | 3 | ||||
-rw-r--r-- | core/state/managed_state.go | 1 | ||||
-rw-r--r-- | core/transaction_pool.go | 6 |
5 files changed, 22 insertions, 12 deletions
diff --git a/core/block_processor.go b/core/block_processor.go index 4c70872ac..28636a725 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -85,8 +85,8 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated _, gas, err := ApplyMessage(NewEnv(statedb, self.bc, tx, block), tx, cb) if err != nil && (IsNonceErr(err) || state.IsGasLimitErr(err) || IsInvalidTxErr(err)) { // If the account is managed, remove the invalid nonce. - from, _ := tx.From() - self.bc.TxState().RemoveNonce(from, tx.Nonce()) + //from, _ := tx.From() + //self.bc.TxState().RemoveNonce(from, tx.Nonce()) return nil, nil, err } diff --git a/core/chain_manager.go b/core/chain_manager.go index 3f2b3a26a..1df56b27f 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -26,11 +26,10 @@ var ( blockNumPre = []byte("block-num-") ) -const blockCacheLimit = 10000 - -type StateQuery interface { - GetAccount(addr []byte) *state.StateObject -} +const ( + blockCacheLimit = 10000 + maxFutureBlocks = 256 +) func CalcDifficulty(block, parent *types.Header) *big.Int { diff := new(big.Int) @@ -95,7 +94,14 @@ 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)} + bc := &ChainManager{ + blockDb: blockDb, + stateDb: stateDb, + genesisBlock: GenesisBlock(stateDb), + eventMux: mux, + quit: make(chan struct{}), + cache: NewBlockCache(blockCacheLimit), + } bc.setLastBlock() // Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain @@ -116,7 +122,7 @@ func NewChainManager(blockDb, stateDb common.Database, mux *event.TypeMux) *Chai // Take ownership of this particular state bc.txState = state.ManageState(bc.State().Copy()) - bc.futureBlocks = NewBlockCache(254) + bc.futureBlocks = NewBlockCache(maxFutureBlocks) bc.makeCache() go bc.update() diff --git a/core/filter.go b/core/filter.go index 4508b35b3..a924709f2 100644 --- a/core/filter.go +++ b/core/filter.go @@ -134,7 +134,8 @@ Logs: for i, topics := range self.topics { for _, topic := range topics { var match bool - if log.Topics[i] == topic { + // common.Hash{} is a match all (wildcard) + if (topic == common.Hash{}) || log.Topics[i] == topic { match = true } if !match { diff --git a/core/state/managed_state.go b/core/state/managed_state.go index 9e6be9980..5114f7a7a 100644 --- a/core/state/managed_state.go +++ b/core/state/managed_state.go @@ -62,6 +62,7 @@ func (ms *ManagedState) NewNonce(addr common.Address) uint64 { } } account.nonces = append(account.nonces, true) + return uint64(len(account.nonces)-1) + account.nstart } diff --git a/core/transaction_pool.go b/core/transaction_pool.go index 94a94f93d..eaddcfa09 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -28,6 +28,8 @@ const txPoolQueueSize = 50 type TxPoolHook chan *types.Transaction type TxMsg struct{ Tx *types.Transaction } +type stateFn func() *state.StateDB + const ( minGasPrice = 1000000 ) @@ -47,7 +49,7 @@ type TxPool struct { // Quiting channel quit chan bool // The state function which will allow us to do some pre checkes - currentState func() *state.StateDB + currentState stateFn // The actual pool txs map[common.Hash]*types.Transaction invalidHashes *set.Set @@ -57,7 +59,7 @@ type TxPool struct { eventMux *event.TypeMux } -func NewTxPool(eventMux *event.TypeMux, currentStateFn func() *state.StateDB) *TxPool { +func NewTxPool(eventMux *event.TypeMux, currentStateFn stateFn) *TxPool { return &TxPool{ txs: make(map[common.Hash]*types.Transaction), queueChan: make(chan *types.Transaction, txPoolQueueSize), |