mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-06 06:06:49 +00:00
[NOD-675] Replace start-hash/stop-hash with meaningful names (#597)
* [NOD-675] Rename startHash/stopHash to lowHigh/stopHash * [NOD-675] Fix typo * [NOD-675] Undo go.mod go.sum conflicts * [NOD-675] revert back to startHash for getChainFromBlock. * [NOD-675] Revet back to startHash in getChainFromBlock leftovers. * [NOD-675] Fix test name.
This commit is contained in:
parent
52e0a0967d
commit
c0463a8a68
@ -143,8 +143,8 @@ func messageSummary(msg wire.Message) string {
|
||||
msg.HighHash)
|
||||
|
||||
case *wire.MsgGetHeaders:
|
||||
return fmt.Sprintf("start hash %s, stop hash %s", msg.StartHash,
|
||||
msg.StopHash)
|
||||
return fmt.Sprintf("low hash %s, high hash %s", msg.LowHash,
|
||||
msg.HighHash)
|
||||
|
||||
case *wire.MsgGetBlockLocator:
|
||||
return fmt.Sprintf("high hash %s, low hash %s", msg.HighHash,
|
||||
|
24
peer/peer.go
24
peer/peer.go
@ -426,8 +426,8 @@ type Peer struct {
|
||||
prevGetBlockInvsLow *daghash.Hash
|
||||
prevGetBlockInvsHigh *daghash.Hash
|
||||
prevGetHdrsMtx sync.Mutex
|
||||
prevGetHdrsStart *daghash.Hash
|
||||
prevGetHdrsStop *daghash.Hash
|
||||
prevGetHdrsLow *daghash.Hash
|
||||
prevGetHdrsHigh *daghash.Hash
|
||||
|
||||
// These fields keep track of statistics for the peer and are protected
|
||||
// by the statsMtx mutex.
|
||||
@ -879,32 +879,32 @@ func (p *Peer) PushBlockLocatorMsg(locator blockdag.BlockLocator) error {
|
||||
}
|
||||
|
||||
// PushGetHeadersMsg sends a getblockinvs message for the provided block locator
|
||||
// and stop hash. It will ignore back-to-back duplicate requests.
|
||||
// and low hash. It will ignore back-to-back duplicate requests.
|
||||
//
|
||||
// This function is safe for concurrent access.
|
||||
func (p *Peer) PushGetHeadersMsg(startHash, stopHash *daghash.Hash) error {
|
||||
func (p *Peer) PushGetHeadersMsg(lowHash, highHash *daghash.Hash) error {
|
||||
// Filter duplicate getheaders requests.
|
||||
p.prevGetHdrsMtx.Lock()
|
||||
isDuplicate := p.prevGetHdrsStop != nil && p.prevGetHdrsStart != nil &&
|
||||
startHash != nil && stopHash.IsEqual(p.prevGetHdrsStop) &&
|
||||
startHash.IsEqual(p.prevGetHdrsStart)
|
||||
isDuplicate := p.prevGetHdrsHigh != nil && p.prevGetHdrsLow != nil &&
|
||||
lowHash != nil && highHash.IsEqual(p.prevGetHdrsHigh) &&
|
||||
lowHash.IsEqual(p.prevGetHdrsLow)
|
||||
p.prevGetHdrsMtx.Unlock()
|
||||
|
||||
if isDuplicate {
|
||||
log.Tracef("Filtering duplicate [getheaders] with start hash %s",
|
||||
startHash)
|
||||
log.Tracef("Filtering duplicate [getheaders] with low hash %s",
|
||||
lowHash)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Construct the getheaders request and queue it to be sent.
|
||||
msg := wire.NewMsgGetHeaders(startHash, stopHash)
|
||||
msg := wire.NewMsgGetHeaders(lowHash, highHash)
|
||||
p.QueueMessage(msg, nil)
|
||||
|
||||
// Update the previous getheaders request information for filtering
|
||||
// duplicates.
|
||||
p.prevGetHdrsMtx.Lock()
|
||||
p.prevGetHdrsStart = startHash
|
||||
p.prevGetHdrsStop = stopHash
|
||||
p.prevGetHdrsLow = lowHash
|
||||
p.prevGetHdrsHigh = highHash
|
||||
p.prevGetHdrsMtx.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ func (c *Client) GetBlock(blockHash *daghash.Hash, subnetworkID *string) (*wire.
|
||||
type FutureGetBlocksResult chan *response
|
||||
|
||||
// Receive waits for the response promised by the future and returns the blocks
|
||||
// starting from startHash up to the virtual ordered by blue score.
|
||||
// starting from lowHash up to the virtual ordered by blue score.
|
||||
func (r FutureGetBlocksResult) Receive() (*rpcmodel.GetBlocksResult, error) {
|
||||
res, err := receiveFuture(r)
|
||||
if err != nil {
|
||||
@ -135,15 +135,15 @@ func (r FutureGetBlocksResult) Receive() (*rpcmodel.GetBlocksResult, error) {
|
||||
// returned instance.
|
||||
//
|
||||
// See GetBlocks for the blocking version and more details.
|
||||
func (c *Client) GetBlocksAsync(includeRawBlockData bool, IncludeVerboseBlockData bool, startHash *string) FutureGetBlocksResult {
|
||||
cmd := rpcmodel.NewGetBlocksCmd(includeRawBlockData, IncludeVerboseBlockData, startHash)
|
||||
func (c *Client) GetBlocksAsync(includeRawBlockData bool, IncludeVerboseBlockData bool, lowHash *string) FutureGetBlocksResult {
|
||||
cmd := rpcmodel.NewGetBlocksCmd(includeRawBlockData, IncludeVerboseBlockData, lowHash)
|
||||
return c.sendCmd(cmd)
|
||||
}
|
||||
|
||||
// GetBlocks returns the blocks starting from startHash up to the virtual ordered
|
||||
// GetBlocks returns the blocks starting from lowHash up to the virtual ordered
|
||||
// by blue score.
|
||||
func (c *Client) GetBlocks(includeRawBlockData bool, includeVerboseBlockData bool, startHash *string) (*rpcmodel.GetBlocksResult, error) {
|
||||
return c.GetBlocksAsync(includeRawBlockData, includeVerboseBlockData, startHash).Receive()
|
||||
func (c *Client) GetBlocks(includeRawBlockData bool, includeVerboseBlockData bool, lowHash *string) (*rpcmodel.GetBlocksResult, error) {
|
||||
return c.GetBlocksAsync(includeRawBlockData, includeVerboseBlockData, lowHash).Receive()
|
||||
}
|
||||
|
||||
// FutureGetBlockVerboseResult is a future promise to deliver the result of a
|
||||
|
@ -482,24 +482,24 @@ func (c *Client) GetTopHeaders(highHash *daghash.Hash) ([]wire.BlockHeader, erro
|
||||
// of the RPC at some future time by invoking the Receive function on the returned instance.
|
||||
//
|
||||
// See GetHeaders for the blocking version and more details.
|
||||
func (c *Client) GetHeadersAsync(startHash, stopHash *daghash.Hash) FutureGetHeadersResult {
|
||||
startHashStr := ""
|
||||
if startHash != nil {
|
||||
startHashStr = startHash.String()
|
||||
func (c *Client) GetHeadersAsync(lowHash, highHash *daghash.Hash) FutureGetHeadersResult {
|
||||
lowHashStr := ""
|
||||
if lowHash != nil {
|
||||
lowHashStr = lowHash.String()
|
||||
}
|
||||
stopHashStr := ""
|
||||
if stopHash != nil {
|
||||
stopHashStr = stopHash.String()
|
||||
highHashStr := ""
|
||||
if highHash != nil {
|
||||
highHashStr = highHash.String()
|
||||
}
|
||||
cmd := rpcmodel.NewGetHeadersCmd(startHashStr, stopHashStr)
|
||||
cmd := rpcmodel.NewGetHeadersCmd(lowHashStr, highHashStr)
|
||||
return c.sendCmd(cmd)
|
||||
}
|
||||
|
||||
// GetHeaders mimics the wire protocol getheaders and headers messages by
|
||||
// returning all headers in the DAG after the first known block in the
|
||||
// locators, up until a block hash matches stopHash.
|
||||
func (c *Client) GetHeaders(startHash, stopHash *daghash.Hash) ([]wire.BlockHeader, error) {
|
||||
return c.GetHeadersAsync(startHash, stopHash).Receive()
|
||||
// locators, up until a block hash matches highHash.
|
||||
func (c *Client) GetHeaders(lowHash, highHash *daghash.Hash) ([]wire.BlockHeader, error) {
|
||||
return c.GetHeadersAsync(lowHash, highHash).Receive()
|
||||
}
|
||||
|
||||
// FutureSessionResult is a future promise to deliver the result of a
|
||||
|
@ -157,16 +157,16 @@ func NewGetBlockCmd(hash string, verbose, verboseTx *bool, subnetworkID *string)
|
||||
type GetBlocksCmd struct {
|
||||
IncludeRawBlockData bool `json:"includeRawBlockData"`
|
||||
IncludeVerboseBlockData bool `json:"includeVerboseBlockData"`
|
||||
StartHash *string `json:"startHash"`
|
||||
LowHash *string `json:"lowHash"`
|
||||
}
|
||||
|
||||
// NewGetBlocksCmd returns a new instance which can be used to issue a
|
||||
// GetGetBlocks JSON-RPC command.
|
||||
func NewGetBlocksCmd(includeRawBlockData bool, includeVerboseBlockData bool, startHash *string) *GetBlocksCmd {
|
||||
func NewGetBlocksCmd(includeRawBlockData bool, includeVerboseBlockData bool, lowHash *string) *GetBlocksCmd {
|
||||
return &GetBlocksCmd{
|
||||
IncludeRawBlockData: includeRawBlockData,
|
||||
IncludeVerboseBlockData: includeVerboseBlockData,
|
||||
StartHash: startHash,
|
||||
LowHash: lowHash,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ func TestRPCServerCommands(t *testing.T) {
|
||||
unmarshalled: &rpcmodel.GetBlocksCmd{
|
||||
IncludeRawBlockData: true,
|
||||
IncludeVerboseBlockData: true,
|
||||
StartHash: rpcmodel.String("123"),
|
||||
LowHash: rpcmodel.String("123"),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -987,7 +987,7 @@ func TestRPCServerCommands(t *testing.T) {
|
||||
unmarshalled: &rpcmodel.GetTopHeadersCmd{},
|
||||
},
|
||||
{
|
||||
name: "getTopHeaders - with start hash",
|
||||
name: "getTopHeaders - with high hash",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return rpcmodel.NewCommand("getTopHeaders", "000000000000000000ba33b33e1fad70b69e234fc24414dd47113bff38f523f7")
|
||||
},
|
||||
|
@ -16,20 +16,20 @@ const (
|
||||
|
||||
func handleGetBlocks(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
||||
c := cmd.(*rpcmodel.GetBlocksCmd)
|
||||
var startHash *daghash.Hash
|
||||
if c.StartHash != nil {
|
||||
startHash = &daghash.Hash{}
|
||||
err := daghash.Decode(startHash, *c.StartHash)
|
||||
var lowHash *daghash.Hash
|
||||
if c.LowHash != nil {
|
||||
lowHash = &daghash.Hash{}
|
||||
err := daghash.Decode(lowHash, *c.LowHash)
|
||||
if err != nil {
|
||||
return nil, rpcDecodeHexError(*c.StartHash)
|
||||
return nil, rpcDecodeHexError(*c.LowHash)
|
||||
}
|
||||
}
|
||||
|
||||
s.cfg.DAG.RLock()
|
||||
defer s.cfg.DAG.RUnlock()
|
||||
|
||||
// If startHash is not in the DAG, there's nothing to do; return an error.
|
||||
if startHash != nil && !s.cfg.DAG.HaveBlock(startHash) {
|
||||
// If lowHash is not in the DAG, there's nothing to do; return an error.
|
||||
if lowHash != nil && !s.cfg.DAG.HaveBlock(lowHash) {
|
||||
return nil, &rpcmodel.RPCError{
|
||||
Code: rpcmodel.ErrRPCBlockNotFound,
|
||||
Message: "Block not found",
|
||||
@ -37,7 +37,7 @@ func handleGetBlocks(s *Server, cmd interface{}, closeChan <-chan struct{}) (int
|
||||
}
|
||||
|
||||
// Retrieve the block hashes.
|
||||
blockHashes, err := s.cfg.DAG.BlockHashesFrom(startHash, maxBlocksInGetBlocksResult)
|
||||
blockHashes, err := s.cfg.DAG.BlockHashesFrom(lowHash, maxBlocksInGetBlocksResult)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -172,11 +172,11 @@ var helpDescsEnUS = map[string]string{
|
||||
"getBlock--result0": "Hex-encoded bytes of the serialized block",
|
||||
|
||||
// GetBlocksCmd help.
|
||||
"getBlocks--synopsis": "Return the blocks starting from startHash up to the virtual ordered by blue score.",
|
||||
"getBlocks--synopsis": "Return the blocks starting from lowHash up to the virtual ordered by blue score.",
|
||||
"getBlocks-includeRawBlockData": "If set to true - the raw block data would be also included.",
|
||||
"getBlocks-includeVerboseBlockData": "If set to true - the verbose block data would also be included.",
|
||||
"getBlocks-startHash": "Hash of the block with the bottom blue score. If this hash is unknown - returns an error.",
|
||||
"getBlocks--result0": "Blocks starting from startHash. The result may contains up to 1000 blocks. For the remainder, call the command again with the bluest block's hash.",
|
||||
"getBlocks-lowHash": "Hash of the block with the bottom blue score. If this hash is unknown - returns an error.",
|
||||
"getBlocks--result0": "Blocks starting from lowHash. The result may contains up to 1000 blocks. For the remainder, call the command again with the bluest block's hash.",
|
||||
|
||||
// GetChainFromBlockResult help.
|
||||
"getBlocksResult-hashes": "List of hashes from StartHash (excluding StartHash) ordered by smallest blue score to greatest.",
|
||||
@ -393,7 +393,7 @@ var helpDescsEnUS = map[string]string{
|
||||
"infoDagResult-errors": "Any current errors",
|
||||
|
||||
// GetTopHeadersCmd help.
|
||||
"getTopHeaders--synopsis": "Returns the top block headers starting with the provided start hash (not inclusive)",
|
||||
"getTopHeaders--synopsis": "Returns the top block headers starting with the provided high hash (not inclusive)",
|
||||
"getTopHeaders-highHash": "Block hash to start including block headers from; if not found, it'll start from the virtual.",
|
||||
"getTopHeaders--result0": "Serialized block headers of all located blocks, limited to some arbitrary maximum number of hashes (currently 2000, which matches the wire protocol headers message, but this is not guaranteed)",
|
||||
|
||||
|
@ -379,8 +379,8 @@ func BenchmarkWriteBlockHeader(b *testing.B) {
|
||||
func BenchmarkDecodeGetHeaders(b *testing.B) {
|
||||
pver := ProtocolVersion
|
||||
var m MsgGetHeaders
|
||||
m.StartHash = &daghash.Hash{1}
|
||||
m.StopHash = &daghash.Hash{1}
|
||||
m.LowHash = &daghash.Hash{1}
|
||||
m.HighHash = &daghash.Hash{1}
|
||||
|
||||
// Serialize it so the bytes are available to test the decode below.
|
||||
var bb bytes.Buffer
|
||||
|
@ -175,7 +175,7 @@ func TestBlockLocatorWireErrors(t *testing.T) {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
// MsgBlockLocator message with multiple block locators and a stop hash.
|
||||
// MsgBlockLocator message with multiple block locators and a low hash.
|
||||
baseGetBlocks := NewMsgBlockLocator()
|
||||
baseGetBlocks.AddBlockLocatorHash(hashLocator2)
|
||||
baseGetBlocks.AddBlockLocatorHash(hashLocator)
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
|
||||
// MsgGetBlockInvs implements the Message interface and represents a kaspa
|
||||
// getblockinvs message. It is used to request a list of blocks starting after the
|
||||
// start hash and until the stop hash.
|
||||
// low hash and until the high hash.
|
||||
type MsgGetBlockInvs struct {
|
||||
LowHash *daghash.Hash
|
||||
HighHash *daghash.Hash
|
||||
@ -51,7 +51,7 @@ func (msg *MsgGetBlockInvs) Command() string {
|
||||
// MaxPayloadLength returns the maximum length the payload can be for the
|
||||
// receiver. This is part of the Message interface implementation.
|
||||
func (msg *MsgGetBlockInvs) MaxPayloadLength(pver uint32) uint32 {
|
||||
// start hash + stop hash.
|
||||
// low hash + high hash.
|
||||
return 2 * daghash.HashSize
|
||||
}
|
||||
|
||||
|
@ -19,22 +19,22 @@ func TestGetBlockInvs(t *testing.T) {
|
||||
pver := ProtocolVersion
|
||||
|
||||
hashStr := "000000000002e7ad7b9eef9479e4aabc65cb831269cc20d2632c13684406dee0"
|
||||
startHash, err := daghash.NewHashFromStr(hashStr)
|
||||
lowHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
hashStr = "3ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506"
|
||||
stopHash, err := daghash.NewHashFromStr(hashStr)
|
||||
highHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
// Ensure we get the same data back out.
|
||||
msg := NewMsgGetBlockInvs(startHash, stopHash)
|
||||
if !msg.HighHash.IsEqual(stopHash) {
|
||||
t.Errorf("NewMsgGetBlockInvs: wrong stop hash - got %v, want %v",
|
||||
msg.HighHash, stopHash)
|
||||
msg := NewMsgGetBlockInvs(lowHash, highHash)
|
||||
if !msg.HighHash.IsEqual(highHash) {
|
||||
t.Errorf("NewMsgGetBlockInvs: wrong high hash - got %v, want %v",
|
||||
msg.HighHash, highHash)
|
||||
}
|
||||
|
||||
// Ensure the command is expected value.
|
||||
@ -44,7 +44,7 @@ func TestGetBlockInvs(t *testing.T) {
|
||||
cmd, wantCmd)
|
||||
}
|
||||
|
||||
// Ensure max payload is start hash (32 bytes) + stop hash (32 bytes).
|
||||
// Ensure max payload is low hash (32 bytes) + high hash (32 bytes).
|
||||
wantPayload := uint32(64)
|
||||
maxPayload := msg.MaxPayloadLength(pver)
|
||||
if maxPayload != wantPayload {
|
||||
@ -58,41 +58,41 @@ func TestGetBlockInvs(t *testing.T) {
|
||||
// numbers of block locator hashes and protocol versions.
|
||||
func TestGetBlockInvsWire(t *testing.T) {
|
||||
hashStr := "2710f40c87ec93d010a6fd95f42c59a2cbacc60b18cf6b7957535"
|
||||
startHash, err := daghash.NewHashFromStr(hashStr)
|
||||
lowHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
hashStr = "3ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506"
|
||||
stopHash, err := daghash.NewHashFromStr(hashStr)
|
||||
highHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
// MsgGetBlocks message with no start or stop hash.
|
||||
// MsgGetBlocks message with no start or high hash.
|
||||
noStartOrStop := NewMsgGetBlockInvs(&daghash.Hash{}, &daghash.Hash{})
|
||||
noStartOrStopEncoded := []byte{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Start hash
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Low hash
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Stop hash
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // High hash
|
||||
}
|
||||
|
||||
// MsgGetBlockInvs message with a start hash and a stop hash.
|
||||
withStartAndStopHash := NewMsgGetBlockInvs(startHash, stopHash)
|
||||
withStartAndStopHashEncoded := []byte{
|
||||
// MsgGetBlockInvs message with a low hash and a high hash.
|
||||
withLowAndHighHash := NewMsgGetBlockInvs(lowHash, highHash)
|
||||
withLowAndHighHashEncoded := []byte{
|
||||
0x35, 0x75, 0x95, 0xb7, 0xf6, 0x8c, 0xb1, 0x60,
|
||||
0xcc, 0xba, 0x2c, 0x9a, 0xc5, 0x42, 0x5f, 0xd9,
|
||||
0x6f, 0x0a, 0x01, 0x3d, 0xc9, 0x7e, 0xc8, 0x40,
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // Start hash
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // Low hash
|
||||
0x06, 0xe5, 0x33, 0xfd, 0x1a, 0xda, 0x86, 0x39,
|
||||
0x1f, 0x3f, 0x6c, 0x34, 0x32, 0x04, 0xb0, 0xd2,
|
||||
0x78, 0xd4, 0xaa, 0xec, 0x1c, 0x0b, 0x20, 0xaa,
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Stop hash
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // High hash
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@ -111,9 +111,9 @@ func TestGetBlockInvsWire(t *testing.T) {
|
||||
|
||||
// Latest protocol version with multiple block locators.
|
||||
{
|
||||
withStartAndStopHash,
|
||||
withStartAndStopHash,
|
||||
withStartAndStopHashEncoded,
|
||||
withLowAndHighHash,
|
||||
withLowAndHighHash,
|
||||
withLowAndHighHashEncoded,
|
||||
ProtocolVersion,
|
||||
},
|
||||
}
|
||||
@ -156,28 +156,28 @@ func TestGetBlockInvsWireErrors(t *testing.T) {
|
||||
pver := ProtocolVersion
|
||||
|
||||
hashStr := "2710f40c87ec93d010a6fd95f42c59a2cbacc60b18cf6b7957535"
|
||||
startHash, err := daghash.NewHashFromStr(hashStr)
|
||||
lowHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
hashStr = "3ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506"
|
||||
stopHash, err := daghash.NewHashFromStr(hashStr)
|
||||
highHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
// MsgGetBlockInvs message with multiple block locators and a stop hash.
|
||||
baseGetBlocks := NewMsgGetBlockInvs(startHash, stopHash)
|
||||
// MsgGetBlockInvs message with multiple block locators and a high hash.
|
||||
baseGetBlocks := NewMsgGetBlockInvs(lowHash, highHash)
|
||||
baseGetBlocksEncoded := []byte{
|
||||
0x35, 0x75, 0x95, 0xb7, 0xf6, 0x8c, 0xb1, 0x60,
|
||||
0xcc, 0xba, 0x2c, 0x9a, 0xc5, 0x42, 0x5f, 0xd9,
|
||||
0x6f, 0x0a, 0x01, 0x3d, 0xc9, 0x7e, 0xc8, 0x40,
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // Start hash
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // Low hash
|
||||
0x06, 0xe5, 0x33, 0xfd, 0x1a, 0xda, 0x86, 0x39,
|
||||
0x1f, 0x3f, 0x6c, 0x34, 0x32, 0x04, 0xb0, 0xd2,
|
||||
0x78, 0xd4, 0xaa, 0xec, 0x1c, 0x0b, 0x20, 0xaa,
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Stop hash
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // High hash
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@ -188,9 +188,9 @@ func TestGetBlockInvsWireErrors(t *testing.T) {
|
||||
writeErr error // Expected write error
|
||||
readErr error // Expected read error
|
||||
}{
|
||||
// Force error in start hash.
|
||||
// Force error in low hash.
|
||||
{baseGetBlocks, baseGetBlocksEncoded, pver, 0, io.ErrShortWrite, io.EOF},
|
||||
// Force error in stop hash.
|
||||
// Force error in high hash.
|
||||
{baseGetBlocks, baseGetBlocksEncoded, pver, 32, io.ErrShortWrite, io.EOF},
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// MsgGetBlockLocator implements the Message interface and represents a kaspa
|
||||
// getlocator message. It is used to request a block locator between start and stop hash.
|
||||
// getlocator message. It is used to request a block locator between high and low hash.
|
||||
// The locator is returned via a locator message (MsgBlockLocator).
|
||||
type MsgGetBlockLocator struct {
|
||||
HighHash *daghash.Hash
|
||||
|
@ -15,20 +15,20 @@ func TestGetBlockLocator(t *testing.T) {
|
||||
pver := ProtocolVersion
|
||||
|
||||
hashStr := "000000000002e7ad7b9eef9479e4aabc65cb831269cc20d2632c13684406dee0"
|
||||
startHash, err := daghash.NewHashFromStr(hashStr)
|
||||
highHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
// Ensure the command is expected value.
|
||||
wantCmd := "getlocator"
|
||||
msg := NewMsgGetBlockLocator(startHash, &daghash.ZeroHash)
|
||||
msg := NewMsgGetBlockLocator(highHash, &daghash.ZeroHash)
|
||||
if cmd := msg.Command(); cmd != wantCmd {
|
||||
t.Errorf("NewMsgGetBlockLocator: wrong command - got %v want %v",
|
||||
cmd, wantCmd)
|
||||
}
|
||||
|
||||
// Ensure max payload is start hash (32 bytes) + stop hash (32 bytes)..
|
||||
// Ensure max payload is low hash (32 bytes) + high hash (32 bytes)..
|
||||
wantPayload := uint32(64)
|
||||
maxPayload := msg.MaxPayloadLength(pver)
|
||||
if maxPayload != wantPayload {
|
||||
@ -41,41 +41,41 @@ func TestGetBlockLocator(t *testing.T) {
|
||||
// TestGetBlockLocatorWire tests the MsgGetBlockLocator wire encode and decode.
|
||||
func TestGetBlockLocatorWire(t *testing.T) {
|
||||
hashStr := "2710f40c87ec93d010a6fd95f42c59a2cbacc60b18cf6b7957535"
|
||||
startHash, err := daghash.NewHashFromStr(hashStr)
|
||||
highHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
hashStr = "3ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506"
|
||||
stopHash, err := daghash.NewHashFromStr(hashStr)
|
||||
lowHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
// MsgGetBlockLocator message with no block locators or stop hash.
|
||||
noStartAndStopHash := NewMsgGetBlockLocator(&daghash.ZeroHash, &daghash.ZeroHash)
|
||||
noStartAndStopHashEncoded := []byte{
|
||||
// MsgGetBlockLocator message with no block locators or high hash.
|
||||
noLowAndHighHash := NewMsgGetBlockLocator(&daghash.ZeroHash, &daghash.ZeroHash)
|
||||
noLowAndHighHashEncoded := []byte{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Start hash
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // High hash
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Stop hash
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Low hash
|
||||
}
|
||||
|
||||
// MsgGetBlockLocator message with multiple block locators and a stop hash.
|
||||
withStartAndStopHash := NewMsgGetBlockLocator(startHash, stopHash)
|
||||
withStartAndStopHashEncoded := []byte{
|
||||
// MsgGetBlockLocator message with multiple block locators and a high hash.
|
||||
withLowAndHighHash := NewMsgGetBlockLocator(highHash, lowHash)
|
||||
withLowAndHighHashEncoded := []byte{
|
||||
0x35, 0x75, 0x95, 0xb7, 0xf6, 0x8c, 0xb1, 0x60,
|
||||
0xcc, 0xba, 0x2c, 0x9a, 0xc5, 0x42, 0x5f, 0xd9,
|
||||
0x6f, 0x0a, 0x01, 0x3d, 0xc9, 0x7e, 0xc8, 0x40,
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // Start hash
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // High hash
|
||||
0x06, 0xe5, 0x33, 0xfd, 0x1a, 0xda, 0x86, 0x39,
|
||||
0x1f, 0x3f, 0x6c, 0x34, 0x32, 0x04, 0xb0, 0xd2,
|
||||
0x78, 0xd4, 0xaa, 0xec, 0x1c, 0x0b, 0x20, 0xaa,
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Stop hash
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Low hash
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@ -84,19 +84,19 @@ func TestGetBlockLocatorWire(t *testing.T) {
|
||||
buf []byte // Wire encoding
|
||||
pver uint32 // Protocol version for wire encoding
|
||||
}{
|
||||
// Message with no start hash and stop hash.
|
||||
// Message with no low hash and high hash.
|
||||
{
|
||||
noStartAndStopHash,
|
||||
noStartAndStopHash,
|
||||
noStartAndStopHashEncoded,
|
||||
noLowAndHighHash,
|
||||
noLowAndHighHash,
|
||||
noLowAndHighHashEncoded,
|
||||
ProtocolVersion,
|
||||
},
|
||||
|
||||
// Message with start hash and stop hash.
|
||||
// Message with low hash and high hash.
|
||||
{
|
||||
withStartAndStopHash,
|
||||
withStartAndStopHash,
|
||||
withStartAndStopHashEncoded,
|
||||
withLowAndHighHash,
|
||||
withLowAndHighHash,
|
||||
withLowAndHighHashEncoded,
|
||||
ProtocolVersion,
|
||||
},
|
||||
}
|
||||
@ -139,28 +139,28 @@ func TestGetBlockLocatorWireErrors(t *testing.T) {
|
||||
pver := ProtocolVersion
|
||||
|
||||
hashStr := "2710f40c87ec93d010a6fd95f42c59a2cbacc60b18cf6b7957535"
|
||||
startHash, err := daghash.NewHashFromStr(hashStr)
|
||||
highHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
hashStr = "3ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506"
|
||||
stopHash, err := daghash.NewHashFromStr(hashStr)
|
||||
lowHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
// MsgGetBlockLocator message with multiple block locators and a stop hash.
|
||||
baseGetBlockLocator := NewMsgGetBlockLocator(startHash, stopHash)
|
||||
// MsgGetBlockLocator message with multiple block locators and a high hash.
|
||||
baseGetBlockLocator := NewMsgGetBlockLocator(highHash, lowHash)
|
||||
baseGetBlockLocatorEncoded := []byte{
|
||||
0x35, 0x75, 0x95, 0xb7, 0xf6, 0x8c, 0xb1, 0x60,
|
||||
0xcc, 0xba, 0x2c, 0x9a, 0xc5, 0x42, 0x5f, 0xd9,
|
||||
0x6f, 0x0a, 0x01, 0x3d, 0xc9, 0x7e, 0xc8, 0x40,
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // Start hash
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // High hash
|
||||
0x06, 0xe5, 0x33, 0xfd, 0x1a, 0xda, 0x86, 0x39,
|
||||
0x1f, 0x3f, 0x6c, 0x34, 0x32, 0x04, 0xb0, 0xd2,
|
||||
0x78, 0xd4, 0xaa, 0xec, 0x1c, 0x0b, 0x20, 0xaa,
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Stop hash
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Low hash
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@ -171,9 +171,9 @@ func TestGetBlockLocatorWireErrors(t *testing.T) {
|
||||
writeErr error // Expected write error
|
||||
readErr error // Expected read error
|
||||
}{
|
||||
// Force error in start hash.
|
||||
// Force error in low hash.
|
||||
{baseGetBlockLocator, baseGetBlockLocatorEncoded, pver, 0, io.ErrShortWrite, io.EOF},
|
||||
// Force error in stop hash.
|
||||
// Force error in high hash.
|
||||
{baseGetBlockLocator, baseGetBlockLocatorEncoded, pver, 32, io.ErrShortWrite, io.EOF},
|
||||
}
|
||||
|
||||
|
@ -27,32 +27,32 @@ import (
|
||||
// exponentially decrease the number of hashes the further away from head and
|
||||
// closer to the genesis block you get.
|
||||
type MsgGetHeaders struct {
|
||||
StartHash *daghash.Hash
|
||||
StopHash *daghash.Hash
|
||||
LowHash *daghash.Hash
|
||||
HighHash *daghash.Hash
|
||||
}
|
||||
|
||||
// KaspaDecode decodes r using the kaspa protocol encoding into the receiver.
|
||||
// This is part of the Message interface implementation.
|
||||
func (msg *MsgGetHeaders) KaspaDecode(r io.Reader, pver uint32) error {
|
||||
msg.StartHash = &daghash.Hash{}
|
||||
err := ReadElement(r, msg.StartHash)
|
||||
msg.LowHash = &daghash.Hash{}
|
||||
err := ReadElement(r, msg.LowHash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg.StopHash = &daghash.Hash{}
|
||||
return ReadElement(r, msg.StopHash)
|
||||
msg.HighHash = &daghash.Hash{}
|
||||
return ReadElement(r, msg.HighHash)
|
||||
}
|
||||
|
||||
// KaspaEncode encodes the receiver to w using the kaspa protocol encoding.
|
||||
// This is part of the Message interface implementation.
|
||||
func (msg *MsgGetHeaders) KaspaEncode(w io.Writer, pver uint32) error {
|
||||
err := WriteElement(w, msg.StartHash)
|
||||
err := WriteElement(w, msg.LowHash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return WriteElement(w, msg.StopHash)
|
||||
return WriteElement(w, msg.HighHash)
|
||||
}
|
||||
|
||||
// Command returns the protocol command string for the message. This is part
|
||||
@ -64,15 +64,15 @@ func (msg *MsgGetHeaders) Command() string {
|
||||
// MaxPayloadLength returns the maximum length the payload can be for the
|
||||
// receiver. This is part of the Message interface implementation.
|
||||
func (msg *MsgGetHeaders) MaxPayloadLength(pver uint32) uint32 {
|
||||
// start hash + stop hash.
|
||||
// low hash + high hash.
|
||||
return 2 * daghash.HashSize
|
||||
}
|
||||
|
||||
// NewMsgGetHeaders returns a new kaspa getheaders message that conforms to
|
||||
// the Message interface. See MsgGetHeaders for details.
|
||||
func NewMsgGetHeaders(startHash, stopHash *daghash.Hash) *MsgGetHeaders {
|
||||
func NewMsgGetHeaders(lowHash, highHash *daghash.Hash) *MsgGetHeaders {
|
||||
return &MsgGetHeaders{
|
||||
StartHash: startHash,
|
||||
StopHash: stopHash,
|
||||
LowHash: lowHash,
|
||||
HighHash: highHash,
|
||||
}
|
||||
}
|
||||
|
@ -20,20 +20,20 @@ func TestGetHeaders(t *testing.T) {
|
||||
|
||||
// Block 99500 hash.
|
||||
hashStr := "000000000002e7ad7b9eef9479e4aabc65cb831269cc20d2632c13684406dee0"
|
||||
startHash, err := daghash.NewHashFromStr(hashStr)
|
||||
lowHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
// Ensure the command is expected value.
|
||||
wantCmd := "getheaders"
|
||||
msg := NewMsgGetHeaders(startHash, &daghash.ZeroHash)
|
||||
msg := NewMsgGetHeaders(lowHash, &daghash.ZeroHash)
|
||||
if cmd := msg.Command(); cmd != wantCmd {
|
||||
t.Errorf("NewMsgGetHeaders: wrong command - got %v want %v",
|
||||
cmd, wantCmd)
|
||||
}
|
||||
|
||||
// Ensure max payload is start hash (32 bytes) + stop hash (32 bytes)..
|
||||
// Ensure max payload is low hash (32 bytes) + high hash (32 bytes)..
|
||||
wantPayload := uint32(64)
|
||||
maxPayload := msg.MaxPayloadLength(pver)
|
||||
if maxPayload != wantPayload {
|
||||
@ -46,41 +46,41 @@ func TestGetHeaders(t *testing.T) {
|
||||
// TestGetHeadersWire tests the MsgGetHeaders wire encode and decode.
|
||||
func TestGetHeadersWire(t *testing.T) {
|
||||
hashStr := "2710f40c87ec93d010a6fd95f42c59a2cbacc60b18cf6b7957535"
|
||||
startHash, err := daghash.NewHashFromStr(hashStr)
|
||||
lowHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
hashStr = "3ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506"
|
||||
stopHash, err := daghash.NewHashFromStr(hashStr)
|
||||
highHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
// MsgGetHeaders message with no block locators or stop hash.
|
||||
noStartAndStopHash := NewMsgGetHeaders(&daghash.ZeroHash, &daghash.ZeroHash)
|
||||
noStartAndStopHashEncoded := []byte{
|
||||
// MsgGetHeaders message with no block locators or high hash.
|
||||
noLowAndHighHash := NewMsgGetHeaders(&daghash.ZeroHash, &daghash.ZeroHash)
|
||||
noLowAndHighHashEncoded := []byte{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Start hash
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Low hash
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Stop hash
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // High hash
|
||||
}
|
||||
|
||||
// MsgGetHeaders message with multiple block locators and a stop hash.
|
||||
withStartAndStopHash := NewMsgGetHeaders(startHash, stopHash)
|
||||
withStartAndStopHashEncoded := []byte{
|
||||
// MsgGetHeaders message with multiple block locators and a high hash.
|
||||
withLowAndHighHash := NewMsgGetHeaders(lowHash, highHash)
|
||||
withLowAndHighHashEncoded := []byte{
|
||||
0x35, 0x75, 0x95, 0xb7, 0xf6, 0x8c, 0xb1, 0x60,
|
||||
0xcc, 0xba, 0x2c, 0x9a, 0xc5, 0x42, 0x5f, 0xd9,
|
||||
0x6f, 0x0a, 0x01, 0x3d, 0xc9, 0x7e, 0xc8, 0x40,
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // Start hash
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // Low hash
|
||||
0x06, 0xe5, 0x33, 0xfd, 0x1a, 0xda, 0x86, 0x39,
|
||||
0x1f, 0x3f, 0x6c, 0x34, 0x32, 0x04, 0xb0, 0xd2,
|
||||
0x78, 0xd4, 0xaa, 0xec, 0x1c, 0x0b, 0x20, 0xaa,
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Stop hash
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // High hash
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@ -89,19 +89,19 @@ func TestGetHeadersWire(t *testing.T) {
|
||||
buf []byte // Wire encoding
|
||||
pver uint32 // Protocol version for wire encoding
|
||||
}{
|
||||
// Message with no start hash and stop hash.
|
||||
// Message with no low hash and high hash.
|
||||
{
|
||||
noStartAndStopHash,
|
||||
noStartAndStopHash,
|
||||
noStartAndStopHashEncoded,
|
||||
noLowAndHighHash,
|
||||
noLowAndHighHash,
|
||||
noLowAndHighHashEncoded,
|
||||
ProtocolVersion,
|
||||
},
|
||||
|
||||
// Message with start hash and stop hash.
|
||||
// Message with low hash and high hash.
|
||||
{
|
||||
withStartAndStopHash,
|
||||
withStartAndStopHash,
|
||||
withStartAndStopHashEncoded,
|
||||
withLowAndHighHash,
|
||||
withLowAndHighHash,
|
||||
withLowAndHighHashEncoded,
|
||||
ProtocolVersion,
|
||||
},
|
||||
}
|
||||
@ -144,28 +144,28 @@ func TestGetHeadersWireErrors(t *testing.T) {
|
||||
pver := ProtocolVersion
|
||||
|
||||
hashStr := "2710f40c87ec93d010a6fd95f42c59a2cbacc60b18cf6b7957535"
|
||||
startHash, err := daghash.NewHashFromStr(hashStr)
|
||||
lowHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
hashStr = "3ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506"
|
||||
stopHash, err := daghash.NewHashFromStr(hashStr)
|
||||
highHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
}
|
||||
|
||||
// MsgGetHeaders message with multiple block locators and a stop hash.
|
||||
baseGetHeaders := NewMsgGetHeaders(startHash, stopHash)
|
||||
// MsgGetHeaders message with multiple block locators and a high hash.
|
||||
baseGetHeaders := NewMsgGetHeaders(lowHash, highHash)
|
||||
baseGetHeadersEncoded := []byte{
|
||||
0x35, 0x75, 0x95, 0xb7, 0xf6, 0x8c, 0xb1, 0x60,
|
||||
0xcc, 0xba, 0x2c, 0x9a, 0xc5, 0x42, 0x5f, 0xd9,
|
||||
0x6f, 0x0a, 0x01, 0x3d, 0xc9, 0x7e, 0xc8, 0x40,
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // Start hash
|
||||
0x0f, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // Low hash
|
||||
0x06, 0xe5, 0x33, 0xfd, 0x1a, 0xda, 0x86, 0x39,
|
||||
0x1f, 0x3f, 0x6c, 0x34, 0x32, 0x04, 0xb0, 0xd2,
|
||||
0x78, 0xd4, 0xaa, 0xec, 0x1c, 0x0b, 0x20, 0xaa,
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Stop hash
|
||||
0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // High hash
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@ -176,9 +176,9 @@ func TestGetHeadersWireErrors(t *testing.T) {
|
||||
writeErr error // Expected write error
|
||||
readErr error // Expected read error
|
||||
}{
|
||||
// Force error in start hash.
|
||||
// Force error in low hash.
|
||||
{baseGetHeaders, baseGetHeadersEncoded, pver, 0, io.ErrShortWrite, io.EOF},
|
||||
// Force error in stop hash.
|
||||
// Force error in high hash.
|
||||
{baseGetHeaders, baseGetHeadersEncoded, pver, 32, io.ErrShortWrite, io.EOF},
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user