portalwire

package
v0.0.0-...-99ca45c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 43 Imported by: 0

Documentation

Overview

Code generated by fastssz. DO NOT EDIT. Hash: 26a61b12807ff78c64a029acdd5bcb580dfe35b7bfbf8bf04ceebae1a3d5cac1 Version: 0.1.3

Index

Constants

View Source
const (
	TransientOfferRequestKind byte = 0x01
	PersistOfferRequestKind   byte = 0x02
)
View Source
const (
	PING        byte = 0x00
	PONG        byte = 0x01
	FINDNODES   byte = 0x02
	NODES       byte = 0x03
	FINDCONTENT byte = 0x04
	CONTENT     byte = 0x05
	OFFER       byte = 0x06
	ACCEPT      byte = 0x07
)

Message codes for the portal protocol.

View Source
const (
	ContentConnIdSelector byte = 0x00
	ContentRawSelector    byte = 0x01
	ContentEnrsSelector   byte = 0x02
)

Content selectors for the portal protocol.

View Source
const (
	ContentKeysLimit = 64
	// OfferMessageOverhead overhead of content message is a result of 1byte for kind enum, and
	// 4 bytes for offset in ssz serialization
	OfferMessageOverhead = 5

	// PerContentKeyOverhead each key in ContentKeysList has uint32 offset which results in 4 bytes per
	// key overhead when serialized
	PerContentKeyOverhead = 4
)

Variables

View Source
var ContentNotFound = storage.ErrContentNotFound
View Source
var ErrEmptyResp = errors.New("empty resp")
View Source
var ErrNilContentKey = errors.New("content key cannot be nil")
View Source
var MaxDistance = hexutil.MustDecode("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")

Functions

func CollectPortalMetrics

func CollectPortalMetrics(refresh time.Duration, networks []string, dataDir string)

CollectPortalMetrics periodically collects various metrics about system entities.

Types

type Accept

type Accept struct {
	ConnectionId []byte `ssz-size:"2"`
	ContentKeys  []byte `ssz:"bitlist" ssz-max:"64"`
}

Response messages for the portal protocol.

func (*Accept) GetTree

func (a *Accept) GetTree() (*ssz.Node, error)

GetTree ssz hashes the Accept object

func (*Accept) HashTreeRoot

func (a *Accept) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Accept object

func (*Accept) HashTreeRootWith

func (a *Accept) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the Accept object with a hasher

func (*Accept) MarshalSSZ

func (a *Accept) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the Accept object

func (*Accept) MarshalSSZTo

func (a *Accept) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the Accept object to a target array

func (*Accept) SizeSSZ

func (a *Accept) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the Accept object

func (*Accept) UnmarshalSSZ

func (a *Accept) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the Accept object

type ClientTag

type ClientTag string
const Tag ClientTag = "shisui"

func (ClientTag) ENRKey

func (c ClientTag) ENRKey() string

type ConnectionId

type ConnectionId struct {
	Id []byte `ssz-size:"2"`
}

Response messages for the portal protocol.

func (*ConnectionId) GetTree

func (c *ConnectionId) GetTree() (*ssz.Node, error)

GetTree ssz hashes the ConnectionId object

func (*ConnectionId) HashTreeRoot

func (c *ConnectionId) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the ConnectionId object

func (*ConnectionId) HashTreeRootWith

func (c *ConnectionId) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the ConnectionId object with a hasher

func (*ConnectionId) MarshalSSZ

func (c *ConnectionId) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the ConnectionId object

func (*ConnectionId) MarshalSSZTo

func (c *ConnectionId) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the ConnectionId object to a target array

func (*ConnectionId) SizeSSZ

func (c *ConnectionId) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the ConnectionId object

func (*ConnectionId) UnmarshalSSZ

func (c *ConnectionId) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the ConnectionId object

type Content

type Content struct {
	Content []byte `ssz-max:"2048"`
}

Response messages for the portal protocol.

func (*Content) GetTree

func (c *Content) GetTree() (*ssz.Node, error)

GetTree ssz hashes the Content object

func (*Content) HashTreeRoot

func (c *Content) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Content object

func (*Content) HashTreeRootWith

func (c *Content) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the Content object with a hasher

func (*Content) MarshalSSZ

func (c *Content) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the Content object

func (*Content) MarshalSSZTo

func (c *Content) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the Content object to a target array

func (*Content) SizeSSZ

func (c *Content) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the Content object

func (*Content) UnmarshalSSZ

func (c *Content) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the Content object

type ContentElement

type ContentElement struct {
	Node        enode.ID
	ContentKeys [][]byte
	Contents    [][]byte
}

type ContentEntry

type ContentEntry struct {
	ContentKey []byte
	Content    []byte
}

type ContentInfo

type ContentInfo struct {
	Content     string `json:"content"`
	UtpTransfer bool   `json:"utpTransfer"`
}

type ContentInfoResp

type ContentInfoResp struct {
	Content     []byte
	UtpTransfer bool
}

type ContentKV

type ContentKV struct {
	ContentKey []byte
	Content    []byte
}

type DiscV5API

type DiscV5API struct {
	DiscV5 *discover.UDPv5
}

DiscV5API json-rpc spec https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/ethereum/portal-network-specs/assembled-spec/jsonrpc/openrpc.json&uiSchema%5BappBar%5D%5Bui:splitView%5D=false&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false

func NewDiscV5API

func NewDiscV5API(discV5 *discover.UDPv5) *DiscV5API

func (*DiscV5API) AddEnr

func (d *DiscV5API) AddEnr(enr string) (bool, error)

func (*DiscV5API) DeleteEnr

func (d *DiscV5API) DeleteEnr(nodeId string) (bool, error)

func (*DiscV5API) FindNodes

func (d *DiscV5API) FindNodes(enr string, distances []uint) ([]string, error)

func (*DiscV5API) GetEnr

func (d *DiscV5API) GetEnr(nodeId string) (bool, error)

func (*DiscV5API) LookupEnr

func (d *DiscV5API) LookupEnr(nodeId string) (string, error)

func (*DiscV5API) NodeInfo

func (d *DiscV5API) NodeInfo() *NodeInfo

func (*DiscV5API) Ping

func (d *DiscV5API) Ping(enr string) (*DiscV5PongResp, error)

func (*DiscV5API) RecursiveFindNodes

func (d *DiscV5API) RecursiveFindNodes(nodeId string) ([]string, error)

func (*DiscV5API) RoutingTableInfo

func (d *DiscV5API) RoutingTableInfo() *RoutingTableInfo

func (*DiscV5API) TalkReq

func (d *DiscV5API) TalkReq(enr string, protocol string, payload string) (string, error)

type DiscV5PongResp

type DiscV5PongResp struct {
	EnrSeq        uint64 `json:"enrSeq"`
	RecipientIP   string `json:"recipientIP"`
	RecipientPort uint16 `json:"recipientPort"`
}

type Enrs

type Enrs struct {
	Enrs [][]byte `ssz-max:"32,2048"`
}

Response messages for the portal protocol.

func (*Enrs) GetTree

func (e *Enrs) GetTree() (*ssz.Node, error)

GetTree ssz hashes the Enrs object

func (*Enrs) HashTreeRoot

func (e *Enrs) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Enrs object

func (*Enrs) HashTreeRootWith

func (e *Enrs) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the Enrs object with a hasher

func (*Enrs) MarshalSSZ

func (e *Enrs) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the Enrs object

func (*Enrs) MarshalSSZTo

func (e *Enrs) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the Enrs object to a target array

func (*Enrs) SizeSSZ

func (e *Enrs) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the Enrs object

func (*Enrs) UnmarshalSSZ

func (e *Enrs) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the Enrs object

type EnrsResp

type EnrsResp struct {
	Enrs []string `json:"enrs"`
}

type FindContent

type FindContent struct {
	ContentKey []byte `ssz-max:"2048"`
}

Request messages for the portal protocol.

func (*FindContent) GetTree

func (f *FindContent) GetTree() (*ssz.Node, error)

GetTree ssz hashes the FindContent object

func (*FindContent) HashTreeRoot

func (f *FindContent) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the FindContent object

func (*FindContent) HashTreeRootWith

func (f *FindContent) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the FindContent object with a hasher

func (*FindContent) MarshalSSZ

