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
crate::ix!();
pub trait PushNodeVersion {
fn push_node_version(&self,
pnode: &mut AmoWriteGuard<Box<dyn NodeInterface>>,
n_time: &OffsetDateTime);
}
impl PushNodeVersion for PeerManager {
fn push_node_version(&self,
mut pnode: &mut AmoWriteGuard<Box<dyn NodeInterface>>,
n_time: &OffsetDateTime) {
let my_services: u64 = pnode.get_local_services().bits() as u64;
let nonce: u64 = pnode.get_local_nonce();
let n_node_starting_height: i32 = self.best_height.load(atomic::Ordering::Relaxed);
let nodeid: NodeId = pnode.get_id();
let addr: Address = pnode.addr().clone();
let addr_you: Service
= match
addr.is_routable()
&& !is_proxy(&addr.service.base)
&& addr.is_addr_v1compatible()
{
true => addr.service,
false => Service::default()
};
let your_services: u64 = addr.n_services.bits() as u64;
let tx_relay: bool =
!self.ignore_incoming_txs
&& pnode.has_tx_relay();
self.connman.get_mut().push_message(
&mut *pnode,
NetMsgMaker::new(INIT_PROTO_VERSION)
.make(
NetMsgType::VERSION,
&[
&PROTOCOL_VERSION,
&my_services,
n_time,
&your_services,
&addr_you, &my_services,
&Service::default(), &nonce,
&STR_SUBVERSION,
&n_node_starting_height,
&tx_relay
]
)
);
if *LOG_IPS {
log_print!(
LogFlags::NET,
"send version message: version %d, blocks=%d, them=%s, txrelay=%d, peer=%d\n",
PROTOCOL_VERSION,
n_node_starting_height,
addr_you.to_string(),
tx_relay,
nodeid
);
} else {
log_print!(
LogFlags::NET,
"send version message: version %d, blocks=%d, txrelay=%d, peer=%d\n",
PROTOCOL_VERSION,
n_node_starting_height,
tx_relay,
nodeid
);
}
}
}