This commit is contained in:
Oskar Thoren 2019-01-09 07:29:09 -05:00
parent 33facb5d83
commit 88cb7807c7
1 changed files with 26 additions and 58 deletions

View File

@ -7,8 +7,6 @@ import time
# TODO: Expand message to be a payload with message hash # TODO: Expand message to be a payload with message hash
# TODO: Encode group with message graph and immutable messages # TODO: Encode group with message graph and immutable messages
# TODO: Introduce latency and unreliability # TODO: Introduce latency and unreliability
# TODO: send_time should be time
# TODO: Use .proto files
## TODO: Encode things like client, group scope, etc ## TODO: Encode things like client, group scope, etc
# client\_id = R(HASH\_LEN) # client\_id = R(HASH\_LEN)
@ -225,70 +223,40 @@ def new_ack_record(id):
# Mocking # Mocking
################################################################################ ################################################################################
print "\n" def run(steps=4):
n = NetworkSimulator()
n = NetworkSimulator() a = Node("A", n)
b = Node("B", n)
c = Node("C", n)
# Create nodes n.peers["A"] = a
a = Node("A", n) n.peers["B"] = b
b = Node("B", n) n.peers["C"] = c
n.nodes = [a, b, c]
# Let's say C is a peer to A but A doesn't share with C a.addPeer("B", b)
c = Node("C", n) # Passive node? a.addPeer("C", c)
b.addPeer("A", a)
c.addPeer("A", a)
# XXX: Want names as pubkey sender # NOTE: Client should decide policy, implict group
n.peers["A"] = a a.share("B")
n.peers["B"] = b b.share("A")
n.peers["C"] = c
n.nodes = [a, b, c]
a.addPeer("B", b) print "\nAssuming one group context (A-B share):"
a.addPeer("C", c)
b.addPeer("A", a) for i in range(steps):
# NOTE: include signature and parent message
if n.time == 1:
a0 = new_message_record("hello world")
a.append_message(a0)
c.addPeer("A", a) n.tick()
a.print_sync_state()
b.print_sync_state()
run()
# XXX: Client should decide sharing policy
# Encode sharing, notice C being left out
# Implicit group context
a.share("B")
b.share("A")
print "Assuming one group context (A-B share):"
# NOTE: For proof of concept this is simply a text field
# More realistic example would include sender signature, and parent message ids
a0 = new_message_record("hello world")
# XXX: remove
# TODO: send_message should be based on send_time and sharing
#a.send_message("B", a0)
n.tick()
a.print_sync_state()
b.print_sync_state()
# Local append
a.append_message(a0)
n.tick()
a.print_sync_state()
b.print_sync_state()
n.tick()
a.print_sync_state()
b.print_sync_state()
n.tick()
a.print_sync_state()
b.print_sync_state()
print "\n"
## TODO: Sync modes, interactive (+bw -latency) and batch (v.v.) ## TODO: Sync modes, interactive (+bw -latency) and batch (v.v.)