func (f *FindContent) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the FindContent object

func (*FindContent) MarshalSSZTo

func (f *FindContent) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the FindContent object to a target array

func (*FindContent) SizeSSZ

func (f *FindContent) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the FindContent object

func (*FindContent) UnmarshalSSZ

func (f *FindContent) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the FindContent object

type FindNodes

type FindNodes struct {
	Distances [][2]byte `ssz-max:"256,2" ssz-size:"?,2"`
}

Request messages for the portal protocol.

func (*FindNodes) GetTree

func (f *FindNodes) GetTree() (*ssz.Node, error)

GetTree ssz hashes the FindNodes object

func (*FindNodes) HashTreeRoot

func (f *FindNodes) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the FindNodes object

func (*FindNodes) HashTreeRootWith

func (f *FindNodes) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the FindNodes object with a hasher

func (*FindNodes) MarshalSSZ

func (f *FindNodes) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the FindNodes object

func (*FindNodes) MarshalSSZTo

func (f *FindNodes) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the FindNodes object to a target array

func (*FindNodes) SizeSSZ

func (f *FindNodes) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the FindNodes object

func (*FindNodes) UnmarshalSSZ

func (f *FindNodes) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the FindNodes object

type NodeInfo

type NodeInfo struct {
	NodeId string `json:"nodeId"`
	Enr    string `json:"enr"`
	Ip     string `json:"ip"`
}

type NodeMetadata

type NodeMetadata struct {
	Enr      string `json:"enr"`
	Distance string `json:"distance"`
}

type Nodes

type Nodes struct {
	Total uint8
	Enrs  [][]byte `ssz-max:"32,2048"`
}

Response messages for the portal protocol.

func (*Nodes) GetTree

func (n *Nodes) GetTree() (*ssz.Node, error)

GetTree ssz hashes the Nodes object

func (*Nodes) HashTreeRoot

func (n *Nodes) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Nodes object

func (*Nodes) HashTreeRootWith

func (n *Nodes) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the Nodes object with a hasher

func (*Nodes) MarshalSSZ

func (n *Nodes) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the Nodes object

func (*Nodes) MarshalSSZTo

func (n *Nodes) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the Nodes object to a target array

func (*Nodes) SizeSSZ

func (n *Nodes) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the Nodes object

func (*Nodes) UnmarshalSSZ

func (n *Nodes) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the Nodes object

type Offer

type Offer struct {
	ContentKeys [][]byte `ssz-max:"64,2048"`
}

Request messages for the portal protocol.

func (*Offer) GetTree

func (o *Offer) GetTree() (*ssz.Node, error)

GetTree ssz hashes the Offer object

func (*Offer) HashTreeRoot

func (o *Offer) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Offer object

func (*Offer) HashTreeRootWith

func (o *Offer) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the Offer object with a hasher

func (*Offer) MarshalSSZ

func (o *Offer) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the Offer object

func (*Offer) MarshalSSZTo

func (o *Offer) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the Offer object to a target array

func (*Offer) SizeSSZ

func (o *Offer) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the Offer object

func (*Offer) UnmarshalSSZ

func (o *Offer) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the Offer object

type OfferRequest

type OfferRequest struct {
	Kind    byte
	Request interface{}
}

type OfferRequestWithNode

type OfferRequestWithNode struct {
	Request *OfferRequest
	Node    *enode.Node
}

type PersistOfferRequest

type PersistOfferRequest struct {
	ContentKeys [][]byte
}

type Ping

type Ping struct {
	EnrSeq        uint64
	CustomPayload []byte `ssz-max:"2048"`
}

Request messages for the portal protocol.

func (*Ping) GetTree

func (p *Ping) GetTree() (*ssz.Node, error)

GetTree ssz hashes the Ping object

func (*Ping) HashTreeRoot

func (p *Ping) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Ping object

func (*Ping) HashTreeRootWith

func (p *Ping) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the Ping object with a hasher

func (*Ping) MarshalSSZ

func (p *Ping) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the Ping object

func (*Ping) MarshalSSZTo

func (p *Ping) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the Ping object to a target array

func (*Ping) SizeSSZ

func (p *Ping) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the Ping object

