Documentation ¶
Index ¶
- Constants
- Variables
- func CIDequals(cid1, cid2 string) bool
- func CalculateCIDv1json(data []byte) string
- func NewIPFSkey() []byte
- type Handler
- func (i *Handler) AddKeyToKeystore(keyalias string, privkey []byte) error
- func (i *Handler) Init(d *types.DataStore) error
- func (i *Handler) ListPins(ctx context.Context) (map[string]string, error)
- func (i *Handler) Pin(ctx context.Context, path string) error
- func (i *Handler) Publish(ctx context.Context, msg []byte) (cid string, err error)
- func (i *Handler) PublishIPNSpath(ctx context.Context, path string, keyalias string) (ipns.Name, ipfspath.ImmutablePath, error)
- func (i *Handler) PublishReader(ctx context.Context, buf io.Reader) (cid string, err error)
- func (i *Handler) Retrieve(ctx context.Context, path string, maxSize int64) ([]byte, error)
- func (i *Handler) RetrieveDir(ctx context.Context, path string, maxSize int64) (map[string][]byte, error)
- func (i *Handler) SetMultiAddress(addr string) (err error)
- func (i *Handler) Stats() map[string]any
- func (i *Handler) Stop() error
- func (*Handler) URIprefix() string
- func (i *Handler) Unpin(ctx context.Context, path string) error
Constants ¶
const ( // MaxFileSizeBytes is the maximum size of a file to be published to IPFS MaxFileSizeBytes = 1024 * 1024 * 100 // 100 MB // RetrievedFileCacheSize is the maximum number of files to be cached in memory RetrievedFileCacheSize = 128 )
const ChunkerTypeSize = "size-262144"
ChunkerTypeSize is the chunker type used by IPFS to calculate to build the DAG.
Variables ¶
var ConfigRoot string
Functions ¶
func CIDequals ¶
CIDequals compares two Cids (v0 or v1) and returns true if they are equal. It compares the hash of the Cid, not the Cid itself (which contains also the codec and encoding). It strips the ipfs:// prefix and the /ipfs/ prefix if present.
func CalculateCIDv1json ¶
CalculateCIDv1json calculates the IPFS Cid hash (v1) from a bytes buffer, using parameters Codec: DagJSON, MhType: SHA2_256
func NewIPFSkey ¶
func NewIPFSkey() []byte
NewIPFSkey generates a new IPFS private key (ECDSA/256bit) and returns its marshaled bytes representation.
Types ¶
type Handler ¶
type Handler struct { Node *ipfscore.IpfsNode CoreAPI coreiface.CoreAPI DataDir string LogLevel string // contains filtered or unexported fields }
Handler is the IPFS data storage node handler.
func MockIPFS ¶
MockIPFS returns a Handler with a (offline, nilrepo) IPFS node with a functional CoreAPI
func (*Handler) AddKeyToKeystore ¶
AddKeyToKeystore adds a marshaled IPFS private key to the IPFS keystore. The key is identified by a unique alias name which can be used for referncing that key when using some other IPFS methods. Compatible Keys can be generated with NewIPFSkey() function.
func (*Handler) Publish ¶
Publish publishes a file or message to ipfs and returns the resulting CID v1.
func (*Handler) PublishIPNSpath ¶
func (i *Handler) PublishIPNSpath(ctx context.Context, path string, keyalias string) (ipns.Name, ipfspath.ImmutablePath, error)
PublishIPNSpath creates or updates an IPNS record with the content of a filesystem path (a single file or a directory).
The IPNS record is published under the scope of the private key identified by the keyalias parameter. New keys can be created using method AddKeyToKeystore and function NewIPFSkey() both available on this package.
The execution of this method might take a while (some minutes), so the caller must handle properly the logic by using goroutines, channels or other mechanisms in order to not block the whole program execution.
func (*Handler) PublishReader ¶ added in v1.10.0
PublishReader publishes a reader buffer to ipfs and returns the resulting CID v1.
func (*Handler) Retrieve ¶
Retrieve gets an IPFS file (either from the p2p network or from the local cache). If maxSize is 0, it is set to the hardcoded maximum of MaxFileSizeBytes.
func (*Handler) RetrieveDir ¶ added in v1.10.0
func (i *Handler) RetrieveDir(ctx context.Context, path string, maxSize int64) (map[string][]byte, error)
RetrieveDir gets an IPFS directory and returns a map of all files and their content. It only supports 1 level of directory depth, so subdirectories are ignored.
func (*Handler) SetMultiAddress ¶
SetMultiAddress sets the multiaddress of the IPFS node.
Directories ¶
Path | Synopsis |
---|---|
Package ipfsconnect provides a service to maintain persistent connections (PersistPeers) between two or more IPFS nodes
|
Package ipfsconnect provides a service to maintain persistent connections (PersistPeers) between two or more IPFS nodes |