bzz

package
v2.7.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: BSD-3-Clause Imports: 14 Imported by: 6

Documentation

Overview

Package bzz exposes the data structure and operations necessary on the bzz.Address type which used in the handshake protocol, address-book and hive protocol.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAddress = errors.New("invalid address")

Functions

func AreUnderlaysEqual added in v2.7.0

func AreUnderlaysEqual(a, b []ma.Multiaddr) bool

func ContainsAddress

func ContainsAddress(addrs []Address, a *Address) bool

ContainsAddress reports whether a is present in addrs.

func DeserializeUnderlays added in v2.7.0

func DeserializeUnderlays(data []byte) ([]multiaddr.Multiaddr, error)

DeserializeUnderlays deserializes a byte slice into a slice of multiaddrs. The data format is automatically detected as either a single legacy multiaddr or a list of multiaddrs (identified by underlayListPrefix), and is parsed accordingly.

func SelectBestAdvertisedAddress added in v2.7.0

func SelectBestAdvertisedAddress(addrs []ma.Multiaddr, fallback ma.Multiaddr) ma.Multiaddr

func SerializeUnderlays added in v2.7.0

func SerializeUnderlays(addrs []multiaddr.Multiaddr) []byte

SerializeUnderlays serializes a slice of multiaddrs into a single byte slice. If the slice contains exactly one address, the standard, backward-compatible multiaddr format is used. For zero or more than one address, a custom list format prefixed with a magic byte is utilized.

Types

type Address

type Address struct {
	Underlays       []ma.Multiaddr
	Overlay         swarm.Address
	Signature       []byte
	Nonce           []byte
	EthereumAddress []byte
}

Address represents the bzz address in swarm. It consists of a peers underlay (physical) address, overlay (topology) address and signature. Signature is used to verify the `Overlay/Underlay` pair, as it is based on `underlay|networkID`, signed with the public key of Overlay address

func NewAddress

func NewAddress(signer crypto.Signer, underlays []ma.Multiaddr, overlay swarm.Address, networkID uint64, nonce []byte) (*Address, error)

func ParseAddress

func ParseAddress(underlay, overlay, signature, nonce []byte, validateOverlay bool, networkID uint64) (*Address, error)

func (*Address) Equal

func (a *Address) Equal(b *Address) bool

func (*Address) MarshalJSON

func (a *Address) MarshalJSON() ([]byte, error)

func (*Address) ShortString

func (a *Address) ShortString() string

ShortString returns shortened versions of bzz address in a format: [Overlay, Underlay] It can be used for logging

func (*Address) String

func (a *Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(b []byte) error

type TransportType added in v2.7.1

type TransportType int

TransportType represents the transport protocol of a multiaddress.

const (
	// TransportUnknown indicates an unrecognized transport.
	TransportUnknown TransportType = iota
	// TransportTCP indicates plain TCP without WebSocket.
	TransportTCP
	// TransportWS indicates WebSocket without TLS.
	TransportWS
	// TransportWSS indicates WebSocket with TLS (secure).
	TransportWSS
)

func ClassifyTransport added in v2.7.1

func ClassifyTransport(addr ma.Multiaddr) TransportType

ClassifyTransport returns the transport type of a multiaddress. It distinguishes between plain TCP, WebSocket (WS), and secure WebSocket (WSS).

func (TransportType) Priority added in v2.7.1

func (t TransportType) Priority() int

Priority returns the sorting priority for the transport type. Lower value = higher priority: TCP (0) > WS (1) > WSS (2) > Unknown (3)

func (TransportType) String added in v2.7.1

func (t TransportType) String() string

String returns a string representation of the transport type.

Jump to

Keyboard shortcuts

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