File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 99 "container/heap"
1010 "context"
1111 "math/big"
12- "sort"
1312 "sync"
1413 "time"
1514
@@ -315,8 +314,6 @@ func (q *actQueue) AllActs() []action.SealedEnvelope {
315314 if len (q .items ) == 0 {
316315 return acts
317316 }
318- // WARNING: after calling this function, the queue should be destroyed
319- sort .Sort (q .ascQueue )
320317 for _ , nonce := range q .ascQueue {
321318 acts = append (acts , q .items [nonce .nonce ])
322319 }
@@ -333,6 +330,7 @@ func (q *actQueue) PopActionWithLargestNonce() *action.SealedEnvelope {
333330 heap .Remove (& q .ascQueue , itemMeta .ascIdx )
334331 item := q .items [itemMeta .nonce ]
335332 delete (q .items , itemMeta .nonce )
333+ q .updateFromNonce (itemMeta .nonce )
336334
337335 return & item
338336}
Original file line number Diff line number Diff line change 55 "encoding/hex"
66 "errors"
77 "math/big"
8+ "sort"
89 "strings"
910 "sync"
1011 "sync/atomic"
@@ -266,7 +267,11 @@ func (worker *queueWorker) AllActions(sender address.Address) ([]action.SealedEn
266267 worker .mu .RLock ()
267268 defer worker .mu .RUnlock ()
268269 if actQueue := worker .accountActs .Account (sender .String ()); actQueue != nil {
269- return actQueue .AllActs (), true
270+ acts := actQueue .AllActs ()
271+ sort .Slice (acts , func (i , j int ) bool {
272+ return acts [i ].Nonce () < acts [j ].Nonce ()
273+ })
274+ return acts , true
270275 }
271276 return nil , false
272277}
@@ -290,9 +295,8 @@ func (worker *queueWorker) ResetAccount(sender address.Address) []action.SealedE
290295 if actQueue != nil {
291296 pendingActs := actQueue .AllActs ()
292297 actQueue .Reset ()
293- worker .mu .Lock ()
298+ // the following line is thread safe with worker.mu.RLock
294299 worker .emptyAccounts .Set (senderStr , struct {}{})
295- worker .mu .Unlock ()
296300 return pendingActs
297301 }
298302 return nil
You can’t perform that action at this time.
0 commit comments