make 1:1 syntax OK

This commit is contained in:
Oskar Thoren 2019-02-23 03:48:27 -05:00
parent c9c317095a
commit 1347963ff6
3 changed files with 19 additions and 3 deletions

View File

@ -124,3 +124,11 @@ enode://421a707a09d9ff08028fd9e47df876bd4cfbd873ce12cfe00702b068acf077518c5c065f
geth 7053 user 68u IPv6 141618 0t0 TCP localhost:30000->localhost:44984 (ESTABLISHED)
geth 7415 user 63u IPv4 141044 0t0 TCP localhost:44984->localhost:30000 (ESTABLISHED)
## Next steps
- End to end add several notes
- Sanity check wrt adding peers manually etc
- Figure out latency smaller

View File

@ -3,6 +3,8 @@ import networkwhisper, sync, sys, threading, time
# TODO: Consider moving sync state outside of log
# XXX: Assume {a,b}sync.log exists
# TODO: UX feedback, when recv it should show
# XXX: Ugly constants, should be elsewhere
SETTINGS = {
'a': {
@ -80,8 +82,8 @@ def main():
thread.start()
while True:
text = input("> ")
print("You wrote", text)
text = input("")
#print("You: " + text)
rec = sync.new_message_record(text)
node.append_message(rec)

View File

@ -297,7 +297,6 @@ class Node():
self.sync_state[message_id][sender_pubkey]['hold_flag'] == 1
self.sync_state[message_id][sender_pubkey]['ack_flag'] == 1
# XXX: ACK again here?
# XXX: This is bad, sender here with Whisper is only pbukey
self.sync_state[message_id][sender_pubkey] = {
"hold_flag": 1,
"ack_flag": 1,
@ -317,8 +316,15 @@ class Node():
"send_time": 0
}
# XXX: Huh, This is MESSAGE, shouldn't it be PAYLOAD inside it?
assert message.header.type == 1, "Type should be MESSAGE, possible faulty logic"
self.messages[message_id] = message
# XXX: Shortcuts, lets take 'em
text = message.payload.message.body.decode('utf-8')
short_sender = sender_pubkey[-4:]
print(short_sender + ": " + text)
def on_receive_ack(self, sender_pubkey, message):
for ack in message.payload.ack.id:
self.logger(' ACK ({} -> {}): {} received'.format(sender_pubkey[-4:], self.name[-4:], ack[-4:]))