Documentation ¶
Index ¶
- Constants
- func CidToNomsHash(id *cid.Cid) (h hash.Hash)
- func NewChunkStore(dbPath string, opts ...Option) (chunks.ChunkStore, error)
- func NomsHashToCID(nh hash.Hash) *cid.Cid
- func OpenIPFSRepo(path string, portIdx int) (*core.IpfsNode, error)
- func RegisterProtocols(opts ...Option) error
- func UnregisterProtocols()
- type HasIPFSNode
- type IPFSStats
- type Option
- type Protocol
Constants ¶
const ( DefaultAPIPort = 5001 DefaultGatewayPort = 8080 DefaultSwarmPort = 4001 )
Default ports for IPFS
const ( // NetworkProtoName is the default protocol name for networked IPFS ChunkStores. SetLocal for more information NetworkProtoName = "ipfs" // LocalProtoName is the default protocol name for local IPFS ChunkStores. See SetLocal for more information. // information. LocalProtoName = "ipfs-local" )
Variables ¶
This section is empty.
Functions ¶
func CidToNomsHash ¶
func NewChunkStore ¶
func NewChunkStore(dbPath string, opts ...Option) (chunks.ChunkStore, error)
NewChunkStore creates a new ChunkStore backed by IPFS.
Noms chunks written to this ChunkStore are converted to IPFS blocks and stored in an IPFS BlockStore.
IPFS database specs have the form:
ipfs://<path-to-ipfs-dir> for networked ChunkStores ipfs-local://<path-to-ipfs-dir> for local ChunkStores
where 'ipfs' or 'ipfs-local' indicates the noms protocol and the path indicates the path to the directory where the ipfs repo resides. The chunkstore creates two files in the ipfs directory called 'noms' and 'noms-local' which stores the root of the noms database. This should ideally be done with IPNS, but that is currently too slow to be practical.
This function creates an IPFS repo at the appropriate path if one doesn't already exist.
See Option documentation for more information on options.
func NomsHashToCID ¶
func OpenIPFSRepo ¶
OpenIPFSRepo opens an IPFS repo for use as a noms store, and returns an IPFS node for that repo. Creates a new repo at this indicated path if one doesn't already exist. See SetPortIdx for information on portIdx.
func RegisterProtocols ¶
RegisterProtocols registers the "ipfs" and "ipfs-local" protocols as external protocols for Specs, with the given options applied to both local and networked protocols. The protocols default to port index 0 and a maximum concurrent request count of 1. SetLocal and SetNetworked are ignored.
The external protocol is implemented by the Protocol type.
func UnregisterProtocols ¶
func UnregisterProtocols()
UnregisterProtocols unregisters the "ipfs" and "ipfs-local" protocols as external protocols for Specs.
Types ¶
type HasIPFSNode ¶
Implementing HasIPFSNode indicates that a type has an underlying IPFS node. It is implemented by the ChunkStore and Database returned by Protocol (i.e. all ChunkStores and Databases created via a Spec) and NewChunkStore/ChunkStoreFromIPFSNode
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
An Option configures the IPFS ChunkStore
func SetLocal ¶
func SetLocal() Option
SetLocal makes the ChunkStore only use the local IPFS blockstore for both reads and writes.
func SetMaxConcurrent ¶
SetMaxConcurrent sets the maximum number of concurrent requests used when creating IPFS ChunkStores from a Spec. The default is 1. Negative values of n will return an error.
func SetNetworked ¶
func SetNetworked() Option
SetNetworked makes reads fall through to the network and expose stored blocks to the entire IPFS network.
func SetPortIdx ¶
SetPortIdx sets the port index to use when creating IPFS ChunkStores from a Spec. If portIdx is a number between 1 and 8 inclusive, the config file will be modified to add 'portIdx' to each external port's number. The defaults are API: 5001, gateway: 8080, swarm: 4001, so a portIdx of 1 would give you 5002, 8081, and 4002.
The default is 0, which stands for IPFS default ports. idx must be between 0 and 8 inclusive; other values will result in an error.
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
Protocol implements spec.ProtocolImpl for the IPFS ChunkStore
func NewProtocol ¶
NewProtocol returns a new Protocol with the given options. The protocol defaults to port index 0, and a maximum concurrent request count of 1. See documentation under Option for more information on options
func (Protocol) NewChunkStore ¶
NewChunkStore returns a new ChunkStore backed by IPFS using the options passed in via NewProtocol The returned ChunkStore implements HasIPFSNode.
See the package-level NewChunkStore and Options for more information.