Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker send logs asynchronously #616

Open
wants to merge 1 commit into
base: dev-upgrade
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,22 +1071,23 @@ func (env *Work) commitTransactions(mux *event.TypeMux, balanceFee map[common.Ad
// make a copy, the state caches the logs and these logs get "upgraded" from pending to mined
// logs by filling in the block hash when the block was mined by the local miner. This can
// cause a race condition if a log was "upgraded" before the PendingLogsEvent is processed.
if len(coalescedLogs) > 0 {
if len(coalescedLogs) > 0 || env.tcount > 0 {
cpy := make([]*types.Log, len(coalescedLogs))
for i, l := range coalescedLogs {
cpy[i] = new(types.Log)
*cpy[i] = *l
}
pendingLogsFeed.Send(cpy)
}
if env.tcount > 0 {
go func(tcount int) {
err := mux.Post(core.PendingStateEvent{})
if err != nil {
log.Warn("[commitTransactions] Error when sending PendingStateEvent", "tcount", tcount)
go func(logs []*types.Log, tcount int) {
if len(logs) > 0 {
pendingLogsFeed.Send(logs)
}
}(env.tcount)

if tcount > 0 {
err := mux.Post(core.PendingStateEvent{})
if err != nil {
log.Warn("[commitTransactions] Error when sending PendingStateEvent", "tcount", tcount)
}
}
}(cpy, env.tcount)
}
}

Expand Down