New splitting logic for Arrangement; including ether address.

pull/318/head
jMyles 2018-06-17 00:47:41 -07:00
parent 4a1c208742
commit e867f495b9
2 changed files with 9 additions and 8 deletions

View File

@ -277,18 +277,19 @@ class ProxyRESTServer:
# TODO: This function is the epitome of #172.
treasure_map_id = binascii.unhexlify(treasure_map_id_as_hex)
header, signature_for_ursula, pubkey_sig_alice, hrac, tmap_message_kit = \
header, signature_for_ursula, pubkey_sig_alice, ether_address, hrac, tmap_message_kit = \
dht_with_hrac_splitter(request.body, return_remainder=True)
# TODO: This next line is possibly the worst in the entire codebase at the moment. #172.
# Also TODO: TTL?
do_store = self.dht_server.protocol.determine_legality_of_dht_key(
signature_for_ursula, pubkey_sig_alice, tmap_message_kit,
signature_for_ursula, pubkey_sig_alice,
hrac, digest(treasure_map_id), request.body)
if do_store:
# TODO: Stop storing things in the protocol storage. Do this better. #227
# TODO: Propagate to other nodes. #235
# TODO: Store the ether address?
self.dht_server.protocol.storage[digest(treasure_map_id)] = request.body
return # TODO: Proper response here.
return # TODO: Proper response here.
else:
# TODO: Make this a proper 500 or whatever.
assert False

View File

@ -57,7 +57,7 @@ class Arrangement:
def __bytes__(self):
return bytes(self.alice.stamp) + bytes(
self.hrac) + self.expiration.iso8601().encode()
self.hrac()) + self.expiration.iso8601().encode()
def id(self):
if not self.ursula:
@ -182,13 +182,13 @@ class Policy:
# In order to know this is safe to propagate, Ursula needs to see a signature, our public key,
# and, reasons explained in treasure_map_dht_key above, the uri_hash.
# TODO: Clean this up. See #172.
map_payload = signature_for_ursula + self.alice.stamp + self.hrac() + tmap_message_kit.to_bytes()
map_payload = signature_for_ursula + self.alice.stamp + self.alice.public_address + self.hrac() + tmap_message_kit.to_bytes()
map_id = self.treasure_map_dht_key()
if not self.alice.known_nodes:
if not self.alice._known_nodes:
raise RuntimeError("Alice hasn't learned of any nodes. Thus, she can't push the TreasureMap.")
for node in self.alice.known_nodes.values():
for node in self.alice._known_nodes.values():
response = network_middleare.push_treasure_map_to_node(node, map_id,
constants.BYTESTRING_IS_TREASURE_MAP + map_payload)
# TODO: Do something here based on success or failure
@ -205,7 +205,7 @@ class Policy:
while len(self._enacted_arrangements) > 0:
kfrag, arrangement = self._enacted_arrangements.popitem()
arrangement.publish(arrangement.kfrag) # TODO
arrangement.publish()
def __assign_kfrags(self) -> Generator[Arrangement, None, None]: