master
dsc 3 years ago
parent 9b213f94a7
commit a5a589a083

@ -6,22 +6,15 @@
Ask a node for it's peer list, sorted on `last_seen`:
`python3 peer_retreiver.py 212.83.175.67 18080`
`python3 peer_retreiver.py 145.239.93.75 34567`
```python
>> created packet 'handshake'
>> sent packet 'handshake'
<< received packet 'support_flags'
<< parsed packet 'support_flags'
<< received packet 'handshake'
<< parsed packet 'handshake'
99.48.XX.XX:18080
62.24.XX.XX:18080
93.44.XX.XX:18080
238.137.XX.XX:18080
163.86.XX.XX:18080
250.227.XX.XX:18080
99.48.XX.XX:34567
62.24.XX.XX:34567
93.44.XX.XX:34567
238.137.XX.XX:34567
163.86.XX.XX:34567
250.227.XX.XX:34567
[...]
```
@ -38,10 +31,10 @@ A Levin header (33 bytes) looks like this:
5. `u_int32` - Protocol version. Usually `01`
The payload that comes after that is a serialized Boost struct, which can be found
in the Monero codebase, e.g: [cryptonote_protocol_defs.h](https://github.com/monero-project/monero/blob/58ce16d4d91518b674a5d46419809f56f71d9114/src/cryptonote_protocol/cryptonote_protocol_defs.h).
in the Wownero codebase, e.g: `cryptonote_protocol_defs.h`.
The terminology for a (possible nested collection) of structs is called a `Section()` in this module.
For the actual serialization from the perspective of Monero, check out [portable_storage_to_bin.h](https://github.com/monero-project/monero/blob/58ce16d4d91518b674a5d46419809f56f71d9114/contrib/epee/include/storages/portable_storage_to_bin.h)
For the actual serialization from the perspective of Wownero, check out `portable_storage_to_bin.h`.
For deserialization look at `Reader.read_storage_entry()` and `Reader.read()`.
@ -61,4 +54,4 @@ Lastly, this module is presented as 'best effort' and, for example, does not gua
### License
© 2018 WTFPL Do What the Fuck You Want to Public License
© 2018 WTFPL Do What the Fuck You Want to Public License

@ -27,14 +27,13 @@ class Section:
@classmethod
def handshake_request(cls, my_port: int = 0, network_id: bytes = None, peer_id: bytes = None):
if not network_id:
network_id = bytes.fromhex("1230f171610441611731008216a1a110") # mainnet
network_id = bytes.fromhex("1133ff77610441611731008216a1a110") # mainnet
if not peer_id:
peer_id = random.getrandbits(64)
section = cls()
node_data = Section()
# node_data.add("local_time", c_uint64(0x4141414141414141))
node_data.add("local_time", c_uint64(int(time())))
node_data.add("my_port", c_uint32(my_port))
node_data.add("network_id", c_string(network_id))
node_data.add("peer_id", c_uint64(peer_id))
@ -42,10 +41,11 @@ class Section:
payload_data = Section()
payload_data.add("cumulative_difficulty", c_uint64(1))
payload_data.add("cumulative_difficulty_top64", c_uint64(1))
payload_data.add("current_height", c_uint64(1))
genesis_hash = bytes.fromhex("418015bb9ae982a1975da7d79277c2705727a56894ba0fb246adaabb1f4632e3") # genesis
genesis_hash = bytes.fromhex("880f85e2fbb1fe6b870eb54cf96975838e059aac00b8b1212702db222007161b") # wat
payload_data.add("top_id", c_string(genesis_hash))
payload_data.add("top_version", c_ubyte(1))
payload_data.add("top_version", c_ubyte(17))
section.add("payload_data", payload_data)
return section

@ -21,8 +21,11 @@ except:
bucket = Bucket.create_handshake_request()
sock.send(bucket.header())
sock.send(bucket.payload())
head = bucket.header()
body = bucket.payload()
sock.send(head)
sock.send(body)
# print(">> sent packet \'%s\'" % P2P_COMMANDS[bucket.command])

Loading…
Cancel
Save