forked from TrueCloudLab/neoneo-go
util: move strange Read2000Uint256Hashes() into storage
It's the only user of it.
This commit is contained in:
parent
672668b9fb
commit
07096a551b
2 changed files with 14 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ func HeaderHashes(s Store) ([]util.Uint256, error) {
|
||||||
hashMap := make(map[uint32][]util.Uint256)
|
hashMap := make(map[uint32][]util.Uint256)
|
||||||
s.Seek(IXHeaderHashList.Bytes(), func(k, v []byte) {
|
s.Seek(IXHeaderHashList.Bytes(), func(k, v []byte) {
|
||||||
storedCount := binary.LittleEndian.Uint32(k[1:])
|
storedCount := binary.LittleEndian.Uint32(k[1:])
|
||||||
hashes, err := util.Read2000Uint256Hashes(v)
|
hashes, err := read2000Uint256Hashes(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -78,3 +79,15 @@ func HeaderHashes(s Store) ([]util.Uint256, error) {
|
||||||
|
|
||||||
return hashes, nil
|
return hashes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// read2000Uint256Hashes attempts to read 2000 Uint256 hashes from
|
||||||
|
// the given byte array.
|
||||||
|
func read2000Uint256Hashes(b []byte) ([]util.Uint256, error) {
|
||||||
|
r := bytes.NewReader(b)
|
||||||
|
lenHashes := util.ReadVarUint(r)
|
||||||
|
hashes := make([]util.Uint256, lenHashes)
|
||||||
|
if err := binary.Read(r, binary.LittleEndian, hashes); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return hashes, nil
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
@ -89,15 +88,3 @@ func WriteVarBytes(w io.Writer, b []byte) error {
|
||||||
}
|
}
|
||||||
return binary.Write(w, binary.LittleEndian, b)
|
return binary.Write(w, binary.LittleEndian, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read2000Uint256Hashes attempt to read 2000 Uint256 hashes from
|
|
||||||
// the given byte array.
|
|
||||||
func Read2000Uint256Hashes(b []byte) ([]Uint256, error) {
|
|
||||||
r := bytes.NewReader(b)
|
|
||||||
lenHashes := ReadVarUint(r)
|
|
||||||
hashes := make([]Uint256, lenHashes)
|
|
||||||
if err := binary.Read(r, binary.LittleEndian, hashes); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return hashes, nil
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue