MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / announce

Method announce

src/lib/subtl/subtl.py:39–67  ·  view source on GitHub ↗
(self, **kwargs)

Source from the content-addressed store, hash-verified

37 return self._send(CONNECT)
38
39 def announce(self, **kwargs):
40 if not kwargs:
41 raise UdpTrackerClientException('arguments missing')
42 args = {
43 'peer_id': self.peer_id,
44 'downloaded': 0,
45 'left': 0,
46 'uploaded': 0,
47 'event': 0,
48 'key': 0,
49 'num_want': 10,
50 'ip_address': 0,
51 'port': self.peer_port,
52 }
53 args.update(kwargs)
54
55 fields = 'info_hash peer_id downloaded left uploaded event ' \
56 'ip_address key num_want port'
57
58 # Check and raise if missing fields
59 self._check_fields(args, fields)
60
61 # Humans tend to use hex representations of the hash. Wasteful humans.
62 args['info_hash'] = args['info_hash']
63
64 values = [args[a] for a in fields.split()]
65 values[1] = values[1].encode("utf8")
66 payload = struct.pack('!20s20sQQQLLLLH', *values)
67 return self._send(ANNOUNCE, payload)
68
69 def scrape(self, info_hash_list):
70 if len(info_hash_list) > 74:

Callers 1

announceTrackerUdpMethod · 0.95

Calls 5

_check_fieldsMethod · 0.95
_sendMethod · 0.95
updateMethod · 0.45
packMethod · 0.45

Tested by

no test coverage detected