mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
7fd4b0431b
* Refactor `structural*` files. * some refactor * dry hashbuilder a bit * rename constants back to the magic rlp values
32 lines
520 B
Go
32 lines
520 B
Go
package trie
|
|
|
|
import "bytes"
|
|
|
|
type ByteArrayWriter struct {
|
|
dest []byte
|
|
pos int
|
|
}
|
|
|
|
func (w *ByteArrayWriter) Setup(dest []byte, pos int) {
|
|
w.dest = dest
|
|
w.pos = pos
|
|
}
|
|
|
|
func (w *ByteArrayWriter) Write(data []byte) (int, error) {
|
|
copy(w.dest[w.pos:], data)
|
|
w.pos += len(data)
|
|
return len(data), nil
|
|
}
|
|
|
|
type sortable [][]byte
|
|
|
|
func (s sortable) Len() int {
|
|
return len(s)
|
|
}
|
|
func (s sortable) Less(i, j int) bool {
|
|
return bytes.Compare(s[i], s[j]) < 0
|
|
}
|
|
func (s sortable) Swap(i, j int) {
|
|
s[i], s[j] = s[j], s[i]
|
|
}
|