Documentation
¶
Index ¶
Constants ¶
const (
// CURRENT_CHAIN_ID is the current chain ID.
CURRENT_CHAIN_ID = "sonrdevnet-1"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Context *Context
// Callback is the callback for the motor
Callback NodeCallback
// GroupIDs is the list of peer ids for the node
GroupIDs []party.ID
// SelfPartyID is the party id for the node
SelfPartyID party.ID
}
Config is the configuration for the node
func DefaultConfig ¶
DefaultConfig returns the default configuration
type Context ¶ added in v0.6.0
type Context struct {
Ctx context.Context
ClientContext client.Context
HomeDir string
RepoPath string
NodeRESTUri string
NodeGRPCUri string
NodeFaucetUri string
Rendevouz string
BsMultiaddrs []string
// contains filtered or unexported fields
}
`Context` is a struct that contains the information needed to run the `go-ipfs` node. @property {string} HomeDir - The home directory of the user running the application. @property {string} RepoPath - The path to the IPFS repo. @property {string} NodeRESTUri - The REST endpoint of the node. @property {string} NodeGRPCUri - The GRPC endpoint of the node. @property {string} NodeFaucetUri - The URI of the faucet service. @property {string} Rendevouz - The rendevouz point for the swarm. @property {[]string} BsMultiaddrs - The bootstrap multiaddrs. @property encPubKey - The public key of the encryption key pair. @property encPrivKey - The private key used to encrypt the data.
func NewContext ¶ added in v0.6.0
NewContext creates a new context object, initializes the encryption keys, and returns the context object
func (*Context) DecryptMessage ¶
The recipient can decrypt the message using their private key and the sender's public key. When you decrypt, you must use the same nonce you used to encrypt the message. One way to achieve this is to store the nonce alongside the encrypted message. Above, we stored the nonce in the first 24 bytes of the encrypted text.
func (*Context) EncryptMessage ¶
Write encrypts a message using the box algorithm This encrypts msg and appends the result to the nonce.
type IPFSNode ¶
type IPFSNode interface {
Node
// Get the IPFS Core API
CoreAPI() icore.CoreAPI
// Add a file to the network
Add(data []byte) (string, error)
// AddEncrypted adds a file to the network, encrypted with the given public key.
Encrypt(file []byte, pubKey []byte) []byte
// 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.
Decrypt(bz []byte, pubKey []byte) ([]byte, bool)
// GetPath gets a file from the network
GetPath(hash string) (map[string]files.Node, error)
// It's returning a DocumentStore for the given username.
LoadDocsStore(username string) (iface.DocumentStore, error)
// It's returning a DocumentStore for the given username.
LoadEventLogStore(username string) (iface.EventLogStore, error)
// It's returning a KeyValueStore for the given username.
LoadKeyValueStore(username string) (iface.KeyValueStore, 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 {
// Context returns protocol.Context
Context() *Context
WrapClientContext(c client.Context) *Context
// 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 NodeCallback ¶ added in v0.6.0
NodeCallback is an interface with three methods: OnDiscover, OnLinking, and OnTopicMessage. @property OnDiscover - This is called when a node is discovered. The data is the data that was sent by the node. @property OnLinking - This is called when a node is linking to the gateway. @property OnTopicMessage - This is the callback that will be called when a message is received on a topic.
func DefaultCallback ¶ added in v0.6.0
func DefaultCallback() NodeCallback
It returns a pointer to a defaultCallback struct
type Option ¶
Option is a function that configures a Node
func WithGroupIds ¶
WithGroupIds sets the peer ids for the node
func WithNodeCallback ¶
func WithNodeCallback(callback NodeCallback) Option
WithNodeCallback sets the callback for the motor
func WithPartyId ¶
WithPartyId sets the party id for the node. This is to be replaced by the User defined label for the device
type PeerNode ¶ added in v0.6.0
type PeerNode 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)
}
`PeerNode` 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.
type StoreType ¶ added in v0.3.0
type StoreType string
StoreType is the type of a store
const ( // DB_EVENT_LOG_STORE is a store that stores events DB_EVENT_LOG_STORE StoreType = "eventlog" // DB_KEY_VALUE_STORE is a store that stores key-value pairs DB_KEY_VALUE_STORE StoreType = "keyvalue" // DB_DOCUMENT_STORE is a store that stores documents DB_DOCUMENT_STORE StoreType = "docstore" )