func (*Ping) UnmarshalSSZ

func (p *Ping) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the Ping object

type PingPongCustomData

type PingPongCustomData struct {
	Radius []byte `ssz-size:"32"`
}

Request messages for the portal protocol.

func (*PingPongCustomData) GetTree

func (p *PingPongCustomData) GetTree() (*ssz.Node, error)

GetTree ssz hashes the PingPongCustomData object

func (*PingPongCustomData) HashTreeRoot

func (p *PingPongCustomData) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the PingPongCustomData object

func (*PingPongCustomData) HashTreeRootWith

func (p *PingPongCustomData) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the PingPongCustomData object with a hasher

func (*PingPongCustomData) MarshalSSZ

func (p *PingPongCustomData) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the PingPongCustomData object

func (*PingPongCustomData) MarshalSSZTo

func (p *PingPongCustomData) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the PingPongCustomData object to a target array

func (*PingPongCustomData) SizeSSZ

func (p *PingPongCustomData) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the PingPongCustomData object

func (*PingPongCustomData) UnmarshalSSZ

func (p *PingPongCustomData) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the PingPongCustomData object

type Pong

type Pong struct {
	EnrSeq        uint64
	CustomPayload []byte `ssz-max:"2048"`
}

Response messages for the portal protocol.

func (*Pong) GetTree

func (p *Pong) GetTree() (*ssz.Node, error)

GetTree ssz hashes the Pong object

func (*Pong) HashTreeRoot

func (p *Pong) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the Pong object

func (*Pong) HashTreeRootWith

func (p *Pong) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the Pong object with a hasher

func (*Pong) MarshalSSZ

func (p *Pong) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the Pong object

func (*Pong) MarshalSSZTo

func (p *Pong) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the Pong object to a target array

func (*Pong) SizeSSZ

func (p *Pong) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the Pong object

func (*Pong) UnmarshalSSZ

func (p *Pong) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the Pong object

type PortalPongResp

type PortalPongResp struct {
	EnrSeq     uint32 `json:"enrSeq"`
	DataRadius string `json:"dataRadius"`
}

type PortalProtocol

type PortalProtocol struct {
	DiscV5 *discover.UDPv5

	Log            log.Logger
	PrivateKey     *ecdsa.PrivateKey
	NetRestrict    *netutil.Netlist
	BootstrapNodes []*enode.Node

	Utp *PortalUtp

	NAT nat.Interface
	// contains filtered or unexported fields
}

func NewPortalProtocol

func NewPortalProtocol(config *PortalProtocolConfig, protocolId ProtocolId, privateKey *ecdsa.PrivateKey, conn discover.UDPConn, localNode *enode.LocalNode, discV5 *discover.UDPv5, utp *PortalUtp, storage storage.ContentStorage, contentQueue chan *ContentElement, opts ...PortalProtocolOption) (*PortalProtocol, error)

func (*PortalProtocol) AddEnr

func (p *PortalProtocol) AddEnr(n *enode.Node)

func (*PortalProtocol) ContentLookup

func (p *PortalProtocol) ContentLookup(contentKey, contentId []byte) ([]byte, bool, error)

func (*PortalProtocol) Distance

func (p *PortalProtocol) Distance(a, b enode.ID) enode.ID

func (*PortalProtocol) Get

func (p *PortalProtocol) Get(contentKey []byte, contentId []byte) ([]byte, error)

func (*PortalProtocol) GetContent

func (p *PortalProtocol) GetContent() chan *ContentElement

func (*PortalProtocol) Gossip

func (p *PortalProtocol) Gossip(srcNodeId *enode.ID, contentKeys [][]byte, content [][]byte) (int, error)

func (*PortalProtocol) InRange

func (p *PortalProtocol) InRange(contentId []byte) bool

func (*PortalProtocol) Lookup

func (p *PortalProtocol) Lookup(target enode.ID) []*enode.Node

Lookup performs a recursive lookup for the given target. It returns the closest nodes to target.

func (*PortalProtocol) LookupRandom

func (p *PortalProtocol) LookupRandom() []*enode.Node

LookupRandom looks up a random target. This is needed to satisfy the transport interface.

func (*PortalProtocol) LookupSelf

