config

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	CCtx client.Context

	// BootstrapMultiaddrs is the list of bootstrap nodes
	BootstrapMultiaddrs []string

	// Callback is the callback for the motor
	Callback common.NodeCallback

	// RendezvousString is the rendezvous string for the motor
	RendezvousString string

	// GroupIDs is the list of peer ids for the node
	GroupIDs []party.ID

	// SelfPartyID is the party id for the node
	SelfPartyID party.ID

	// PeerType is the type of peer
	PeerType common.PeerType

	// RemoteIPFSURL is the remote IPFS URL
	RemoteIPFSURL string

	// EncryptionKey is the encryption key for the node
	EncryptionKey p2pcrypto.PrivKey

	// EncryptionPrivKeyPath is the encryption key for the node
	EncryptionPrivKeyPath string

	// EncryptionPubKeyPath is the encryption key for the node
	EncryptionPubKeyPath string
}

Config is the configuration for the node

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

func (*Config) Apply

func (c *Config) Apply(opts ...Option) error

Apply applies the options to the configuration

func (*Config) GetCapabilityDelegation

func (c *Config) GetCapabilityDelegation() *types.VerificationMethod

GetCapabilityDelegation returns the capability delegation

func (*Config) IsLocal

func (c *Config) IsLocal() bool

IsLocal returns true if the node is local

func (*Config) IsMotor

func (c *Config) IsMotor() bool

IsMotor returns true if the node is a motor

func (*Config) LoadEncKeys

func (c *Config) LoadEncKeys() (*[32]byte, *[32]byte, error)

LoadEncKeys loads the encryption keys

type IPFSNode

type IPFSNode interface {
	Node

	// Get the IPFS Core API
	CoreAPI() icore.CoreAPI

	// Get the IPFS PubSub API
	GetCapabilityDelegation() *types.VerificationMethod

	// Add a file to the network
	Add(data []byte) (string, error)

	// AddEncrypted adds a file to the network, encrypted with the given public key.
	AddEncrypted(file []byte, pubKey []byte) (string, error)

	// AddPath adds a file to the network
	AddPath(path string) (string, error)

	// Get a file from the network
	Get(hash string) ([]byte, error)

	// GetDecrypted takes a cid and a public key and returns the decrypted file.
	GetDecrypted(cidStr string, pubKey []byte) ([]byte, error)

	// GetPath gets a file from the network
	GetPath(hash string) (map[string]files.Node, error)
}

`IPFSNode` is an interface that defines the methods that a Highway node must implement. @property Add - This is the function that adds a file to the IPFS network. @property {error} Connect - Connects to a peer @property CoreAPI - This is the IPFS Core API. @property Get - Get a file from the network @property {string} MultiAddr - The multiaddr of the node @property PeerID - The peer ID of the node @property GetDecrypted - This is a method that takes a cid and a public key and returns the decrypted file. @property AddEncrypted - Add a file to the network, encrypted with the given public key.

type Node

type Node interface {
	// PeerID returns the peer ID of the node
	PeerID() peer.ID

	// Connect to a peer
	Connect(peers ...string) error

	// MultiAddrs returns the multiaddr of the node
	MultiAddrs() string

	// Close the node
	Close() error
}

`Node` is an interface that defines the methods that a node must implement to be used by the Motor library. @property PeerID - The peer ID of the node. @property {error} Connect - Connect to a peer @property {string} MultiAddrs - The multiaddr of the node @property {error} Close - Close the node

type Option

type Option func(*Config) error

Option is a function that configures a Node

func AddBootstrappers

func AddBootstrappers(bootstrappers []string) Option

AddBootstrappers adds additional nodes to start initial connections with

func WithClientContext

func WithClientContext(cctx client.Context, generate bool) Option

WithEncryptionKeyPath sets the encryption private key for the node from a file

func WithGroupIds

func WithGroupIds(partyIds ...party.ID) Option

WithGroupIds sets the peer ids for the node

func WithNodeCallback

func WithNodeCallback(callback common.NodeCallback) Option

WithNodeCallback sets the callback for the motor

func WithPartyId

func WithPartyId(partyId string) Option

WithPartyId sets the party id for the node. This is to be replaced by the User defined label for the device

func WithPeerType

func WithPeerType(peerType common.PeerType) Option

WithPeerType sets the type of peer

func WithRemoteIPFSURL

func WithRemoteIPFSURL(remoteIPFSURL string) Option

WithRemoteIPFSURL sets the remote IPFS URL

type P2PNode

type P2PNode interface {
	Node

	// NewStream creates a new stream to a peer
	NewStream(to peer.ID, protocol protocol.ID, msg proto.Message) error

	// SetStreamHandler sets the handler for a given protocol
	SetStreamHandler(protocol protocol.ID, handler network.StreamHandler)

	// Publish a message to a topic
	Publish(topic string, message []byte, opts ...ps.TopicOpt) error

	// Subscribe to a topic
	Subscribe(topic string, handlers ...func(msg *ps.Message)) (*ps.Subscription, error)
}

`P2PNode` is an interface that defines the methods that a node must implement to be used by the Motor library. @property PeerID - The peer ID of the node. @property {error} Connect - Connect to a peer @property {string} MultiAddrs - The multiaddresses of the node. @property {error} NewStream - This is the function that allows you to create a new stream to a peer. @property {error} Publish - Publish a message to a topic. @property SetStreamHandler - This is a function that sets the handler for a given protocol. @property Subscribe - Subscribe to a topic. @property {error} Close - Closes the node.

Jump to

Keyboard shortcuts

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