Conversation
| def __init__(self, node_metadata): | ||
| super().__init__(node_metadata) | ||
| self.checksum_address = to_checksum_address(node_metadata['public_address'][0]) | ||
| self.checksum_address = to_checksum_address(self.public_address) |
There was a problem hiding this comment.
...and much more optimal. Saves a keccak and other smaller cpu-bound operations compared to the previous method.
There was a problem hiding this comment.
With other changes too, readability is certainly improved!
Relock dependencies
…atically when necessary.
…hat the (teacher) node is invalid, because we've been lazy until now.
…a bit of compatibility logic in the tests here.
| if eager: | ||
| node.mature() | ||
| stranger_certificate = node.certificate | ||
| except AttributeError: | ||
| # Probably a sprout. | ||
| try: | ||
| if grow_node_sprout_into_node: | ||
| node.mature() | ||
| stranger_certificate = node.certificate | ||
| else: | ||
| # TODO: Well, why? What about eagerness, popping listeners, etc? We not doing that stuff? NRN | ||
| return node | ||
| except Exception as e: | ||
| # Whoops, we got an Alice, Bob, or something totally wrong... | ||
| raise self.NotATeacher(f"{node.__class__.__name__} does not have a certificate and cannot be remembered.") | ||
|
|
||
| # Store node's certificate - It has been seen. | ||
| certificate_filepath = self.node_storage.store_node_certificate(certificate=stranger_certificate) | ||
| # Store node's certificate - It has been seen. | ||
| certificate_filepath = self.node_storage.store_node_certificate(certificate=stranger_certificate) | ||
|
|
||
| # In some cases (seed nodes or other temp stored certs), | ||
| # this will update the filepath from the temp location to this one. | ||
| node.certificate_filepath = certificate_filepath | ||
| # In some cases (seed nodes or other temp stored certs), | ||
| # this will update the filepath from the temp location to this one. | ||
| node.certificate_filepath = certificate_filepath |
There was a problem hiding this comment.
This whole thing is looking really nice now.
| verifying_keys_match = sprout.verifying_key == self.public_keys(SigningPower) | ||
| encrypting_keys_match = sprout.encrypting_key == self.public_keys(DecryptingPower) | ||
| addresses_match = sprout.public_address == self.canonical_public_address | ||
| evidence_matches = sprout.decentralized_identity_evidence == self.__decentralized_identity_evidence |
tuxxy
left a comment
There was a problem hiding this comment.
Really liking these changes.
| assert len(all_known_nodes) == len(all_stored_nodes) | ||
| assert all_stored_nodes == all_known_nodes | ||
|
|
||
| known_checksums = sorted([n.checksum_address for n in all_known_nodes]) |
There was a problem hiding this comment.
I think, [ and ] are not necessary here
There was a problem hiding this comment.
Indeed; good catch. I will include this change in #1881.
|
|
||
| # However, it learned about *all* of the nodes in its own domain. | ||
| assert set(first_domain_learners).intersection(set(new_first_domain_learner.known_nodes)) == first_domain_learners | ||
| assert set(first_domain_learners).intersection(set(n.mature() for n in new_first_domain_learner.known_nodes)) == first_domain_learners |
There was a problem hiding this comment.
Curiously, it works as .intersection(n.mature() for n in new_first_domain_learner.known_nodes), too
There was a problem hiding this comment.
Interesting - that's unexpected. But very nice. I will also include this in #1881.
A precursor to #1881, this PR integrates the changes in nucypher/bytestringSplitter#27.