Documentation ¶
Index ¶
Constants ¶
const ( GetAccountRangeMsg = 0x00 AccountRangeMsg = 0x01 GetStorageRangesMsg = 0x02 StorageRangesMsg = 0x03 GetByteCodesMsg = 0x04 ByteCodesMsg = 0x05 GetTrieNodesMsg = 0x06 TrieNodesMsg = 0x07 )
const ProtocolName = "snap"
ProtocolName is the official short name of the `snap` protocol used during devp2p capability negotiation.
const (
SNAP1 = 1
)
Constants to match up protocol versions and messages
Variables ¶
var ProtocolVersions = []uint{SNAP1}
ProtocolVersions are the supported versions of the `snap` protocol (first is primary).
Functions ¶
This section is empty.
Types ¶
type AccountData ¶
type AccountData struct { Hash common.Hash // Hash of the account Body rlp.RawValue // Account body in slim format }
AccountData represents a single account in a query response.
type AccountRangePacket ¶
type AccountRangePacket struct { ID uint64 // ID of the request this is a response for Accounts []*AccountData // List of consecutive accounts from the trie Proof [][]byte // List of trie nodes proving the account range }
AccountRangePacket represents an account query response.
func (*AccountRangePacket) Kind ¶
func (*AccountRangePacket) Kind() byte
func (*AccountRangePacket) Name ¶
func (*AccountRangePacket) Name() string
func (*AccountRangePacket) Unpack ¶
func (p *AccountRangePacket) Unpack() ([]common.Hash, [][]byte, error)
Unpack retrieves the accounts from the range packet and converts from slim wire representation to consensus format. The returned data is RLP encoded since it's expected to be serialized to disk without further interpretation.
Note, this method does a round of RLP decoding and reencoding, so only use it once and cache the results if need be. Ideally discard the packet afterwards to not double the memory use.
type ByteCodesPacket ¶
type ByteCodesPacket struct { ID uint64 // ID of the request this is a response for Codes [][]byte // Requested contract bytecodes }
ByteCodesPacket represents a contract bytecode query response.
func (*ByteCodesPacket) Kind ¶
func (*ByteCodesPacket) Kind() byte
func (*ByteCodesPacket) Name ¶
func (*ByteCodesPacket) Name() string
type GetAccountRangePacket ¶
type GetAccountRangePacket struct { ID uint64 // Request ID to match up responses with Root common.Hash // Root hash of the account trie to serve Origin common.Hash // Hash of the first account to retrieve Limit common.Hash // Hash of the last account to retrieve Bytes uint64 // Soft limit at which to stop returning data }
GetAccountRangePacket represents an account query.
func (*GetAccountRangePacket) Kind ¶
func (*GetAccountRangePacket) Kind() byte
func (*GetAccountRangePacket) Name ¶
func (*GetAccountRangePacket) Name() string
type GetByteCodesPacket ¶
type GetByteCodesPacket struct { ID uint64 // Request ID to match up responses with Hashes []common.Hash // Code hashes to retrieve the code for Bytes uint64 // Soft limit at which to stop returning data }
GetByteCodesPacket represents a contract bytecode query.
func (*GetByteCodesPacket) Kind ¶
func (*GetByteCodesPacket) Kind() byte
func (*GetByteCodesPacket) Name ¶
func (*GetByteCodesPacket) Name() string
type GetStorageRangesPacket ¶
type GetStorageRangesPacket struct { ID uint64 // Request ID to match up responses with Root common.Hash // Root hash of the account trie to serve Accounts []common.Hash // Account hashes of the storage tries to serve Origin []byte // Hash of the first storage slot to retrieve (large contract mode) Limit []byte // Hash of the last storage slot to retrieve (large contract mode) Bytes uint64 // Soft limit at which to stop returning data }
GetStorageRangesPacket represents an storage slot query.
func (*GetStorageRangesPacket) Kind ¶
func (*GetStorageRangesPacket) Kind() byte
func (*GetStorageRangesPacket) Name ¶
func (*GetStorageRangesPacket) Name() string
type GetTrieNodesPacket ¶
type GetTrieNodesPacket struct { ID uint64 // Request ID to match up responses with Root common.Hash // Root hash of the account trie to serve Paths []TrieNodePathSet // Trie node hashes to retrieve the nodes for Bytes uint64 // Soft limit at which to stop returning data }
GetTrieNodesPacket represents a state trie node query.
func (*GetTrieNodesPacket) Kind ¶
func (*GetTrieNodesPacket) Kind() byte
func (*GetTrieNodesPacket) Name ¶
func (*GetTrieNodesPacket) Name() string
type Packet ¶
type Packet interface { Name() string // Name returns a string corresponding to the message type. Kind() byte // Kind returns the message type. }
Packet represents a p2p message in the `snap` protocol.
type StorageData ¶
type StorageData struct { Hash common.Hash // Hash of the storage slot Body []byte // Data content of the slot }
StorageData represents a single storage slot in a query response.
type StorageRangesPacket ¶
type StorageRangesPacket struct { ID uint64 // ID of the request this is a response for Slots [][]*StorageData // Lists of consecutive storage slots for the requested accounts Proof [][]byte // Merkle proofs for the *last* slot range, if it's incomplete }
StorageRangesPacket represents a storage slot query response.
func (*StorageRangesPacket) Kind ¶
func (*StorageRangesPacket) Kind() byte
func (*StorageRangesPacket) Name ¶
func (*StorageRangesPacket) Name() string
type TrieNodePathSet ¶
type TrieNodePathSet [][]byte
TrieNodePathSet is a list of trie node paths to retrieve. A naive way to represent trie nodes would be a simple list of `account || storage` path segments concatenated, but that would be very wasteful on the network.
Instead, this array special cases the first element as the path in the account trie and the remaining elements as paths in the storage trie. To address an account node, the slice should have a length of 1 consisting of only the account path. There's no need to be able to address both an account node and a storage node in the same request as it cannot happen that a slot is accessed before the account path is fully expanded.
type TrieNodesPacket ¶
type TrieNodesPacket struct { ID uint64 // ID of the request this is a response for Nodes [][]byte // Requested state trie nodes }
TrieNodesPacket represents a state trie node query response.
func (*TrieNodesPacket) Kind ¶
func (*TrieNodesPacket) Kind() byte
func (*TrieNodesPacket) Name ¶
func (*TrieNodesPacket) Name() string