From 697c2b5dc16653228c5264d01c08163cebda3aeb Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Tue, 3 Feb 2015 23:09:39 +0100 Subject: Correct block parent timestamp check and typos --- core/block_processor.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/block_processor.go b/core/block_processor.go index 4d5cd94c9..60d73e390 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -206,7 +206,7 @@ func (sm *BlockProcessor) ProcessWithParent(block, parent *types.Block) (td *big return } - if err = sm.AccumelateRewards(state, block, parent); err != nil { + if err = sm.AccumulateRewards(state, block, parent); err != nil { return } @@ -248,8 +248,8 @@ func (sm *BlockProcessor) ValidateBlock(block, parent *types.Block) error { } diff := block.Header().Time - parent.Header().Time - if diff < 0 { - return ValidationError("Block timestamp less then prev block %v (%v - %v)", diff, block.Header().Time, sm.bc.CurrentBlock().Header().Time) + if diff <= 0 { + return ValidationError("Block timestamp not after prev block %v (%v - %v)", diff, block.Header().Time, sm.bc.CurrentBlock().Header().Time) } if block.Time() > time.Now().Unix() { @@ -264,7 +264,7 @@ func (sm *BlockProcessor) ValidateBlock(block, parent *types.Block) error { return nil } -func (sm *BlockProcessor) AccumelateRewards(statedb *state.StateDB, block, parent *types.Block) error { +func (sm *BlockProcessor) AccumulateRewards(statedb *state.StateDB, block, parent *types.Block) error { reward := new(big.Int).Set(BlockReward) ancestors := set.New() @@ -326,7 +326,7 @@ func (sm *BlockProcessor) GetMessages(block *types.Block) (messages []*state.Mes defer state.Reset() sm.TransitionState(state, parent, block) - sm.AccumelateRewards(state, block, parent) + sm.AccumulateRewards(state, block, parent) return state.Manifest().Messages, nil } @@ -347,7 +347,7 @@ func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err erro defer state.Reset() sm.TransitionState(state, parent, block) - sm.AccumelateRewards(state, block, parent) + sm.AccumulateRewards(state, block, parent) return state.Logs(), nil } -- cgit v1.2.3 From c64852dbccd0c8eb57cab994aefd0243c65b351b Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 5 Feb 2015 11:55:03 -0800 Subject: pending / chain event --- core/block_processor.go | 8 ++++++++ core/filter.go | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/block_processor.go b/core/block_processor.go index d59d7feca..349de85e0 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -19,6 +19,10 @@ import ( "gopkg.in/fatih/set.v0" ) +type PendingBlockEvent struct { + Block *types.Block +} + var statelogger = logger.NewLogger("BLOCK") type EthManager interface { @@ -154,6 +158,10 @@ done: block.Reward = cumulativeSum block.Header().GasUsed = totalUsedGas + if transientProcess { + go self.eventMux.Post(PendingBlockEvent{block}) + } + return receipts, handled, unhandled, erroneous, err } diff --git a/core/filter.go b/core/filter.go index c22996d7e..24d1f5a4a 100644 --- a/core/filter.go +++ b/core/filter.go @@ -33,8 +33,9 @@ type Filter struct { max int topics [][]byte - BlockCallback func(*types.Block) - LogsCallback func(state.Logs) + BlockCallback func(*types.Block) + PendingCallback func(*types.Block) + LogsCallback func(state.Logs) } // Create a new filter which uses a bloom filter on blocks to figure out whether a particular block -- cgit v1.2.3 From f8c1eb157d6025c16c808fad01d5b32dccd8e2f1 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 5 Feb 2015 14:42:12 -0800 Subject: Undone fix. Will re-enable once chain resets --- core/block_processor.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'core') diff --git a/core/block_processor.go b/core/block_processor.go index e3f764616..6db3c25f5 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -129,20 +129,14 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state cumulativeSum = new(big.Int) ) -done: - for i, tx := range txs { + for _, tx := range txs { receipt, txGas, err := self.ApplyTransaction(coinbase, state, block, tx, totalUsedGas, transientProcess) if err != nil { - return nil, nil, nil, nil, err - switch { case IsNonceErr(err): - err = nil // ignore error - continue + return nil, nil, nil, nil, err case IsGasLimitErr(err): - unhandled = txs[i:] - - break done + return nil, nil, nil, nil, err default: statelogger.Infoln(err) erroneous = append(erroneous, tx) @@ -260,9 +254,8 @@ func (sm *BlockProcessor) ValidateBlock(block, parent *types.Block) error { return fmt.Errorf("Difficulty check failed for block %v, %v", block.Header().Difficulty, expd) } - diff := block.Header().Time - parent.Header().Time - if diff <= 0 { - return ValidationError("Block timestamp not after prev block %v (%v - %v)", diff, block.Header().Time, sm.bc.CurrentBlock().Header().Time) + if block.Time() < parent.Time() { + return ValidationError("Block timestamp not after prev block (%v - %v)", block.Header().Time, parent.Header().Time) } if block.Time() > time.Now().Unix() { -- cgit v1.2.3 From c8147fb7b9e4bf349c47a1e4620e1b79cbeb7f7a Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 7 Feb 2015 17:04:04 +0100 Subject: Compare regardless of length --- core/filter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/filter.go b/core/filter.go index 24d1f5a4a..b93fcc8a5 100644 --- a/core/filter.go +++ b/core/filter.go @@ -145,7 +145,7 @@ func (self *Filter) FilterLogs(logs state.Logs) state.Logs { // Filter the logs for interesting stuff Logs: for _, log := range logs { - if len(self.address) > 0 && !bytes.Equal(self.address, log.Address()) { + if !bytes.Equal(self.address, log.Address()) { continue } -- cgit v1.2.3