diff --git a/_pkg.dev/wire/payload/mgetheaders.go b/_pkg.dev/wire/payload/mgetheaders.go deleted file mode 100644 index 87c30c607..000000000 --- a/_pkg.dev/wire/payload/mgetheaders.go +++ /dev/null @@ -1,61 +0,0 @@ -package payload - -import ( - "io" - - "github.com/CityOfZion/neo-go/pkg/wire/command" - "github.com/CityOfZion/neo-go/pkg/wire/util" -) - -//GetHeadersMessage represents a GetHeaders message on the neo-network -type GetHeadersMessage struct { - cmd command.Type - hashStart []util.Uint256 - hashStop util.Uint256 -} - -// NewGetHeadersMessage returns a NewGetHeaders object -// Start contains the list of all headers you want to fetch -// End contains the list of the highest header hash you would like to fetch -func NewGetHeadersMessage(start []util.Uint256, stop util.Uint256) (*GetHeadersMessage, error) { - getHeaders := &GetHeadersMessage{command.GetHeaders, start, stop} - - return getHeaders, nil - -} - -func newAbstractGetHeaders(start []util.Uint256, stop util.Uint256, cmd command.Type) (*GetHeadersMessage, error) { - getHeaders, err := NewGetHeadersMessage(start, stop) - - if err != nil { - return nil, err - } - getHeaders.cmd = cmd - return getHeaders, nil -} - -// DecodePayload Implements Messager interface -func (v *GetHeadersMessage) DecodePayload(r io.Reader) error { - - br := util.BinReader{R: r} - lenStart := br.VarUint() - v.hashStart = make([]util.Uint256, lenStart) - br.Read(&v.hashStart) - br.Read(&v.hashStop) - - return br.Err -} - -// EncodePayload Implements messager interface -func (v *GetHeadersMessage) EncodePayload(w io.Writer) error { - bw := &util.BinWriter{W: w} - bw.VarUint(uint64(len(v.hashStart))) - bw.Write(v.hashStart) - bw.Write(v.hashStop) - return bw.Err -} - -// Command Implements messager interface -func (v *GetHeadersMessage) Command() command.Type { - return v.cmd -} diff --git a/_pkg.dev/wire/payload/mgetheaders_test.go b/_pkg.dev/wire/payload/mgetheaders_test.go deleted file mode 100644 index 7ba0d6a10..000000000 --- a/_pkg.dev/wire/payload/mgetheaders_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package payload - -import ( - "bytes" - "crypto/sha256" - "testing" - - "github.com/CityOfZion/neo-go/pkg/wire/util/Checksum" - - "github.com/CityOfZion/neo-go/pkg/wire/util" - "github.com/stretchr/testify/assert" -) - -// Test taken from neo-go v1 -func TestGetHeadersEncodeDecode(t *testing.T) { - - var ( - start = []util.Uint256{ - sha256.Sum256([]byte("a")), - sha256.Sum256([]byte("b")), - sha256.Sum256([]byte("c")), - sha256.Sum256([]byte("d")), - } - stop = sha256.Sum256([]byte("e")) - ) - msgGetHeaders, err := NewGetHeadersMessage(start, stop) - assert.Equal(t, nil, err) - - buf := new(bytes.Buffer) - - err = msgGetHeaders.EncodePayload(buf) - assert.Equal(t, nil, err) - expected := checksum.FromBuf(buf) - - msgGetHeadersDec, err := NewGetHeadersMessage([]util.Uint256{}, util.Uint256{}) - assert.Equal(t, nil, err) - - r := bytes.NewReader(buf.Bytes()) - err = msgGetHeadersDec.DecodePayload(r) - assert.Equal(t, nil, err) - - buf = new(bytes.Buffer) - err = msgGetHeadersDec.EncodePayload(buf) - have := checksum.FromBuf(buf) - - assert.Equal(t, expected, have) -}