LibreWeb Browser
Decentralized Web-browser
Public Member Functions | List of all members
IPFS Class Reference

Start IPFS connection and contain IPFS related calls. More...

#include <ipfs.h>

Public Member Functions

 IPFS (const std::string &host, int port, const std::string &timeout)
 IPFS Contructor, connect to IPFS. More...
 
std::size_t getNrPeers ()
 Get the number of IPFS peers. More...
 
std::string const getClientID ()
 Retrieve your IPFS client ID. More...
 
std::string const getClientPublicKey ()
 Retrieve your IPFS Public Key. More...
 
std::string const getVersion ()
 Retrieve the Go IPFS daemon version. More...
 
std::map< std::string, float > getBandwidthRates ()
 Get the number of IPFS peers. More...
 
std::map< std::string, std::variant< int, std::string > > getRepoStats ()
 Get the stats of the current Repo. More...
 
std::string const fetch (const std::string &path)
 Fetch file from IFPS network (create a new client object each time - which is thread-safe), static method. More...
 
std::string const add (const std::string &path, const std::string &content)
 Add a file to IPFS network (not thread-safe) More...
 

Detailed Description

Start IPFS connection and contain IPFS related calls.

Constructor & Destructor Documentation

◆ IPFS()

IPFS::IPFS ( const std::string &  host,
int  port,
const std::string &  timeout 
)
explicit

IPFS Contructor, connect to IPFS.

Parameters
hostIPFS host (eg. localhost)
portIPFS port number (5001)
timeoutIPFS time-out (which is a string, eg. "6s" for 6 seconds)

Member Function Documentation

◆ add()

std::string const IPFS::add ( const std::string &  path,
const std::string &  content 
)

Add a file to IPFS network (not thread-safe)

Parameters
pathFile path where the file could be stored in IPFS (like puting a file inside a directory within IPFS)
contentContent that needs to be written to the IPFS network
Exceptions
std::runtime_errorwhen there is a connection-time/something goes wrong while trying to get the file
Returns
IPFS content-addressed identifier (CID) hash

◆ fetch()

std::string const IPFS::fetch ( const std::string &  path)

Fetch file from IFPS network (create a new client object each time - which is thread-safe), static method.

Parameters
pathFile path
Exceptions
std::runtime_errorwhen there is a connection-time/something goes wrong while trying to get the file
Returns
content as string

◆ getBandwidthRates()

std::map< std::string, float > IPFS::getBandwidthRates ( )

Get the number of IPFS peers.

Returns
Map with bandwidth information (with keys: 'in' and 'out')

◆ getClientID()

std::string const IPFS::getClientID ( )

Retrieve your IPFS client ID.

Returns
ID

◆ getClientPublicKey()

std::string const IPFS::getClientPublicKey ( )

Retrieve your IPFS Public Key.

Returns
Public Key

◆ getNrPeers()

std::size_t IPFS::getNrPeers ( )

Get the number of IPFS peers.

Returns
number of peers

◆ getRepoStats()

std::map< std::string, std::variant< int, std::string > > IPFS::getRepoStats ( )

Get the stats of the current Repo.

Returns
Map with repo stats (with keys: 'total_size' and 'path')

◆ getVersion()

std::string const IPFS::getVersion ( )

Retrieve the Go IPFS daemon version.

Returns
Public Key

The documentation for this class was generated from the following files: