Esempio n. 1
0
async def _setup_alice_and_bob_factories(alice_chain_db, bob_chain_db):
    cancel_token = CancelToken(
        'trinity.get_directly_linked_peers_without_handshake')

    #
    # Alice
    #
    alice_context = BeaconContext(
        chain_db=alice_chain_db,
        network_id=1,
    )

    alice_factory = BCCPeerFactory(
        privkey=ecies.generate_privkey(),
        context=alice_context,
        token=cancel_token,
    )

    #
    # Bob
    #
    bob_context = BeaconContext(
        chain_db=bob_chain_db,
        network_id=1,
    )

    bob_factory = BCCPeerFactory(
        privkey=ecies.generate_privkey(),
        context=bob_context,
        token=cancel_token,
    )

    return alice_factory, bob_factory
Esempio n. 2
0
 def _make_peer_pool(self) -> BCCPeerPool:
     context = BeaconContext(
         chain_db=cast(BaseAsyncBeaconChainDB, self.chaindb),
         network_id=self.network_id,
     )
     return BCCPeerPool(privkey=self.privkey,
                        max_peers=self.max_peers,
                        context=context,
                        token=self.cancel_token,
                        event_bus=self.event_bus)
Esempio n. 3
0
 def _make_peer_pool(self) -> BCCPeerPool:
     context = BeaconContext(
         chain_db=cast(BaseAsyncBeaconChainDB, self.chaindb),
         network_id=self.network_id,
         genesis_slot=SERENITY_CONFIG.GENESIS_SLOT,
     )
     return BCCPeerPool(privkey=self.privkey,
                        max_peers=self.max_peers,
                        context=context,
                        token=self.cancel_token,
                        event_bus=self.event_bus)
Esempio n. 4
0
 def _make_peer_pool(self) -> BCCPeerPool:
     context = BeaconContext(
         chain_db=cast(BaseAsyncBeaconChainDB, self.chaindb),
         network_id=self.network_id,
         client_version_string=construct_trinity_client_identifier(),
         listen_port=self.port,
     )
     return BCCPeerPool(privkey=self.privkey,
                        max_peers=self.max_peers,
                        context=context,
                        token=self.cancel_token,
                        event_bus=self.event_bus)
Esempio n. 5
0
 def _make_peer_pool(self) -> BCCPeerPool:
     context = BeaconContext(
         chain_db=self.chaindb,
         network_id=self.network_id,
         client_version_string=self.p2p_handshake_params.client_version_string,
         listen_port=self.p2p_handshake_params.listen_port,
         p2p_version=self.p2p_handshake_params.version,
     )
     return BCCPeerPool(
         privkey=self.privkey,
         max_peers=self.max_peers,
         context=context,
         token=self.cancel_token,
         event_bus=self.event_bus
     )
Esempio n. 6
0
 def _make_peer_pool(self) -> BCCPeerPool:
     # mypy things that `self.chaindb` is the wrong type here.
     context = BeaconContext(  # type: ignore
         chain_db=self.chaindb,
         network_id=self.network_id,
         client_version_string=self.p2p_handshake_params.client_version_string,
         listen_port=self.p2p_handshake_params.listen_port,
         p2p_version=self.p2p_handshake_params.version,
     )
     return BCCPeerPool(
         privkey=self.privkey,
         max_peers=self.max_peers,
         context=context,
         token=self.cancel_token,
         event_bus=self.event_bus
     )