Skip to content

Commit

Permalink
improve actqueue efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
Liuhaai committed Jun 9, 2022
1 parent c10c9af commit f6be2f5
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 180 deletions.
16 changes: 4 additions & 12 deletions actpool/actpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func TestActPool_removeConfirmedActs(t *testing.T) {
acct.Balance = big.NewInt(100000000000000000)

return 0, nil
}).Times(8)
}).Times(5)
require.NoError(ap.Add(context.Background(), tsf1))
require.NoError(ap.Add(context.Background(), tsf2))
require.NoError(ap.Add(context.Background(), tsf3))
Expand All @@ -416,7 +416,7 @@ func TestActPool_removeConfirmedActs(t *testing.T) {
}).Times(1)
ap.Reset()
require.Equal(0, ap.allActions.Count())
require.True(ap.worker[ap.allocatedWorker(addr)].GetQueue(addr).Empty())
require.True(ap.worker[ap.allocatedWorker(addr)].GetQueue(addr).IsEmpty())
}

func TestActPool_Reset(t *testing.T) {
Expand Down Expand Up @@ -988,7 +988,7 @@ func TestActPool_GetSize(t *testing.T) {
acct.Balance = big.NewInt(100000000000000000)

return 0, nil
}).Times(8)
}).Times(5)
require.NoError(ap.Add(context.Background(), tsf1))
require.NoError(ap.Add(context.Background(), tsf2))
require.NoError(ap.Add(context.Background(), tsf3))
Expand Down Expand Up @@ -1103,7 +1103,7 @@ func getPendingBalance(ap *actPool, addrStr string) (*big.Int, error) {
return nil, err
}
if queue := ap.worker[ap.allocatedWorker(addr)].GetQueue(addr); queue != nil {
return queue.PendingBalance(), nil
return queue.PendingBalanceAt(queue.PendingNonce()), nil
}
state, err := accountutil.AccountState(ap.sf, addr)
if err != nil {
Expand All @@ -1122,14 +1122,6 @@ func getActPoolCfg() config.ActPool {
}
}

func actionMap2Slice(actMap map[string][]action.SealedEnvelope) []action.SealedEnvelope {
acts := make([]action.SealedEnvelope, 0)
for _, parts := range actMap {
acts = append(acts, parts...)
}
return acts
}

func lenPendingActionMap(acts map[string][]action.SealedEnvelope) int {
l := 0
for _, part := range acts {
Expand Down
Loading

0 comments on commit f6be2f5

Please sign in to comment.