mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
core/state: optimize Logs by using index sort
This commit is contained in:
parent
de5ea2ffd8
commit
0c8bf82527
1 changed files with 4 additions and 6 deletions
|
|
@ -22,7 +22,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"maps"
|
"maps"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -263,13 +262,12 @@ func (s *StateDB) GetLogs(hash common.Hash, blockNumber uint64, blockHash common
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StateDB) Logs() []*types.Log {
|
func (s *StateDB) Logs() []*types.Log {
|
||||||
logs := make([]*types.Log, 0, s.logSize)
|
logs := make([]*types.Log, s.logSize)
|
||||||
for _, lgs := range s.logs {
|
for _, lgs := range s.logs {
|
||||||
logs = append(logs, lgs...)
|
for _, l := range lgs {
|
||||||
|
logs[l.Index] = l
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sort.Slice(logs, func(i, j int) bool {
|
|
||||||
return logs[i].Index < logs[j].Index
|
|
||||||
})
|
|
||||||
return logs
|
return logs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue