Initial implementation of routing/offline.
This commit is contained in:
parent
33431a3007
commit
1535273259
6 changed files with 143 additions and 2 deletions
32
include/ipfs/routing/routing.h
Normal file
32
include/ipfs/routing/routing.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#ifndef ROUTING_H
|
||||
#define ROUTING_H
|
||||
|
||||
#include "libp2p/crypto/rsa.h"
|
||||
|
||||
// offlineRouting implements the IpfsRouting interface,
|
||||
// but only provides the capability to Put and Get signed dht
|
||||
// records to and from the local datastore.
|
||||
struct s_ipfs_routing {
|
||||
struct FSRepo* datastore;
|
||||
size_t ds_len;
|
||||
struct RsaPrivateKey* sk;
|
||||
int (*PutValue) (struct s_ipfs_routing*, char*, size_t, void*, size_t);
|
||||
int (*GetValue) (struct s_ipfs_routing*, char*, size_t, void*, size_t*);
|
||||
int (*FindProviders) (struct s_ipfs_routing*, char*, size_t, void*, size_t*);
|
||||
int (*FindPeer) (struct s_ipfs_routing*, char*, size_t, void*, size_t*);
|
||||
int (*Provide) (struct s_ipfs_routing*, char*);
|
||||
int (*Ping) (struct s_ipfs_routing*, char*, size_t);
|
||||
int (*Bootstrap) (struct s_ipfs_routing*);
|
||||
};
|
||||
typedef struct s_ipfs_routing ipfs_routing;
|
||||
|
||||
// offline routing routines.
|
||||
ipfs_routing* ipfs_routing_new_offline (struct FSRepo* ds, struct RsaPrivateKey *private_key);
|
||||
int ipfs_routing_offline_put_value (ipfs_routing* offlineRouting, char *key, size_t key_size, void *val, size_t vlen);
|
||||
int ipfs_routing_offline_get_value (ipfs_routing* offlineRouting, char *key, size_t key_size, void *val, size_t *vlen);
|
||||
int ipfs_routing_offline_find_providers (ipfs_routing* offlineRouting, char *key, size_t key_size, void *ret, size_t *rlen);
|
||||
int ipfs_routing_offline_find_peer (ipfs_routing* offlineRouting, char *peer_id, size_t pid_size, void *ret, size_t *rlen);
|
||||
int ipfs_routing_offline_provide (ipfs_routing* offlineRouting, char *cid);
|
||||
int ipfs_routing_offline_ping (ipfs_routing* offlineRouting, char *peer_id, size_t pid_size);
|
||||
int ipfs_routing_offline_bootstrap (ipfs_routing* offlineRouting);
|
||||
#endif // ROUTING_H
|
|
@ -27,6 +27,7 @@
|
|||
ErrInvalidSignature,
|
||||
ErrInvalidSignatureFmt,
|
||||
ErrNoRecord,
|
||||
ErrCidDecodeFailed
|
||||
ErrCidDecodeFailed,
|
||||
ErrOffline
|
||||
} ErrsIdx;
|
||||
#endif // IPFS_ERRS_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue