Documentation ¶
Index ¶
- Constants
- Variables
- func AddDagPBSupportToChooser(existing traversal.LinkTargetNodePrototypeChooser) traversal.LinkTargetNodePrototypeChooser
- func AddrBytesToAddrInfo(b []byte) (*peer.AddrInfo, error)
- func AddrStringToAddrInfo(s string) (*peer.AddrInfo, error)
- func CodecFromString(name string) (uint64, error)
- func FormatToken(tok string, tp string) string
- func Libp2pKey(ks keystore.Keystore) (ci.PrivKey, error)
- func ListValue(lst *[]string, defaultList []string) flag.Value
- func MigrateBlocks(ctx context.Context, from blockstore.Blockstore, to blockstore.Blockstore) error
- func MigrateSelectBlocks(from blockstore.Blockstore, to blockstore.Blockstore, root cid.Cid, ...) error
- func RepoExists(path string) (bool, error)
- func RepoPath() (string, error)
- func StringsToPeerIDs(strIDs []string) ([]peer.ID, error)
- func WalkDAG(root cid.Cid, bs blockstore.Blockstore, sel ipld.Node, ...) error
- type DAGStat
- type FileType
- type KeyList
Constants ¶
const KLibp2pHost = "libp2p-host"
KLibp2pHost is the datastore key for storing our libp2p identity private key
Variables ¶
var Chooser = AddDagPBSupportToChooser(func(ipld.Link, ipld.LinkContext) (ipld.NodePrototype, error) { return basicnode.Prototype.Any, nil })
Chooser decides which node type to use when decoding IPLD nodes
var HAMTHashOption = hamt.UseHashFunction(func(input []byte) []byte { res := sha256.Sum256(input) return res[:] })
HAMTHashOption uses 256 hash to prevent collision attacks
var MimeTypes = map[string]FileType{ "application": FTApplication, "archive": FTArchive, "audio": FTAudio, "video": FTVideo, "image": FTImage, "text": FTText, "chemical": FTChemical, "font": FTFont, "message": FTMessage, "model": FTModel, }
Functions ¶
func AddDagPBSupportToChooser ¶
func AddDagPBSupportToChooser(existing traversal.LinkTargetNodePrototypeChooser) traversal.LinkTargetNodePrototypeChooser
func AddrBytesToAddrInfo ¶
AddrBytesToAddrInfo tunrs a compressed address into addrInfo struct
func AddrStringToAddrInfo ¶
AddrStringToAddrInfo turns a string address of format /p2p/<addr>/<peerid> to AddrInfo struct
func CodecFromString ¶
CodecFromString returns a codec code from a string name
func FormatToken ¶
FormatToken takes a token type and a token value and creates a string ready to send in the http Authorization header
func Libp2pKey ¶
Libp2pKey gets a libp2p host private key from the keystore if available or generates a new one
func MigrateBlocks ¶
func MigrateBlocks(ctx context.Context, from blockstore.Blockstore, to blockstore.Blockstore) error
MigrateBlocks transfers all blocks from a blockstore to another
func MigrateSelectBlocks ¶
func MigrateSelectBlocks(from blockstore.Blockstore, to blockstore.Blockstore, root cid.Cid, sel ipld.Node) error
MigrateSelectBlocks transfers blocks from a blockstore to another for a given block selection
func RepoExists ¶
RepoExists checks if we have a datastore directory already created
func StringsToPeerIDs ¶
StringsToPeerIDs parses a list of strings into peer IDs
func WalkDAG ¶
func WalkDAG( root cid.Cid, bs blockstore.Blockstore, sel ipld.Node, f func(blocks.Block) error, missingF func(cid.Cid, error) error) error
WalkDAG executes a DAG traversal for a given root and selector and calls a callback function for every block loaded during the traversal an optional callback also returns missing block and forwards the errors
Types ¶
type FileType ¶
type FileType int
func DetectFileType ¶
func DetectFileType(path string, buf io.ReadSeeker) FileType
DetectFileType detects the FileType of a file using it's extension. The path argument should be absolute
type KeyList ¶
type KeyList []string
KeyList is a list of strings representing all the keys in an IPLD Map
func MapLoadableKeys ¶
MapLoadableKeys returns all the keys of a Tx, given its cid and a loader this only returns the keys for entries where the blocks are available in the blockstore it supports both dagpb and dagcbor nodes
func MapMissingKeys ¶
MapMissingKeys returns keys for values for which the links are not loadable