mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-23 03:38:35 +00:00
core: add EncodeBinary() support for the block
This commit is contained in:
parent
0ff38e9645
commit
c093f070d3
1 changed files with 15 additions and 0 deletions
|
@ -152,5 +152,20 @@ func (b *Block) DecodeBinary(r io.Reader) error {
|
|||
|
||||
// EncodeBinary encodes the block to the given writer.
|
||||
func (b *Block) EncodeBinary(w io.Writer) error {
|
||||
err := b.BlockBase.EncodeBinary(w)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bw := util.BinWriter{W: w}
|
||||
bw.WriteVarUint(uint64(len(b.Transactions)))
|
||||
if bw.Err != nil {
|
||||
return err
|
||||
}
|
||||
for _, tx := range b.Transactions {
|
||||
err := tx.EncodeBinary(w)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue