Documentation ¶
Index ¶
- Constants
- func AddFileToNodes(ctx context.Context, filePath string, clients ...Client) (string, error)
- func AddTextToNodes(ctx context.Context, fileContent []byte, clients ...Client) (string, error)
- func ParsePeersString(peers []string) ([]peer.AddrInfo, error)
- type Client
- func (cl Client) APIAddress() string
- func (cl Client) Get(ctx context.Context, cid, outputPath string) error
- func (cl Client) GetCidSize(ctx context.Context, cid string) (uint64, error)
- func (cl Client) GetTreeNode(ctx context.Context, cid string) (IPLDTreeNode, error)
- func (cl Client) HasCID(ctx context.Context, cid string) (bool, error)
- func (cl Client) ID(ctx context.Context) (string, error)
- func (cl Client) Put(ctx context.Context, inputPath string) (string, error)
- func (cl Client) Stat(ctx context.Context, cid string) (*StatResult, error)
- func (cl Client) SwarmAddresses(ctx context.Context) ([]string, error)
- func (cl Client) SwarmMultiAddresses(ctx context.Context) ([]ma.Multiaddr, error)
- type Config
- type IPLDTreeNode
- type IPLDType
- type Node
- type NodeMode
- type StatResult
Constants ¶
const MagicInternalIPFSAddress = "memory://in-memory-node/"
const (
// PvtIpfsFolderPerm is what permissions we give to a private ipfs repo
PvtIpfsFolderPerm = 0755
)
Variables ¶
This section is empty.
Functions ¶
func AddFileToNodes ¶
func AddTextToNodes ¶
Types ¶
type Client ¶
Client is a front-end for an ipfs node's API endpoints. You can create Client instances manually by connecting to an ipfs node's API multiaddr using NewClientUsingRemoteHandler, or automatically from an active Node instance using NewClient.
func NewClientUsingRemoteHandler ¶
NewClientUsingRemoteHandler creates an API client for the given ipfs node API multiaddress. NOTE: the API address is _not_ the same as the swarm address
func (Client) APIAddress ¶
APIAddress returns Api address that was used to connect to the node.
func (Client) GetCidSize ¶
func (Client) GetTreeNode ¶
func (Client) HasCID ¶
HasCID returns true if the node has the given CID locally, whether pinned or not.
func (Client) Put ¶
Put uploads and pins a file or directory to the ipfs network. Timeouts and cancellation should be handled by passing an appropriate context value.
func (Client) SwarmAddresses ¶
SwarmAddresses returns a list of swarm addresses the node has announced.
type Config ¶
type Config struct { // PeerAddrs is a list of additional IPFS node multiaddrs to use as // peers. By default, the IPFS node will connect to whatever nodes are // specified by its mode. PeerAddrs []string // Mode configures the node's default settings. Mode NodeMode // KeypairSize is the number of bits to use for the node's repo keypair. If // nil, then a default value of 2048 is used. KeypairSize int }
Config contains configuration for the IPFS node.
type IPLDTreeNode ¶
type IPLDTreeNode struct { Cid cid.Cid Path []string Children []IPLDTreeNode }
func FlattenTreeNode ¶
func FlattenTreeNode(ctx context.Context, rootNode IPLDTreeNode) ([]IPLDTreeNode, error)
type Node ¶
type Node struct { // Mode is the mode the ipfs node was created in. Mode NodeMode // RepoPath is the path to the ipfs node's data repository. RepoPath string // APIPort is the port that the node's ipfs API is listening on. APIPort int // contains filtered or unexported fields }
Node is a wrapper around an in-process IPFS node that can be used to interact with the IPFS network without requiring an `ipfs` binary.
func NewLocalNode ¶
func NewLocalNode(ctx context.Context, cm *system.CleanupManager, peerAddrs []string) (*Node, error)
NewLocalNode creates a new local IPFS node in local mode, which can be used to create test environments without polluting the public IPFS nodes.
func NewNode ¶
NewNode creates a new IPFS node in default mode, which creates an IPFS repo in a temporary directory, uses the public libp2p nodes as peers and generates a repo keypair with 2048 bits.
func (*Node) LogDetails ¶
func (n *Node) LogDetails()
LogDetails logs connection details for the node's swarm and API servers.
func (*Node) SwarmAddresses ¶
SwarmAddresses returns the node's swarm addresses.
type NodeMode ¶
type NodeMode int
NodeMode configures how the node treats the public IPFS network.
const ( // ModeDefault is the default node mode, which uses an IPFS repo backed // by the `flatfs` datastore, and connects to the public IPFS network. ModeDefault NodeMode = iota // ModeLocal is a node mode that uses an IPFS repo backed by the `flatfs` // datastore and ignores the public IPFS network completely, for setting // up test environments without polluting the public IPFS nodes. ModeLocal )
type StatResult ¶
type StatResult struct {
Type IPLDType
}