mirror of https://github.com/nucypher/nucypher.git
New splitting logic for Arrangement; including ether address.
parent
4a1c208742
commit
e867f495b9
|
@ -277,16 +277,17 @@ class ProxyRESTServer:
|
||||||
# TODO: This function is the epitome of #172.
|
# TODO: This function is the epitome of #172.
|
||||||
treasure_map_id = binascii.unhexlify(treasure_map_id_as_hex)
|
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)
|
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.
|
# TODO: This next line is possibly the worst in the entire codebase at the moment. #172.
|
||||||
# Also TODO: TTL?
|
# Also TODO: TTL?
|
||||||
do_store = self.dht_server.protocol.determine_legality_of_dht_key(
|
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)
|
hrac, digest(treasure_map_id), request.body)
|
||||||
if do_store:
|
if do_store:
|
||||||
# TODO: Stop storing things in the protocol storage. Do this better. #227
|
# TODO: Stop storing things in the protocol storage. Do this better. #227
|
||||||
# TODO: Propagate to other nodes. #235
|
# TODO: Propagate to other nodes. #235
|
||||||
|
# TODO: Store the ether address?
|
||||||
self.dht_server.protocol.storage[digest(treasure_map_id)] = request.body
|
self.dht_server.protocol.storage[digest(treasure_map_id)] = request.body
|
||||||
return # TODO: Proper response here.
|
return # TODO: Proper response here.
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Arrangement:
|
||||||
|
|
||||||
def __bytes__(self):
|
def __bytes__(self):
|
||||||
return bytes(self.alice.stamp) + bytes(
|
return bytes(self.alice.stamp) + bytes(
|
||||||
self.hrac) + self.expiration.iso8601().encode()
|
self.hrac()) + self.expiration.iso8601().encode()
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
if not self.ursula:
|
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,
|
# 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.
|
# and, reasons explained in treasure_map_dht_key above, the uri_hash.
|
||||||
# TODO: Clean this up. See #172.
|
# 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()
|
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.")
|
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,
|
response = network_middleare.push_treasure_map_to_node(node, map_id,
|
||||||
constants.BYTESTRING_IS_TREASURE_MAP + map_payload)
|
constants.BYTESTRING_IS_TREASURE_MAP + map_payload)
|
||||||
# TODO: Do something here based on success or failure
|
# TODO: Do something here based on success or failure
|
||||||
|
@ -205,7 +205,7 @@ class Policy:
|
||||||
|
|
||||||
while len(self._enacted_arrangements) > 0:
|
while len(self._enacted_arrangements) > 0:
|
||||||
kfrag, arrangement = self._enacted_arrangements.popitem()
|
kfrag, arrangement = self._enacted_arrangements.popitem()
|
||||||
arrangement.publish(arrangement.kfrag) # TODO
|
arrangement.publish()
|
||||||
|
|
||||||
def __assign_kfrags(self) -> Generator[Arrangement, None, None]:
|
def __assign_kfrags(self) -> Generator[Arrangement, None, None]:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue