grapes / include / trade_sig_ha.h @ a2859bcd
History | View | Annotate | Download (4.38 KB)
1 |
/** @file trade_sig_ha.h
|
---|---|
2 |
*
|
3 |
* @brief Chunk Signaling API - Higher Abstraction (HA).
|
4 |
*
|
5 |
* The trade signaling HA provides a set of primitives for chunks signaling negotiation with other peers, in order to collect information for the effective chunk exchange with other peers. <br>
|
6 |
* This is a part of the Data Exchange Protocol which provides high level abstraction for chunks' negotiations, like requesting and proposing chunks.
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
|
11 |
#ifndef TRADE_SIG_HA_H
|
12 |
#define TRADE_SIG_HA_H
|
13 |
|
14 |
#include "net_helper.h" |
15 |
#include "chunkidset.h" |
16 |
|
17 |
/**
|
18 |
* Header used to define a signaling message.
|
19 |
*/
|
20 |
typedef struct sig_nal SigType; |
21 |
|
22 |
/**
|
23 |
* Set current node identifier.
|
24 |
*
|
25 |
* @param[in] current node indentifier.
|
26 |
* @return 1 on success, <0 on error.
|
27 |
*/
|
28 |
int chunkSignalingInit(struct nodeID *myID); |
29 |
|
30 |
/**
|
31 |
* Request a set of chunks from a Peer.
|
32 |
*
|
33 |
* Request a set of Chunks towards a Peer, and specify the maximum number of Chunks attempted to receive
|
34 |
* (i.e., the number of chunks the destination peer would like to receive among those requested).
|
35 |
*
|
36 |
* @param[in] to target peer to request the ChunkIDs from.
|
37 |
* @param[in] cset array of ChunkIDs.
|
38 |
* @param[in] cset_len length of the ChunkID set.
|
39 |
* @param[in] max_deliver deliver at most this number of Chunks.
|
40 |
* @param[in] trans_id transaction number associated with this request.
|
41 |
* @return 1 on success, <0 on error.
|
42 |
*/
|
43 |
//int requestChunks(const struct nodeID *to, const struct chunkID_set *cset, int cset_len, int max_deliver, int trans_id);
|
44 |
|
45 |
/**
|
46 |
* Deliver a set of Chunks to a Peer as a reply of its previous request of Chunks.
|
47 |
*
|
48 |
* Announce to the Peer which sent a request of a set of Chunks, that we have these chunks (sub)set available
|
49 |
* among all those requested and willing to deliver them.
|
50 |
*
|
51 |
* @param[in] to target peer to which deliver the ChunkIDs.
|
52 |
* @param[in] cset array of ChunkIDs.
|
53 |
* @param[in] cset_len length of the ChunkID set.
|
54 |
* @param[in] max_deliver we are able to deliver at most this many from the set.
|
55 |
* @param[in] trans_id transaction number associated with this request.
|
56 |
* @return 1 on success, <0 on error.
|
57 |
*/
|
58 |
//int deliverChunks(const struct nodeID *to, struct chunkID_set *cset, int cset_len, int max_deliver, int trans_id);
|
59 |
|
60 |
/**
|
61 |
* Offer a (sub)set of chunks to a Peer.
|
62 |
*
|
63 |
* Initiate a offer for a set of Chunks towards a Peer, and specify the maximum number of Chunks attempted to deliver
|
64 |
* (attempted to deliver: i.e., the sender peer should try to send at most this number of Chunks from the set).
|
65 |
*
|
66 |
* @param[in] to target peer to offer the ChunkIDs.
|
67 |
* @param[in] cset array of ChunkIDs.
|
68 |
* @param[in] max_deliver deliver at most this number of Chunks.
|
69 |
* @param[in] trans_id transaction number associated with this request.
|
70 |
* @return 1 on success, <0 on error.
|
71 |
*/
|
72 |
int offerChunks(struct nodeID *to, struct chunkID_set *cset, int max_deliver, int trans_id); |
73 |
|
74 |
/**
|
75 |
* Accept a (sub)set of chunks from a Peer.
|
76 |
*
|
77 |
* Announce to accept a (sub)set of Chunks from a Peer which sent a offer before, and specify the maximum number of Chunks attempted to receive
|
78 |
* (attempted to receive: i.e., the receiver peer would like to receive at most this number of Chunks from the set offered before).
|
79 |
*
|
80 |
* @param[in] to target peer to accept the ChunkIDs.
|
81 |
* @param[in] cset array of ChunkIDs.
|
82 |
* @param[in] max_deliver accept at most this number of Chunks.
|
83 |
* @param[in] trans_id transaction number associated with this request.
|
84 |
* @return 1 on success, <0 on error.
|
85 |
*/
|
86 |
int acceptChunks(struct nodeID *to, struct chunkID_set *cset, int max_deliver, int trans_id); |
87 |
|
88 |
/**
|
89 |
* Send a BufferMap to a Peer.
|
90 |
*
|
91 |
* Send (our own or some other peer's) BufferMap to a third Peer.
|
92 |
*
|
93 |
* @param[in] to PeerID.
|
94 |
* @param[in] owner Owner of the BufferMap to send.
|
95 |
* @param[in] bmap the BufferMap to send.
|
96 |
* @param[in] bmap_len length of the buffer map.
|
97 |
* @param[in] trans_id transaction number associated with this send.
|
98 |
* @return 1 Success, <0 on error.
|
99 |
*/
|
100 |
int sendBufferMap(struct nodeID *to, const struct nodeID *owner, struct chunkID_set *bmap, int bmap_len, int trans_id); |
101 |
|
102 |
/**
|
103 |
* Request a BufferMap to a Peer.
|
104 |
*
|
105 |
* Request (target peer or some other peer's) BufferMap to target Peer.
|
106 |
*
|
107 |
* @param[in] to PeerID.
|
108 |
* @param[in] owner Owner of the BufferMap to request.
|
109 |
* @param[in] trans_id transaction number associated with this request.
|
110 |
* @return 1 Success, <0 on error.
|
111 |
*/
|
112 |
//int requestBufferMap(const struct nodeID *to, const struct nodeID *owner, int trans_id);
|
113 |
|
114 |
#endif //TRADE_SIG_HA_H |