mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
get stable LogsHash result
This commit is contained in:
parent
18a902799e
commit
e8731404d0
1 changed files with 5 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ import (
|
|||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"sort"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
|
@ -264,6 +265,10 @@ func (s *StateDB) Logs() []*types.Log {
|
|||
for _, lgs := range s.logs {
|
||||
logs = append(logs, lgs...)
|
||||
}
|
||||
// Due to the map iteration is not stable, we need to sort the logs by TxIndex, then the LogsHash result is stable.
|
||||
sort.Slice(logs, func(i, j int) bool {
|
||||
return logs[i].TxIndex < logs[j].TxIndex
|
||||
})
|
||||
return logs
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue