2018-02-01 09:25:34 +00:00
|
|
|
package payload
|
|
|
|
|
|
|
|
import (
|
2019-09-16 09:18:13 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/io"
|
2018-02-04 19:54:51 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
2018-02-01 09:25:34 +00:00
|
|
|
)
|
|
|
|
|
2019-12-25 16:40:18 +00:00
|
|
|
// Maximum inventory hashes number is limited to 500.
|
|
|
|
const (
|
|
|
|
MaxHashesCount = 500
|
|
|
|
)
|
|
|
|
|
2018-02-04 19:54:51 +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
|
2018-02-04 19:54:51 +00:00
|
|
|
HashStart []util.Uint256
|
2018-02-01 09:25:34 +00:00
|
|
|
// hash of last block that node requests
|
2018-02-04 19:54:51 +00:00
|
|
|
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.
|
2018-02-04 19:54:51 +00:00
|
|
|
func NewGetBlocks(start []util.Uint256, stop util.Uint256) *GetBlocks {
|
2018-02-07 14:16:50 +00:00
|
|
|
return &GetBlocks{
|
|
|
|
HashStart: start,
|
|
|
|
HashStop: stop,
|
|
|
|
}
|
2018-02-04 19:54:51 +00:00
|
|
|
}
|
2018-02-01 09:25:34 +00:00
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// DecodeBinary implements Serializable interface.
|
|
|
|
func (p *GetBlocks) DecodeBinary(br *io.BinReader) {
|
2019-11-14 08:07:23 +00:00
|
|
|
br.ReadArray(&p.HashStart)
|
2019-12-06 15:37:46 +00:00
|
|
|
br.ReadBytes(p.HashStop[:])
|
2018-02-01 09:25:34 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// EncodeBinary implements Serializable interface.
|
|
|
|
func (p *GetBlocks) EncodeBinary(bw *io.BinWriter) {
|
2019-11-14 08:07:23 +00:00
|
|
|
bw.WriteArray(p.HashStart)
|
2019-12-06 15:22:21 +00:00
|
|
|
bw.WriteBytes(p.HashStop[:])
|
2018-02-01 09:25:34 +00:00
|
|
|
}
|