Documentation
¶
Index ¶
- Constants
- Variables
- func WithBee260Compatibility(yes bool) func(*Option)
- type Addresser
- type AdvertisableAddressResolver
- type Info
- type Option
- type Service
- func (s *Service) GetWelcomeMessage() string
- func (s *Service) Handle(ctx context.Context, stream p2p.Stream, peerMultiaddrs []ma.Multiaddr, ...) (i *Info, err error)
- func (s *Service) Handshake(ctx context.Context, stream p2p.Stream, peerMultiaddrs []ma.Multiaddr, ...) (i *Info, err error)
- func (s *Service) Metrics() []prometheus.Collector
- func (s *Service) SetChequebookAddress(addr common.Address)
- func (s *Service) SetPicker(n p2p.Picker)
- func (s *Service) SetWelcomeMessage(msg string) (err error)
Constants ¶
const ( // ProtocolName is the text of the name of the handshake protocol. ProtocolName = "handshake" // ProtocolVersion is the current handshake protocol version. ProtocolVersion = "15.0.0" // StreamName is the name of the stream used for handshake purposes. StreamName = "handshake" // MaxWelcomeMessageLength is maximum number of characters allowed in the welcome message. MaxWelcomeMessageLength = 140 )
Variables ¶
var ( // ErrNetworkIDIncompatible is returned if response from the other peer does not have valid networkID. ErrNetworkIDIncompatible = errors.New("incompatible network ID") // ErrInvalidAck is returned if data in received in ack is not valid (invalid signature for example). ErrInvalidAck = errors.New("invalid ack") // ErrInvalidSyn is returned if observable address in ack is not a valid.. ErrInvalidSyn = errors.New("invalid syn") // ErrWelcomeMessageLength is returned if the welcome message is longer than the maximum length ErrWelcomeMessageLength = fmt.Errorf("handshake welcome message longer than maximum of %d characters", MaxWelcomeMessageLength) // ErrPicker is returned if the picker (kademlia) rejects the peer ErrPicker = errors.New("picker rejection") )
Functions ¶
func WithBee260Compatibility ¶ added in v2.7.0
WithBee260Compatibility option ensures that only one underlay address is passed to the peer in p2p protocol messages, so that nodes with version 2.6.0 and older can deserialize it. This option can be safely removed when bee version 2.6.0 is deprecated.
Types ¶
type AdvertisableAddressResolver ¶
type AdvertisableAddressResolver interface {
Resolve(observedAddress ma.Multiaddr) (ma.Multiaddr, error)
}
AdvertisableAddressResolver can Resolve a Multiaddress.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service can perform initiate or handle a handshake between peers.
func New ¶
func New(signer crypto.Signer, advertisableAddresser AdvertisableAddressResolver, overlay swarm.Address, networkID uint64, fullNode bool, nonce []byte, hostAddresser Addresser, welcomeMessage string, addrbook addressbook.Getter, ownPeerID libp2ppeer.ID, chequebookVerifier chequebook.Verifier, logger log.Logger) (*Service, error)
New creates a new handshake Service. A nil chequebookVerifier disables the chequebook gate; otherwise handshake completion requires the peer's chequebook to pass verification.
func (*Service) GetWelcomeMessage ¶
GetWelcomeMessage returns the current handshake welcome message.
func (*Service) Handle ¶
func (s *Service) Handle(ctx context.Context, stream p2p.Stream, peerMultiaddrs []ma.Multiaddr, opts ...func(*Option)) (i *Info, err error)
Handle handles an incoming handshake from a peer.
func (*Service) Handshake ¶
func (s *Service) Handshake(ctx context.Context, stream p2p.Stream, peerMultiaddrs []ma.Multiaddr, opts ...func(*Option)) (i *Info, err error)
Handshake initiates a handshake with a peer.
func (*Service) Metrics ¶
func (s *Service) Metrics() []prometheus.Collector
Metrics returns set of prometheus collectors.
func (*Service) SetChequebookAddress ¶ added in v2.8.0
SetChequebookAddress sets the local chequebook address included in subsequent signed BzzAddress payloads. The zero value clears it.
func (*Service) SetWelcomeMessage ¶
SetWelcomeMessage sets the new handshake welcome message.