1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use lib3h_protocol::{data_types::EntryData, Address};
#[derive(Debug, PartialEq, Clone)]
pub enum DhtEvent {
/// We have received a gossip bundle from a remote peer,
/// pass it along to the dht backend for processing
RemoteGossipBundle(RemoteGossipBundleData),
/// Instructs implementors to send this binary gossip bundle
/// to the specified list of peerAddress' in a reliable manner.
GossipTo(GossipToData),
/// Instructs implementors to send this binary gossip bundle
/// to as many peers listed in peerList as possible.
/// It is okay if not all peers on the list receive the message.
UnreliableGossipTo(GossipToData),
/// Tell implementors that gossip is requesting we hold a peer discovery
/// data item. Note that this dht tracker has not actually marked this item
/// for holding until the implementors pass this event back in.
PeerHoldRequest(PeerHoldRequestData),
/// Tell implementors that gossip believes a peer has dropped
PeerTimedOut(String),
/// Tell implementors that gossip is requesting we hold a data item.
/// Note that this dht tracker has not actually marked this item
/// for holding until the implementors pass this event back in.
DataHoldRequest(DataHoldRequestData),
/// This dht tracker requires access to the data associated with a data hash.
/// This event should cause implementors to respond with a dataFetchResponse
/// event.
DataFetch(DataFetchData),
/// Response to a dataFetch event. Set `data` to `null` to indicate the
/// requested data is not available (it will be removed from gossip).
DataFetchResponse(DataFetchResponseData),
/// Tell our implementors that we are no longer tracking this data
/// locally. Implementors should purge this hash from storage,
/// but that can, of course, choose not to.
DataPrune(String),
}
#[derive(Debug, PartialEq, Clone)]
pub struct RemoteGossipBundleData {
pub from_peer_address: String,
pub bundle: Vec<u8>,
}
#[derive(Debug, PartialEq, Clone)]
pub struct GossipToData {
pub peer_address_list: Vec<String>,
pub bundle: Vec<u8>,
}
#[derive(Debug, PartialEq, Clone)]
pub struct PeerHoldRequestData {
pub peer_address: String,
pub transport: String,
pub timestamp: u64,
}
#[derive(Debug, PartialEq, Clone)]
pub struct DataHoldRequestData {
pub entry: EntryData,
}
#[derive(Debug, PartialEq, Clone)]
pub struct DataFetchData {
pub msg_id: String,
pub data_address: Address,
}
#[derive(Debug, PartialEq, Clone)]
pub struct DataFetchResponseData {
pub msg_id: String,
pub entry: EntryData,
}