More code for storage
Pushing through on the ipfs block put use case. Building out the necessary code to write to the blockstore.
This commit is contained in:
parent
74a5afe169
commit
4626b69381
14 changed files with 217 additions and 26 deletions
|
@ -17,7 +17,7 @@ struct Block {
|
|||
* @param block a pointer to the struct Block that will be created
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int ipfs_blocks_block_new(unsigned char* data, size_t data_size, struct Block* block);
|
||||
int ipfs_blocks_block_new(unsigned char* data, size_t data_size, struct Block** block);
|
||||
|
||||
/***
|
||||
* Free resources used by the creation of a block
|
||||
|
|
|
@ -33,14 +33,14 @@ struct Cid {
|
|||
* @param cid where to put the results
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int cid_new(int version, unsigned char* hash, size_t hash_length, const char codec, struct Cid* cid);
|
||||
int ipfs_cid_new(int version, unsigned char* hash, size_t hash_length, const char codec, struct Cid** cid);
|
||||
|
||||
/***
|
||||
* Free the resources from a Cid
|
||||
* @param cid the struct
|
||||
* @returns 1
|
||||
*/
|
||||
int cid_free(struct Cid* cid);
|
||||
int ipfs_cid_free(struct Cid* cid);
|
||||
|
||||
/***
|
||||
* Fill a Cid struct based on a base 58 encoded string
|
||||
|
@ -49,7 +49,7 @@ int cid_free(struct Cid* cid);
|
|||
* @cid the Cid struct to fill
|
||||
* @return true(1) on success
|
||||
*/
|
||||
int cid_decode_from_string(const unsigned char* incoming, size_t incoming_length, struct Cid* cid);
|
||||
int ipfs_cid_decode_from_string(const unsigned char* incoming, size_t incoming_length, struct Cid** cid);
|
||||
|
||||
/***
|
||||
* Turn a multibase decoded string of bytes into a Cid struct
|
||||
|
@ -57,6 +57,6 @@ int cid_decode_from_string(const unsigned char* incoming, size_t incoming_length
|
|||
* @param incoming_size the size of the array
|
||||
* @param cid the Cid structure to fill
|
||||
*/
|
||||
int cid_cast(unsigned char* incoming, size_t incoming_size, struct Cid* cid);
|
||||
int ipfs_cid_cast(unsigned char* incoming, size_t incoming_size, struct Cid* cid);
|
||||
|
||||
#endif
|
||||
|
|
33
include/ipfs/datastore/ds_helper.h
Normal file
33
include/ipfs/datastore/ds_helper.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* Some code to help with the datastore / blockstore interface
|
||||
*/
|
||||
#ifndef __IPFS_DATASTORE_DS_HELPER_H__
|
||||
#define __IPFS_DATASTORE_DS_HELPER_H__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* Generate a key based on the passed in binary_array
|
||||
* @param binary_array what to base the key on
|
||||
* @param array_length the size of the binary array
|
||||
* @param results where the key will be put
|
||||
* @param max_results_length the size of the results buffer
|
||||
* @param results_length the length of the generated key
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int ipfs_datastore_helper_ds_key_from_binary(unsigned char* binary_array, size_t array_length,
|
||||
char* results, size_t max_results_length, size_t* results_length);
|
||||
|
||||
/**
|
||||
* Generate a binary array based on the passed in datastore key
|
||||
* @param ds_key the base32 encoded key
|
||||
* @param key_length the length of the base32 "string"
|
||||
* @param binary_array where to put the decoded value
|
||||
* @param max_binary_array_length the memory size of binary_array
|
||||
* @param completed_binary_array_length the length of what was written to the binary_array
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int ipfs_datastore_helper_binary_from_ds_key(unsigned char* ds_key, size_t key_length, unsigned char* binary_array,
|
||||
size_t max_binary_array_length, size_t* completed_binary_array_length);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue