neo-go/pkg/network/payload/getblocks.go

35 lines
851 B
Go
Raw Normal View History

2018-02-01 09:25:34 +00:00
package payload
import (
"github.com/CityOfZion/neo-go/pkg/io"
"github.com/CityOfZion/neo-go/pkg/util"
2018-02-01 09:25:34 +00:00
)
// GetBlocks contains fields and methods to be shared with the
type GetBlocks struct {
2018-02-01 09:25:34 +00:00
// hash of latest block that node requests
HashStart []util.Uint256
2018-02-01 09:25:34 +00:00
// hash of last block that node requests
HashStop util.Uint256
2018-02-01 09:25:34 +00:00
}
2019-10-22 14:56:03 +00:00
// NewGetBlocks returns a pointer to a GetBlocks object.
func NewGetBlocks(start []util.Uint256, stop util.Uint256) *GetBlocks {
return &GetBlocks{
HashStart: start,
HashStop: stop,
}
}
2018-02-01 09:25:34 +00:00
// DecodeBinary implements Serializable interface.
func (p *GetBlocks) DecodeBinary(br *io.BinReader) {
br.ReadArray(&p.HashStart)
br.ReadLE(&p.HashStop)
2018-02-01 09:25:34 +00:00
}
// EncodeBinary implements Serializable interface.
func (p *GetBlocks) EncodeBinary(bw *io.BinWriter) {
bw.WriteArray(p.HashStart)
bw.WriteBytes(p.HashStop[:])
2018-02-01 09:25:34 +00:00
}