예제 #1
0
    def _set_peer_node_health(self, peer_wallet_address: Address,
                              after_block_number: BlockNumber,
                              peer_node_health: PeerNodeHealth) -> None:
        encoded_peer_node_health = rlp.encode(peer_node_health,
                                              sedes=PeerNodeHealth)
        key = SchemaV1.make_peer_node_health_lookup(peer_wallet_address,
                                                    after_block_number)

        self.db[key] = encoded_peer_node_health
예제 #2
0
    def _get_peer_node_health(
            self, peer_wallet_address: Address,
            after_block_number: BlockNumber) -> PeerNodeHealth:
        validate_canonical_address(peer_wallet_address, title="Value")
        validate_uint64(after_block_number, 'block_number')

        key = SchemaV1.make_peer_node_health_lookup(peer_wallet_address,
                                                    after_block_number)
        try:
            rlp_peer_node_health = self.db[key]
            peer_node_health = rlp.decode(rlp_peer_node_health,
                                          sedes=PeerNodeHealth)
        except KeyError:
            peer_node_health = PeerNodeHealth()

        return peer_node_health