MCPcopy Create free account
hub / github.com/ElementsProject/elements / Peer

Class Peer

contrib/tracing/p2p_monitor.py:88–115  ·  view source on GitHub ↗

A P2P network peer.

Source from the content-addressed store, hash-verified

86
87
88class Peer:
89 """ A P2P network peer. """
90 id = 0
91 address = ""
92 connection_type = ""
93 last_messages = list()
94
95 total_inbound_msgs = 0
96 total_inbound_bytes = 0
97 total_outbound_msgs = 0
98 total_outbound_bytes = 0
99
100 def __init__(self, id, address, connection_type):
101 self.id = id
102 self.address = address
103 self.connection_type = connection_type
104 self.last_messages = list()
105
106 def add_message(self, message):
107 self.last_messages.append(message)
108 if len(self.last_messages) > 25:
109 self.last_messages.pop(0)
110 if message.inbound:
111 self.total_inbound_bytes += message.size
112 self.total_inbound_msgs += 1
113 else:
114 self.total_outbound_bytes += message.size
115 self.total_outbound_msgs += 1
116
117
118def main(bitcoind_path):

Callers 2

handle_inboundFunction · 0.70
handle_outboundFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected