util: add 'constructors' for BinReader/BinWriter

And an additional BufBinWriter to ease buffer management.
This commit is contained in:
Roman Khimov 2019-09-15 14:58:19 +03:00
parent 0838948540
commit aacf58c9ab
31 changed files with 138 additions and 95 deletions

View file

@ -84,7 +84,7 @@ func HeaderHashes(s Store) ([]util.Uint256, error) {
// the given byte array.
func read2000Uint256Hashes(b []byte) ([]util.Uint256, error) {
r := bytes.NewReader(b)
br := util.BinReader{R: r}
br := util.NewBinReaderFromIO(r)
lenHashes := br.ReadVarUint()
hashes := make([]util.Uint256, lenHashes)
br.ReadLE(hashes)