示例#1
0
def build(network: Dict):
    assert isinstance(network, dict), network
    pool = P2PConnectionPool(connections=8,
                             batcher_timeout=30,
                             network=network['pycoin'])
    interface = P2PInterface(pool, network=network['pycoin'])
    return pool, interface
 def setUp(self):
     self.pool = Mock()
     self.loopmock = Mock()
     self.peers_bootstrapper = Mock()
     self.sut = P2PInterface(self.pool,
                             loop=self.loopmock,
                             peers_bootstrapper=self.peers_bootstrapper)
     self.loop = asyncio.get_event_loop()
示例#3
0
 def setUp(self):
     self.repository = create_autospec(Repository)
     self.mempool_repository = MempoolRepository()
     self.repository.mempool = self.mempool_repository
     self.batcher_factory = Mock()
     self.pool = P2PConnectionPool(batcher=lambda: batcher_factory(self))
     self.connection = Mock(connected=True, score=99)
     self.pool.connections.append(self.connection)
     self.p2p_interface = P2PInterface(self.pool)
     self.sut = MempoolObserver(self.repository, self.p2p_interface)
     self.loop = asyncio.get_event_loop()
示例#4
0
def build(context):
    network = context.get_network()
    assert isinstance(network, dict), network
    from spruned.daemon.bitcoin_p2p.p2p_connection import P2PConnectionPool
    from spruned.daemon.bitcoin_p2p.p2p_interface import P2PInterface
    pool = P2PConnectionPool(connections=8,
                             batcher_timeout=15,
                             network=network['pycoin'],
                             ipv6=False,
                             context=context)
    interface = P2PInterface(pool, network=network['pycoin'])
    return pool, interface
示例#5
0
def build(ctx: Context):
    network = ctx.get_network()
    assert isinstance(network, dict), network
    from spruned.daemon.bitcoin_p2p.p2p_connection import P2PConnectionPool
    from spruned.daemon.bitcoin_p2p.p2p_interface import P2PInterface
    peers = load_p2p_peers()
    print(ctx.proxy)
    pool = P2PConnectionPool(connections=8,
                             batcher_timeout=15,
                             network=network['pycoin'],
                             ipv6=False,
                             proxy=str(ctx.proxy),
                             context=ctx)
    for peer in peers:
        pool.add_peer(peer)
    interface = P2PInterface(pool, network=network['pycoin'])
    if ctx.tor:

        async def _no_dns_bootstrap(*_, **__):
            return load_p2p_peers()

        interface.peers_bootstrapper = _no_dns_bootstrap
    return pool, interface