func (p *PortalProtocol) LookupSelf() []*enode.Node

LookupSelf looks up our own node ID. This is needed to satisfy the transport interface.

func (*PortalProtocol) Ping

func (p *PortalProtocol) Ping(node *enode.Node) (uint64, error)

func (*PortalProtocol) Put

func (p *PortalProtocol) Put(contentKey []byte, contentId []byte, content []byte) error

func (*PortalProtocol) Radius

func (p *PortalProtocol) Radius() *uint256.Int

func (*PortalProtocol) RequestENR

func (p *PortalProtocol) RequestENR(n *enode.Node) (*enode.Node, error)

func (*PortalProtocol) Resolve

func (p *PortalProtocol) Resolve(n *enode.Node) *enode.Node

Resolve searches for a specific Node with the given ID and tries to get the most recent version of the Node record for it. It returns n if the Node could not be resolved.

func (*PortalProtocol) ResolveNodeId

func (p *PortalProtocol) ResolveNodeId(id enode.ID) *enode.Node

ResolveNodeId searches for a specific Node with the given ID. It returns nil if the nodeId could not be resolved.

func (*PortalProtocol) RoutingTableInfo

func (p *PortalProtocol) RoutingTableInfo() [][]string

func (*PortalProtocol) Self

func (p *PortalProtocol) Self() *enode.Node

func (*PortalProtocol) Start

func (p *PortalProtocol) Start() error

func (*PortalProtocol) Stop

func (p *PortalProtocol) Stop()

func (*PortalProtocol) ToContentId

func (p *PortalProtocol) ToContentId(contentKey []byte) []byte

func (*PortalProtocol) TraceContentLookup

func (p *PortalProtocol) TraceContentLookup(contentKey, contentId []byte) (*TraceContentResult, error)

type PortalProtocolAPI

type PortalProtocolAPI struct {
	// contains filtered or unexported fields
}

func NewPortalAPI

func NewPortalAPI(portalProtocol *PortalProtocol) *PortalProtocolAPI

func (*PortalProtocolAPI) AddEnr

func (p *PortalProtocolAPI) AddEnr(enr string) (bool, error)

func (*PortalProtocolAPI) AddEnrs

func (p *PortalProtocolAPI) AddEnrs(enrs []string) bool

func (*PortalProtocolAPI) DeleteEnr

func (p *PortalProtocolAPI) DeleteEnr(nodeId string) (bool, error)

func (*PortalProtocolAPI) FindContent

func (p *PortalProtocolAPI) FindContent(enr string, contentKey string) (interface{}, error)

func (*PortalProtocolAPI) FindNodes

func (p *PortalProtocolAPI) FindNodes(enr string, distances []uint) ([]string, error)

func (*PortalProtocolAPI) GetEnr

func (p *PortalProtocolAPI) GetEnr(nodeId string) (string, error)

func (*PortalProtocolAPI) Gossip

func (p *PortalProtocolAPI) Gossip(contentKeyHex, contentHex string) (int, error)

func (*PortalProtocolAPI) LocalContent

func (p *PortalProtocolAPI) LocalContent(contentKeyHex string) (string, error)

func (*PortalProtocolAPI) LookupEnr

func (p *PortalProtocolAPI) LookupEnr(nodeId string) (string, error)

func (*PortalProtocolAPI) NodeInfo

func (p *PortalProtocolAPI) NodeInfo() *NodeInfo

func (*PortalProtocolAPI) Offer

func (p *PortalProtocolAPI) Offer(enr string, contentItems [][2]string) (string, error)

func (*PortalProtocolAPI) Ping

func (p *PortalProtocolAPI) Ping(enr string) (*PortalPongResp, error)

func (*PortalProtocolAPI) RecursiveFindContent

func (p *PortalProtocolAPI) RecursiveFindContent(contentKeyHex string) (*ContentInfo, error)

func (*PortalProtocolAPI) RecursiveFindNodes

func (p *PortalProtocolAPI) RecursiveFindNodes(nodeId string) ([]string, error)

func (*PortalProtocolAPI) RoutingTableInfo

func (p *PortalProtocolAPI) RoutingTableInfo() *RoutingTableInfo

func (*PortalProtocolAPI) Store

