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
crate::ix!();
pub trait FindTxForGetData {
fn find_tx_for_get_data(self: Arc<Self>,
peer: &dyn NodeInterface,
gtxid: &GenTxId,
mempool_req: Option<OffsetDateTime> ,
now: OffsetDateTime ) -> TransactionRef;
}
impl FindTxForGetData for PeerManager {
#[LOCKS_EXCLUDED(CS_MAIN)]
fn find_tx_for_get_data(
self: Arc<Self>,
peer: &dyn NodeInterface,
gtxid: &GenTxId,
mempool_req: Option<OffsetDateTime>,
now: OffsetDateTime) -> TransactionRef {
let txinfo = self.mempool.get().info(gtxid);
if txinfo.tx.is_some() {
if (mempool_req.is_some() && txinfo.time <= mempool_req.unwrap())
|| txinfo.time <= now - UNCONDITIONAL_RELAY_DELAY {
return txinfo.tx ;
}
}
{
let mut guard = CS_MAIN.lock();
let state = create_state(peer.get_id());
if state.get().recently_announced_invs.contains_key(gtxid.get_hash().as_slice()) {
if txinfo.tx.is_some() {
return txinfo.tx ;
}
let inner = self.inner.lock();
let mi = inner.map_relay.get(gtxid.get_hash());
if mi.is_some() {
return mi.unwrap().clone();
}
}
}
TransactionRef::none()
}
}