c-ipfs/include/ipfs/exchange/bitswap/want_manager.h

41 lines
1.4 KiB
C
Raw Normal View History

2017-07-24 21:03:56 +00:00
#pragma once
#include "ipfs/blocks/block.h"
#include "ipfs/cid/cid.h"
#include "ipfs/exchange/bitswap/bitswap.h"
2017-07-24 22:58:39 +00:00
#include "wantlist_queue.h"
2017-07-24 21:03:56 +00:00
/***
* Add a Cid to the local wantlist
* @param context the context
* @param cid the Cid
2017-07-24 22:58:39 +00:00
* @returns the added WantListQueueEntry
2017-07-24 21:03:56 +00:00
*/
struct WantListQueueEntry* ipfs_bitswap_want_manager_add(const struct BitswapContext* context, const struct Cid* cid, const struct WantListSession* session);
2017-07-24 21:03:56 +00:00
/***
* Checks to see if the requested block has been received
* @param context the context
* @param cid the Cid
* @returns true(1) if it has been received, false(0) otherwise
*/
int ipfs_bitswap_want_manager_received(const struct BitswapContext* context, const struct Cid* cid);
/***
* retrieve a block from the WantManager.
2017-07-24 21:03:56 +00:00
* @param context the context
* @param cid the Cid to get
* @param block a pointer to the block that will be allocated
* @returns true(1) on success, false(0) otherwise
*/
int ipfs_bitswap_want_manager_get_block(const struct BitswapContext* context, const struct Cid* cid, struct Block** block);
/***
* We no longer are requesting this block, so remove it from the queue
* NOTE: This is reference counted, as another process may have asked for it.
* @param context the context
* @param cid the Cid
* @returns true(1) on success, false(0) otherwise.
*/
int ipfs_bitswap_want_manager_remove(const struct BitswapContext* context, const struct Cid* cid);