Пример #1
0
def test_get_v5_topic():
    les_topic = discovery.get_v5_topic(LESProtocolV1,
                                       ROPSTEN_GENESIS_HEADER.hash)
    assert les_topic == b'LES@41941023680923e0'
    les2_topic = discovery.get_v5_topic(LESProtocolV2,
                                        ROPSTEN_GENESIS_HEADER.hash)
    assert les2_topic == b'LES2@41941023680923e0'
Пример #2
0
def get_discv5_topic(trinity_config: TrinityConfig, protocol: Type[Protocol]) -> bytes:
    db_manager = create_db_consumer_manager(trinity_config.database_ipc_path)

    header_db = db_manager.get_headerdb()  # type: ignore
    genesis_hash = header_db.get_canonical_block_hash(BlockNumber(GENESIS_BLOCK_NUMBER))

    return get_v5_topic(protocol, genesis_hash)
Пример #3
0
 def _get_discv5_topic(self) -> bytes:
     genesis_hash = self.headerdb.get_canonical_block_hash(
         BlockNumber(GENESIS_BLOCK_NUMBER))
     # For now DiscoveryByTopicProtocol supports a single topic, so we use the latest version
     # of our supported protocols.
     proto = self.peer_class._supported_sub_protocols[-1]
     return get_v5_topic(proto, genesis_hash)
Пример #4
0
def get_discv5_topic(trinity_config: TrinityConfig,
                     protocol: Type[Protocol]) -> bytes:
    db = DBClient.connect(trinity_config.database_ipc_path)

    header_db = HeaderDB(db)
    genesis_hash = header_db.get_canonical_block_hash(
        BlockNumber(GENESIS_BLOCK_NUMBER))

    return get_v5_topic(protocol, genesis_hash)
Пример #5
0
def get_discv5_topic(trinity_config: TrinityConfig, protocol: Protocol):
    db_manager = create_db_manager(trinity_config.database_ipc_path)
    db_manager.connect()

    header_db = db_manager.get_headerdb()
    genesis_hash = header_db.get_canonical_block_hash(
        BlockNumber(GENESIS_BLOCK_NUMBER))

    return get_v5_topic(protocol, genesis_hash)