|
|
@ -307,19 +307,19 @@ func (hn *hashOrNumber) EncodeRLP(w io.Writer) error { |
|
|
|
// DecodeRLP is a specialized decoder for hashOrNumber to decode the contents
|
|
|
|
// DecodeRLP is a specialized decoder for hashOrNumber to decode the contents
|
|
|
|
// into either a block hash or a block number.
|
|
|
|
// into either a block hash or a block number.
|
|
|
|
func (hn *hashOrNumber) DecodeRLP(s *rlp.Stream) error { |
|
|
|
func (hn *hashOrNumber) DecodeRLP(s *rlp.Stream) error { |
|
|
|
_, size, _ := s.Kind() |
|
|
|
_, size, err := s.Kind() |
|
|
|
origin, err := s.Raw() |
|
|
|
switch { |
|
|
|
if err == nil { |
|
|
|
case err != nil: |
|
|
|
switch { |
|
|
|
return err |
|
|
|
case size == 32: |
|
|
|
case size == 32: |
|
|
|
err = rlp.DecodeBytes(origin, &hn.Hash) |
|
|
|
hn.Number = 0 |
|
|
|
case size <= 8: |
|
|
|
return s.Decode(&hn.Hash) |
|
|
|
err = rlp.DecodeBytes(origin, &hn.Number) |
|
|
|
case size <= 8: |
|
|
|
default: |
|
|
|
hn.Hash = common.Hash{} |
|
|
|
err = fmt.Errorf("invalid input size %d for origin", size) |
|
|
|
return s.Decode(&hn.Number) |
|
|
|
} |
|
|
|
default: |
|
|
|
|
|
|
|
return fmt.Errorf("invalid input size %d for origin", size) |
|
|
|
} |
|
|
|
} |
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// CodeData is the network response packet for a node data retrieval.
|
|
|
|
// CodeData is the network response packet for a node data retrieval.
|
|
|
|