diff options
-rw-r--r-- | core/events.go | 3 | ||||
-rw-r--r-- | miner/worker.go | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/core/events.go b/core/events.go index c23206cad..bed8c7b90 100644 --- a/core/events.go +++ b/core/events.go @@ -35,6 +35,9 @@ type PendingLogsEvent struct { Logs vm.Logs } +// PendingStateEvent is posted pre mining and notifies of pending state changes. +type PendingStateEvent struct{} + // NewBlockEvent is posted when a block has been imported. type NewBlockEvent struct{ Block *types.Block } diff --git a/miner/worker.go b/miner/worker.go index 71f22ef1c..f3e95cb5f 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -649,8 +649,15 @@ func (env *Work) commitTransactions(mux *event.TypeMux, transactions types.Trans coalescedLogs = append(coalescedLogs, logs...) } } - if len(coalescedLogs) > 0 { - go mux.Post(core.PendingLogsEvent{Logs: coalescedLogs}) + if len(coalescedLogs) > 0 || env.tcount > 0 { + go func(logs vm.Logs, tcount int) { + if len(logs) > 0 { + mux.Post(core.PendingLogsEvent{Logs: logs}) + } + if tcount > 0 { + mux.Post(core.PendingStateEvent{}) + } + }(coalescedLogs, env.tcount) } } |