Documentation
¶
Index ¶
- Variables
- func DiscoveryService(s ...ServiceDiscovery) func(cfg *Config) error
- func ExchangeKeys(s string) func(cfg *Config) error
- func FromBase64(enablemDNS, enableDHT bool, bb string, d *discovery.DHT, m *discovery.MDNS) func(cfg *Config) error
- func FromYaml(enablemDNS, enableDHT bool, path string, d *discovery.DHT, m *discovery.MDNS) func(cfg *Config) error
- func GenPrivKey(seed int64) (crypto.PrivKey, error)
- func GenericChannelHandlers(h ...Handler) func(cfg *Config) error
- func Handlers(h ...Handler) func(cfg *Config) error
- func Insecure(b bool) func(cfg *Config) error
- func LibP2PLogLevel(l log.LogLevel) func(cfg *Config) error
- func ListenAddresses(ss ...string) func(cfg *Config) error
- func Logger(l log.StandardLogger) func(cfg *Config) error
- func MaxMessageSize(i int) func(cfg *Config) error
- func RoomName(s string) func(cfg *Config) error
- func SealKeyInterval(i int) func(cfg *Config) error
- func SealKeyLength(i int) func(cfg *Config) error
- func WithBlacklist(i ...string) func(cfg *Config) error
- func WithDiscoveryBootstrapPeers(a discovery.AddrList) func(cfg *Config) error
- func WithDiscoveryInterval(t time.Duration) func(cfg *Config) error
- func WithInterfaceAddress(i string) func(cfg *Config) error
- func WithLedgerAnnounceTime(t time.Duration) func(cfg *Config) error
- func WithLedgerInterval(t time.Duration) func(cfg *Config) error
- func WithLibp2pAdditionalOptions(i ...libp2p.Option) func(cfg *Config) error
- func WithLibp2pOptions(i ...libp2p.Option) func(cfg *Config) error
- func WithNetworkService(ns ...NetworkService) func(cfg *Config) error
- func WithPrivKey(b []byte) func(cfg *Config) error
- func WithStaticPeer(ip string, p peer.ID) func(cfg *Config) error
- func WithStore(s blockchain.Store) func(cfg *Config) error
- func WithStreamHandler(id protocol.Protocol, h StreamHandler) func(cfg *Config) error
- type Config
- type Gater
- type Handler
- type NetworkService
- type Node
- func (e *Node) BlockSubnet(cidr string) error
- func (e *Node) ConnectionGater() *conngater.BasicConnectionGater
- func (e *Node) Host() host.Host
- func (e *Node) Ledger() (*blockchain.Ledger, error)
- func (e *Node) PeerGater() Gater
- func (e *Node) PublishMessage(m *hub.Message) error
- func (e *Node) Start(ctx context.Context) error
- type OTP
- type OTPConfig
- type Option
- type Sealer
- type ServiceDiscovery
- type StreamHandler
- type YAMLConnectionConfig
Constants ¶
This section is empty.
Variables ¶
var EnableGenericHub = func(cfg *Config) error { cfg.GenericHub = true return nil }
EnableGenericHub enables an additional generic hub between peers. This can be used to exchange messages between peers that are not related to any blockchain event. For instance, messages could be used for authentication, or for other sort of application.
var FallbackDefaults libp2p.Option = func(cfg *libp2p.Config) error { for _, def := range defaults { if !def.fallback(cfg) { continue } if err := cfg.Apply(def.opt); err != nil { return err } } return nil }
FallbackDefaults applies default options to the libp2p node if and only if no other relevant options have been applied. will be appended to the options passed into New.
Functions ¶
func DiscoveryService ¶
func DiscoveryService(s ...ServiceDiscovery) func(cfg *Config) error
DiscoveryService Adds the service given as argument to the discovery services
func ExchangeKeys ¶
func FromBase64 ¶
func GenericChannelHandlers ¶ added in v0.13.0
GenericChannelHandlers adds a handler to the list that is called on each received message in the generic channel (not the one allocated for the blockchain)
func ListenAddresses ¶
func MaxMessageSize ¶
func SealKeyInterval ¶
func SealKeyLength ¶
func WithBlacklist ¶ added in v0.8.4
func WithInterfaceAddress ¶
func WithLibp2pOptions ¶
WithLibp2pOptions Overrides defaults options
func WithNetworkService ¶
func WithNetworkService(ns ...NetworkService) func(cfg *Config) error
func WithPrivKey ¶ added in v0.19.1
func WithStaticPeer ¶ added in v0.19.1
func WithStreamHandler ¶
func WithStreamHandler(id protocol.Protocol, h StreamHandler) func(cfg *Config) error
WithStreamHandler adds a handler to the list that is called on each received message
Types ¶
type Config ¶
type Config struct {
// ExchangeKey is a Symmetric key used to seal the messages
ExchangeKey string
// RoomName is the OTP token gossip room where all peers are subscribed to
RoomName string
// ListenAddresses is the discovery peer initial bootstrap addresses
ListenAddresses []discovery.AddrList
// Insecure disables secure p2p e2e encrypted communication
Insecure bool
// Handlers are a list of handlers subscribed to messages received by the vpn interface
Handlers, GenericChannelHandler []Handler
MaxMessageSize int
SealKeyInterval int
ServiceDiscovery []ServiceDiscovery
NetworkServices []NetworkService
Logger log.StandardLogger
SealKeyLength int
InterfaceAddress string
Store blockchain.Store
// Handle is a handle consumed by HumanInterfaces to handle received messages
Handle func(bool, *hub.Message)
StreamHandlers map[protocol.Protocol]StreamHandler
AdditionalOptions, Options []libp2p.Option
DiscoveryInterval, LedgerSyncronizationTime, LedgerAnnounceTime time.Duration
DiscoveryBootstrapPeers discovery.AddrList
Whitelist, Blacklist []string
// GenericHub enables generic hub
GenericHub bool
PrivateKey []byte
PeerTable map[string]peer.ID
Sealer Sealer
PeerGater Gater
}
Config is the node configuration
type NetworkService ¶
NetworkService is a service running over the network. It takes a context, a node and a ledger
type Node ¶
type Node struct {
MessageHub *hub.MessageHub
sync.Mutex
// contains filtered or unexported fields
}
func (*Node) BlockSubnet ¶ added in v0.8.4
BlockSubnet blocks the CIDR subnet from connections
func (*Node) ConnectionGater ¶ added in v0.8.4
func (e *Node) ConnectionGater() *conngater.BasicConnectionGater
ConnectionGater returns the underlying libp2p conngater
func (*Node) Ledger ¶
func (e *Node) Ledger() (*blockchain.Ledger, error)
Ledger return the ledger which uses the node connection to broadcast messages
func (*Node) PublishMessage ¶ added in v0.13.0
PublishMessage publishes a message to the generic channel (if enabled) See GenericChannelHandlers(..) to attach handlers to receive messages from this channel.
type ServiceDiscovery ¶
type StreamHandler ¶ added in v0.7.2
type StreamHandler func(*Node, *blockchain.Ledger) func(stream network.Stream)
type YAMLConnectionConfig ¶
type YAMLConnectionConfig struct {
OTP OTP `yaml:"otp"`
RoomName string `yaml:"room"`
Rendezvous string `yaml:"rendezvous"`
MDNS string `yaml:"mdns"`
MaxMessageSize int `yaml:"max_message_size"`
}
func GenerateNewConnectionData ¶
func GenerateNewConnectionData(i ...int) *YAMLConnectionConfig
func (YAMLConnectionConfig) Base64 ¶
func (y YAMLConnectionConfig) Base64() string
Base64 returns the base64 string representation of the connection
func (YAMLConnectionConfig) YAML ¶
func (y YAMLConnectionConfig) YAML() string
YAML returns the connection config as yaml string