浏览代码

core, miner: add PendingStateEvent to track non-log updates

Péter Szilágyi 9 年之前
父节点
当前提交
b534106cc8
共有 2 个文件被更改,包括 12 次插入2 次删除
  1. 3 0
      core/events.go
  2. 9 2
      miner/worker.go

+ 3 - 0
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 }
 

+ 9 - 2
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)
 	}
 }