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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
crate::ix!();
impl PeerManager {
pub fn process_verack_message(
self: Arc<Self>,
peer: &Option<Peer>,
msg_maker: NetMsgMaker,
mut pfrom: &mut AmoWriteGuard<Box<dyn NodeInterface>>,
msg_type: &str,
recv: &mut DataStream,
time_received: &OffsetDateTime ,
interrupt_msg_proc: &AtomicBool) {
if pfrom.is_successfully_connected() {
log_print!(
LogFlags::NET,
"ignoring redundant verack message from peer=%d\n",
pfrom.get_id()
);
return;
}
if !pfrom.is_inbound_conn() {
log_printf!(
"New outbound peer connected: version: %d, blocks=%d, peer=%d%s (%s)\n",
pfrom.n_version.load(),
(*peer).starting_height,
pfrom.get_id(),
match LOG_IPS {
true => strprintf(", peeraddr=%s",pfrom.addr.to_string()),
false => ""
},
pfrom.connection_type_as_string()
);
}
if pfrom.get_common_version() >= SENDHEADERS_VERSION {
self.connman.get_mut().push_message(
&mut *pfrom,
msg_maker.make(NetMsgType::SENDHEADERS, &[])
);
}
if pfrom.get_common_version() >= SHORT_IDS_BLOCKS_VERSION {
let announce_usingcmpctblock: bool = false;
let mut n_cmpctblock_version: u64 = 2;
self.connman.get_mut().push_message(
&mut *pfrom,
msg_maker.make(
NetMsgType::SENDCMPCT,
&[
&announce_usingcmpctblock,
&n_cmpctblock_version
]
)
);
n_cmpctblock_version = 1;
self.connman.get_mut().push_message(
&mut *pfrom,
msg_maker.make(
NetMsgType::SENDCMPCT,
&[
&announce_usingcmpctblock,
&n_cmpctblock_version
]
)
);
}
pfrom.set_successfully_connected(true);
}
}