add unique_contacts
This commit is contained in:
parent
d4835153cd
commit
9f15573742
3 changed files with 51 additions and 0 deletions
|
@ -11,6 +11,7 @@ at anytime.
|
||||||
### Added
|
### Added
|
||||||
* Add `claim_send_to_address`
|
* Add `claim_send_to_address`
|
||||||
* Add `change_address` argument to `publish`
|
* Add `change_address` argument to `publish`
|
||||||
|
* Add `unique_contacts` count to `status` response
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* Support resolution of multiple uris with `resolve`, all results are keyed by uri
|
* Support resolution of multiple uris with `resolve`, all results are keyed by uri
|
||||||
|
|
|
@ -79,6 +79,7 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
||||||
self._history_tx = {}
|
self._history_tx = {}
|
||||||
self._bytes_rx = {}
|
self._bytes_rx = {}
|
||||||
self._bytes_tx = {}
|
self._bytes_tx = {}
|
||||||
|
self._unique_contacts = []
|
||||||
self._queries_rx_per_second = 0
|
self._queries_rx_per_second = 0
|
||||||
self._queries_tx_per_second = 0
|
self._queries_tx_per_second = 0
|
||||||
self._kbps_tx = 0
|
self._kbps_tx = 0
|
||||||
|
@ -121,6 +122,10 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
||||||
self._total_bytes_tx = sum(v for (k, v) in self._bytes_tx.iteritems())
|
self._total_bytes_tx = sum(v for (k, v) in self._bytes_tx.iteritems())
|
||||||
self._total_bytes_rx = sum(v for (k, v) in self._bytes_rx.iteritems())
|
self._total_bytes_rx = sum(v for (k, v) in self._bytes_rx.iteritems())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_contacts(self):
|
||||||
|
return self._unique_contacts
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def queries_rx_per_second(self):
|
def queries_rx_per_second(self):
|
||||||
return self._queries_rx_per_second
|
return self._queries_rx_per_second
|
||||||
|
@ -159,6 +164,7 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
||||||
"queries_received": self.queries_rx_per_second,
|
"queries_received": self.queries_rx_per_second,
|
||||||
"queries_sent": self.queries_tx_per_second,
|
"queries_sent": self.queries_tx_per_second,
|
||||||
"recent_contacts": self.recent_contact_count,
|
"recent_contacts": self.recent_contact_count,
|
||||||
|
"unique_contacts": len(self.unique_contacts)
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@ -256,6 +262,8 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
||||||
bytes_rx = self._bytes_rx.get(address, 0)
|
bytes_rx = self._bytes_rx.get(address, 0)
|
||||||
bytes_rx += len(datagram)
|
bytes_rx += len(datagram)
|
||||||
self._bytes_rx[address] = bytes_rx
|
self._bytes_rx[address] = bytes_rx
|
||||||
|
if address not in self.unique_contacts:
|
||||||
|
self._unique_contacts.append(address)
|
||||||
|
|
||||||
# Refresh the remote node's details in the local node's k-buckets
|
# Refresh the remote node's details in the local node's k-buckets
|
||||||
self._node.addContact(remoteContact)
|
self._node.addContact(remoteContact)
|
||||||
|
@ -315,6 +323,8 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
||||||
bytes_tx = self._bytes_tx.get(address, 0)
|
bytes_tx = self._bytes_tx.get(address, 0)
|
||||||
bytes_tx += len(data)
|
bytes_tx += len(data)
|
||||||
self._bytes_tx[address] = bytes_tx
|
self._bytes_tx[address] = bytes_tx
|
||||||
|
if address not in self.unique_contacts:
|
||||||
|
self._unique_contacts.append(address)
|
||||||
|
|
||||||
if len(data) > self.msgSizeLimit:
|
if len(data) > self.msgSizeLimit:
|
||||||
# We have to spread the data over multiple UDP datagrams,
|
# We have to spread the data over multiple UDP datagrams,
|
||||||
|
|
|
@ -994,6 +994,46 @@ class Daemon(AuthJSONRPCServer):
|
||||||
Options:
|
Options:
|
||||||
-s : include session status in results
|
-s : include session status in results
|
||||||
-d : include dht network and peer status
|
-d : include dht network and peer status
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
(dict) lbrynet-daemon status
|
||||||
|
{
|
||||||
|
'lbry_id': lbry peer id, base58
|
||||||
|
'installation_id': installation id, base58
|
||||||
|
'is_running': bool
|
||||||
|
'is_first_run': bool
|
||||||
|
'startup_status': {
|
||||||
|
'code': status code
|
||||||
|
'message': status message
|
||||||
|
},
|
||||||
|
'connection_status': {
|
||||||
|
'code': connection status code
|
||||||
|
'message': connection status message
|
||||||
|
},
|
||||||
|
'blockchain_status': {
|
||||||
|
'blocks': local blockchain height,
|
||||||
|
'blocks_behind': remote_height - local_height,
|
||||||
|
'best_blockhash': block hash of most recent block,
|
||||||
|
},
|
||||||
|
|
||||||
|
If given the session status option:
|
||||||
|
'session_status': {
|
||||||
|
'managed_blobs': count of blobs in the blob manager,
|
||||||
|
'managed_streams': count of streams in the file manager
|
||||||
|
}
|
||||||
|
|
||||||
|
If given the dht status option:
|
||||||
|
'dht_status': {
|
||||||
|
'kbps_received': current kbps receiving,
|
||||||
|
'kbps_sent': current kdps being sent,
|
||||||
|
'total_bytes_sent': total bytes sent
|
||||||
|
'total_bytes_received': total bytes received
|
||||||
|
'queries_received': number of queries received per second
|
||||||
|
'queries_sent': number of queries sent per second
|
||||||
|
'recent_contacts': count of recently contacted peers
|
||||||
|
'unique_contacts': count of unique peers
|
||||||
|
}
|
||||||
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# on startup, the wallet or network won't be available but we still need this call to work
|
# on startup, the wallet or network won't be available but we still need this call to work
|
||||||
|
|
Loading…
Reference in a new issue