2017-02-22 15:56:11 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-09-21 12:51:18 +00:00
|
|
|
#include <pthread.h>
|
2017-07-27 13:38:57 +00:00
|
|
|
#include "libp2p/peer/peerstore.h"
|
|
|
|
#include "libp2p/peer/providerstore.h"
|
2017-07-24 19:56:30 +00:00
|
|
|
#include "ipfs/blocks/blockstore.h"
|
2017-07-27 13:38:57 +00:00
|
|
|
#include "ipfs/exchange/exchange.h"
|
2017-02-23 20:15:33 +00:00
|
|
|
#include "ipfs/repo/config/identity.h"
|
|
|
|
#include "ipfs/repo/fsrepo/fs_repo.h"
|
2017-04-03 16:55:36 +00:00
|
|
|
#include "ipfs/routing/routing.h"
|
2017-02-23 20:15:33 +00:00
|
|
|
|
2017-09-20 14:11:01 +00:00
|
|
|
/***
|
|
|
|
* Holds information about the local node
|
|
|
|
*/
|
|
|
|
|
|
|
|
/***
|
|
|
|
* Modes:
|
|
|
|
* MODE_OFFLINE: Do everything yourself
|
|
|
|
* MODE_API_AVAILABLE: If you want to, the API is running
|
|
|
|
* MODE_ONLINE: You are the API
|
|
|
|
*/
|
|
|
|
enum NodeMode { MODE_OFFLINE, MODE_API_AVAILABLE, MODE_ONLINE };
|
2016-10-27 18:11:34 +00:00
|
|
|
|
|
|
|
struct IpfsNode {
|
2017-09-20 14:11:01 +00:00
|
|
|
/***
|
|
|
|
* Modes:
|
|
|
|
* MODE_OFFLINE: Do everything yourself
|
|
|
|
* MODE_API_AVAILABLE: If you want to, the API is running
|
|
|
|
* MODE_ONLINE: You are the API
|
|
|
|
*/
|
2017-02-22 15:56:11 +00:00
|
|
|
enum NodeMode mode;
|
2017-02-22 16:48:42 +00:00
|
|
|
struct Identity* identity;
|
2017-02-22 15:56:11 +00:00
|
|
|
struct FSRepo* repo;
|
|
|
|
struct Peerstore* peerstore;
|
2017-03-19 19:40:16 +00:00
|
|
|
struct ProviderStore* providerstore;
|
2017-04-03 16:55:36 +00:00
|
|
|
struct IpfsRouting* routing;
|
2017-07-24 19:56:30 +00:00
|
|
|
struct Blockstore* blockstore;
|
2017-07-27 13:38:57 +00:00
|
|
|
struct Exchange* exchange;
|
2017-08-09 13:04:17 +00:00
|
|
|
struct Libp2pVector* protocol_handlers;
|
2016-10-27 18:11:34 +00:00
|
|
|
//struct Pinner pinning; // an interface
|
|
|
|
//struct Mount** mounts;
|
|
|
|
// TODO: Add more here
|
|
|
|
};
|
2017-04-20 22:56:03 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
* build an online IpfsNode
|
|
|
|
* @param repo_path where the IPFS repository directory is
|
|
|
|
* @param node the completed IpfsNode struct
|
|
|
|
* @returns true(1) on success
|
|
|
|
*/
|
2017-09-20 17:39:26 +00:00
|
|
|
int ipfs_node_online_new(pthread_t *pth_scope, const char* repo_path, struct IpfsNode** node);
|
2017-08-30 16:10:14 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
* build an offline IpfsNode
|
|
|
|
* @param repo_path where the IPFS repository directory is
|
|
|
|
* @param node the completed IpfsNode struct
|
|
|
|
* @returns true(1) on success
|
|
|
|
*/
|
2017-09-21 12:51:18 +00:00
|
|
|
int ipfs_node_offline_new(const char* repo_path, struct IpfsNode** node);
|
2017-08-30 16:10:14 +00:00
|
|
|
|
2017-04-20 22:56:03 +00:00
|
|
|
/***
|
|
|
|
* Free resources from the creation of an IpfsNode
|
|
|
|
* @param node the node to free
|
|
|
|
* @returns true(1)
|
|
|
|
*/
|
2017-09-20 17:39:26 +00:00
|
|
|
int ipfs_node_free(pthread_t *pth_scope, struct IpfsNode* node);
|