Beispiel #1
0
    def _get_eth1_tracker(cls, boot_info: BootInfo) -> BaseEth1PeerTracker:
        if not boot_info.args.enable_experimental_eth1_peer_tracking:
            return NoopEth1PeerTracker()

        backend = boot_info.args.network_tracking_backend

        if backend is TrackingBackend.SQLITE3:
            session = cls._get_database_session(boot_info)

            # TODO: correctly determine protocols and versions
            protocols = ('eth', )
            protocol_versions = (63, )

            # TODO: get genesis_hash
            return SQLiteEth1PeerTracker(
                session,
                network_id=boot_info.trinity_config.network_id,
                protocols=protocols,
                protocol_versions=protocol_versions,
            )
        elif backend is TrackingBackend.MEMORY:
            return MemoryEth1PeerTracker()
        elif backend is TrackingBackend.DO_NOT_TRACK:
            return NoopEth1PeerTracker()
        else:
            raise Exception(f"INVARIANT: {backend}")
Beispiel #2
0
    def setup_peer_backends(self) -> Tuple[BasePeerBackend, ...]:
        if self.has_event_bus:
            self.peer_tracker = EventBusEth1PeerTracker(self.get_event_bus())
        else:
            self.peer_tracker = NoopEth1PeerTracker()

        self.subscribe(self.peer_tracker)
        return super().setup_peer_backends() + (self.peer_tracker,)