func (p *PortalProtocolAPI) Store(contentKeyHex string, contextHex string) (bool, error)

func (*PortalProtocolAPI) TraceRecursiveFindContent

func (p *PortalProtocolAPI) TraceRecursiveFindContent(contentKeyHex string) (*TraceContentResult, error)

type PortalProtocolConfig

type PortalProtocolConfig struct {
	BootstrapNodes  []*enode.Node
	ListenAddr      string
	NetRestrict     *netutil.Netlist
	NodeRadius      *uint256.Int
	RadiusCacheSize int
	NodeDBPath      string
	NAT             nat.Interface
	// contains filtered or unexported fields
}

func DefaultPortalProtocolConfig

func DefaultPortalProtocolConfig() *PortalProtocolConfig

type PortalProtocolOption

type PortalProtocolOption func(p *PortalProtocol)

type PortalStorageMetrics

type PortalStorageMetrics struct {
	RadiusRatio         metrics.GaugeFloat64
	EntriesCount        metrics.Gauge
	ContentStorageUsage metrics.Gauge
}

func NewPortalStorageMetrics

func NewPortalStorageMetrics(network string, db *sql.DB) (*PortalStorageMetrics, error)

type PortalUtp

type PortalUtp struct {
	ListenAddr string
	// contains filtered or unexported fields
}

func NewPortalUtp

func NewPortalUtp(ctx context.Context, config *PortalProtocolConfig, discV5 *discover.UDPv5, conn discover.UDPConn) *PortalUtp

func (*PortalUtp) Accept

func (p *PortalUtp) Accept(ctx context.Context) (*utp.Conn, error)

func (*PortalUtp) AcceptWithCid

func (p *PortalUtp) AcceptWithCid(ctx context.Context, nodeId enode.ID, cid *libutp.ConnId) (*utp.Conn, error)

func (*PortalUtp) Dial

func (p *PortalUtp) Dial(ctx context.Context, dest *enode.Node) (net.Conn, error)

func (*PortalUtp) DialWithCid

func (p *PortalUtp) DialWithCid(ctx context.Context, dest *enode.Node, connId uint16) (net.Conn, error)

func (*PortalUtp) Start

func (p *PortalUtp) Start() error

func (*PortalUtp) Stop

func (p *PortalUtp) Stop()

type ProtocolId

type ProtocolId []byte
var (
	State             ProtocolId = []byte{0x50, 0x0A}
	History           ProtocolId = []byte{0x50, 0x0B}
	Beacon            ProtocolId = []byte{0x50, 0x0C}
	CanonicalIndices  ProtocolId = []byte{0x50, 0x0D}
	VerkleState       ProtocolId = []byte{0x50, 0x0E}
	TransactionGossip ProtocolId = []byte{0x50, 0x0F}
	Utp               ProtocolId = []byte{0x75, 0x74, 0x70}
)

func (ProtocolId) Name

func (p ProtocolId) Name() string

type RespByNode

type RespByNode struct {
	DurationMs    int32    `json:"durationMs"`
	RespondedWith []string `json:"respondedWith"`
}

type RoutingTableInfo

type RoutingTableInfo struct {
	Buckets     [][]string `json:"buckets"`
	LocalNodeId string     `json:"localNodeId"`
}

type Trace

type Trace struct {
	Origin       string                   `json:"origin"`       // local node id
	TargetId     string                   `json:"targetId"`     // target content id
	ReceivedFrom string                   `json:"receivedFrom"` // the node id of which content from
	Responses    map[string]RespByNode    `json:"responses"`    // the node id and there response nodeIds
	Metadata     map[string]*NodeMetadata `json:"metadata"`     // node id and there metadata object
	StartedAtMs  int                      `json:"startedAtMs"`  // timestamp of the beginning of this request in milliseconds
	Cancelled    []string                 `json:"cancelled"`    // the node ids which are send but cancelled
}

type TraceContentResult

type TraceContentResult struct {
	Content     string `json:"content"`
	UtpTransfer bool   `json:"utpTransfer"`
	Trace       Trace  `json:"trace"`
}

type TransientOfferRequest

type TransientOfferRequest struct {
	Contents []*ContentEntry
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL