Exemple #1
0
    def rpc_get_zonefiles(self, src_hostport, dest_hostport, zonefile_hashes):
        """
        Get the list of zonefiles, given the zonefile hashes (with simulated loss)
        Returns [{'zonefile hash': zonefile data}]
        """
        log.debug("atlas network: get_zonefiles(%s,%s)" %
                  (src_hostport, dest_hostport))
        self.possibly_drop(src_hostport, dest_hostport)

        dest_host, dest_port = url_to_host_port(dest_hostport)
        rpc = BlockstackRPCClient(dest_host, dest_port, src=src_hostport)
        return rpc.get_zonefiles('atlas_network', src_hostport, dest_hostport,
                                 zonefile_hashes)
Exemple #2
0
class AtlasRPCTestClient(object):
    def __init__(self, host, port, timeout=60, src=None):
        self.rpc = BlockstackRPCClient("127.0.0.1",
                                       ATLAS_TESTNET_PORT,
                                       timeout=timeout)
        self.src_hostport = src
        self.dest_hostport = "%s:%s" % (host, port)
        self.timeout = timeout

    def get_atlas_peers(self):
        """
        Get atlas peers from the destination
        """
        return self.rpc.get_atlas_peers('atlas_network', self.src_hostport,
                                        self.dest_hostport)

    def atlas_peer_exchange(self, remote_peer):
        """
        Exchange this peer with the remote peer's neighbors
        """
        return self.rpc.atlas_peer_exchange('atlas_network', self.src_hostport,
                                            self.dest_hostport, remote_peer)

    def get_zonefile_inventory(self, bit_offset, bit_len):
        """
        Get zonefile inventory from the given dest hostport, with simulated loss
        """
        return self.rpc.get_zonefile_inventory('atlas_network',
                                               self.src_hostport,
                                               self.dest_hostport, bit_offset,
                                               bit_len)

    def get_zonefiles(self, zonefile_hashes):
        """
        Get the list of zonefiles, given the zonefile hashes (with simulated loss)
        Returns [{'zonefile hash': zonefile data}]
        """
        return self.rpc.get_zonefiles('atlas_network', self.src_hostport,
                                      self.dest_hostport, zonefile_hashes)

    def put_zonefiles(self, zonefile_info):
        """
        Upload a list of zonefiles, and enqueue them in the pusher
        """
        return self.rpc.put_zonefiles('atlas_network', self.src_hostport,
                                      self.dest_hostport, zonefile_info)

    def ping(self):
        """
        Ping!
        """
        return self.rpc.ping('atlas_network', self.src_hostport,
                             self.dest_hostport)

    def getinfo(self):
        """
        get server info
        """
        return self.rpc.getinfo('atlas_network', self.src_hostport,
                                self.dest_hostport)

    def add_sleep_deadline(self, hostport, procname, value):
        """
        make the node sleep
        """
        return self.rpc.add_sleep_deadline(hostport, procname, value)

    def max_neighbors(self):
        """
        get max neighbors
        """
        return self.rpc.max_neighbors()

    def peer_lifetime_interval(self):
        """
        peer lifetime interval
        """
        return self.rpc.peer_lifetime_interval()

    def peer_ping_interval(self):
        """
        peer ping interval
        """
        return self.rpc.peer_ping_interval()

    def peer_max_age(self):
        """
        peer max age
        """
        return self.rpc.peer_max_age()

    def peer_clean_interval(self):
        """
        peer clean interval
        """
        return self.rpc.peer_clean_interval()

    def ping_timeout(self):
        """
        ping timeout
        """
        return self.rpc.ping_timeout()

    def inv_timeout(self):
        """
        inv timeout
        """
        return self.rpc.inv_timeout()

    def neighbors_timeout(self):
        """
        getneighbors timeout
        """
        return self.rpc.neighbors_timeout()

    def zonefiles_timeout(self):
        """
        zonefiles timeout
        """
        return self.rpc.zonefiles_timeout()

    def push_zonefiles_timeout(self):
        """
        push zonefiles timeout
        """
        return self.rpc.push_zonefiles_timeout()

    def time_now(self):
        """
        time now
        """
        return self.rpc.time_now()