IPFS

public class IPFS

IPFS is a class that wraps a go-ipfs node and its shell over UDS

  • Undocumented

    Declaration

    Swift

    public static let defaultRepoPath: String
  • Class constructor using repoPath passed as parameter on internal storage

    Throws

    Declaration

    Swift

    public init(_ repoPath: String = defaultRepoPath) throws

    Parameters

    repoPath

    The path of the go-ipfs repo (default: ipfs/repo)

  • Returns the absolute repo path as an URL

    Declaration

    Swift

    public func getAbsoluteRepoPath() -> URL

    Return Value

    The absolute repo path

  • Returns True if this IPFS instance is started by checking if the underlying go-ipfs node is instantiated

    Declaration

    Swift

    public func isStarted() -> Bool

    Return Value

    True, if this IPFS instance is started

  • Starts this IPFS instance

    Throws

    • RepoError: If the opening of the repo failed
    • NodeError: If the node is already started or if its startup fails

    Declaration

    Swift

    public func start() throws
  • Stops this IPFS instance

    Throws

    IPFSError: If the node is already stopped or if its stop fails

    Declaration

    Swift

    public func stop() throws
  • Restarts this IPFS instance

    Throws

    • IPFSError: If the node is already stopped or if its stop fails
    • RepoError: If the opening of the repo failed

    Declaration

    Swift

    public func restart() throws
  • Gets the IPFS instance config as a dict

    Throws

    • RepoError: If the opening of the repo or the getting of its config failed
    • ConfigError: If the getting of the config as a dict failed

    Seealso

    IPFS Config Doc

    Declaration

    Swift

    public func getConfig() throws -> [String : Any]

    Return Value

    The IPFS instance config as a dict

  • Sets dict config passed as parameter as IPFS config or reset to default config (with a new identity) if the config parameter is nil

    Attention

    A started IPFS instance must be restarted for its config to be applied

    Throws

    • RepoError: If the opening of the repo or the setting of its config failed
    • ConfigError: If the setting of the config as a dict failed

    Seealso

    IPFS Config Doc

    Declaration

    Swift

    public func setConfig(_ config: [String : Any]? = nil) throws

    Parameters

    config

    The IPFS instance dict config to set (if nil, default config will be used)

  • Gets the dict value associated to the key passed as parameter in the IPFS instance config

    Throws

    • RepoError: If the opening of the repo or the getting of its config failed
    • ConfigError: If the getting of the config value as a dict failed

    Seealso

    IPFS Config Doc

    Declaration

    Swift

    public func getConfigKey(_ key: String) throws -> [String : Any]

    Parameters

    key

    The key associated to the value to get in the IPFS config

    Return Value

    The dict value associated to the key passed as parameter in the IPFS instance config

  • Sets dict config value to the key passed as parameters in the IPFS instance config

    Attention

    A started IPFS instance must be restarted for its config to be applied

    Throws

    • RepoError: If the opening of the repo or the getting/setting of its config failed
    • ConfigError: If the setting of the config value as a dict failed

    Seealso

    IPFS Config Doc

    Declaration

    Swift

    public func setConfigKey(_ key: String, _ value: [String : Any]) throws

    Parameters

    key

    The key associated to the value to set in the IPFS instance config

    value

    The dict value associated to the key to set in the IPFS instance config

  • Creates and returns a RequestBuilder associated to this IPFS instance shell

    Throws

    IPFSError: If the request creaton failed

    Declaration

    Swift

    public func newRequest(_ command: String) throws -> RequestBuilder

    Parameters

    command

    The command of the request

    Return Value

    A RequestBuilder based on the command passed as parameter

  • Serves node Gateway over the given Multiaddr

    Throws

    NodeError: If the node failed to serve

    Declaration

    Swift

    public func serveGateway(onMultiaddr: String, _ writable: Bool = false) throws -> String

    Parameters

    onMultiaddr

    The multiaddr to serve on

    writable

    If true: will also support support POST, PUT, and DELETE methods.

  • Serves node opi over the given TCPPort

    Throws

    NodeError: If the node failed to serve

    Declaration

    Swift

    public func serveAPI(onTCPPort: String) throws -> String

    Parameters

    onMultiaddr

    The multiaddr to serve on

    writable

    If true: will also support support POST, PUT, and DELETE methods.