Skip to content

Commit 90920a9

Browse files
committed
miner: fix pendingLogsFeed
1 parent 1f45af0 commit 90920a9

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

miner/worker.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,22 +1071,23 @@ func (env *Work) commitTransactions(mux *event.TypeMux, balanceFee map[common.Ad
10711071
// make a copy, the state caches the logs and these logs get "upgraded" from pending to mined
10721072
// logs by filling in the block hash when the block was mined by the local miner. This can
10731073
// cause a race condition if a log was "upgraded" before the PendingLogsEvent is processed.
1074-
if len(coalescedLogs) > 0 {
1074+
if len(coalescedLogs) > 0 || env.tcount > 0 {
10751075
cpy := make([]*types.Log, len(coalescedLogs))
10761076
for i, l := range coalescedLogs {
10771077
cpy[i] = new(types.Log)
10781078
*cpy[i] = *l
10791079
}
1080-
pendingLogsFeed.Send(cpy)
1081-
}
1082-
if env.tcount > 0 {
1083-
go func(tcount int) {
1084-
err := mux.Post(core.PendingStateEvent{})
1085-
if err != nil {
1086-
log.Warn("[commitTransactions] Error when sending PendingStateEvent", "tcount", tcount)
1080+
go func(logs []*types.Log, tcount int) {
1081+
if len(logs) > 0 {
1082+
pendingLogsFeed.Send(logs)
10871083
}
1088-
}(env.tcount)
1089-
1084+
if tcount > 0 {
1085+
err := mux.Post(core.PendingStateEvent{})
1086+
if err != nil {
1087+
log.Warn("[commitTransactions] Error when sending PendingStateEvent", "tcount", tcount)
1088+
}
1089+
}
1090+
}(cpy, env.tcount)
10901091
}
10911092
}
10921093

0 commit comments

Comments
 (0)