forked from cerc-io/plugeth
eth: use slices package for sorting (#27490)
Also adds Hash.Less method for sorting purposes. --------- Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
@@ -65,6 +65,11 @@ func BigToHash(b *big.Int) Hash { return BytesToHash(b.Bytes()) }
|
||||
// If b is larger than len(h), b will be cropped from the left.
|
||||
func HexToHash(s string) Hash { return BytesToHash(FromHex(s)) }
|
||||
|
||||
// Less compares two hashes.
|
||||
func (h Hash) Less(other Hash) bool {
|
||||
return bytes.Compare(h[:], other[:]) < 0
|
||||
}
|
||||
|
||||
// Bytes gets the byte representation of the underlying hash.
|
||||
func (h Hash) Bytes() []byte { return h[:] }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user