Search in sources :

Example 1 with MetadataMessagesFactory

use of tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.MetadataMessagesFactory in project teku by ConsenSys.

the class BeaconChainMethods method createMetadata.

private static Eth2RpcMethod<EmptyMessage, MetadataMessage> createMetadata(final Spec spec, final AsyncRunner asyncRunner, final MetadataMessagesFactory metadataMessagesFactory, final PeerLookup peerLookup, final RpcEncoding rpcEncoding) {
    final MetadataMessageHandler messageHandler = new MetadataMessageHandler(spec, metadataMessagesFactory);
    final EmptyMessageSchema requestType = EmptyMessage.SSZ_SCHEMA;
    final boolean expectResponse = true;
    final SszSchema<MetadataMessage> phase0MetadataSchema = SszSchema.as(MetadataMessage.class, spec.forMilestone(SpecMilestone.PHASE0).getSchemaDefinitions().getMetadataMessageSchema());
    final RpcContextCodec<?, MetadataMessage> phase0ContextCodec = RpcContextCodec.noop(phase0MetadataSchema);
    final SingleProtocolEth2RpcMethod<EmptyMessage, MetadataMessage> v1Method = new SingleProtocolEth2RpcMethod<>(asyncRunner, BeaconChainMethodIds.GET_METADATA, 1, rpcEncoding, requestType, expectResponse, phase0ContextCodec, messageHandler, peerLookup);
    if (spec.isMilestoneSupported(SpecMilestone.ALTAIR)) {
        final SszSchema<MetadataMessage> altairMetadataSchema = SszSchema.as(MetadataMessage.class, spec.forMilestone(SpecMilestone.ALTAIR).getSchemaDefinitions().getMetadataMessageSchema());
        final RpcContextCodec<?, MetadataMessage> altairContextCodec = RpcContextCodec.noop(altairMetadataSchema);
        final SingleProtocolEth2RpcMethod<EmptyMessage, MetadataMessage> v2Method = new SingleProtocolEth2RpcMethod<>(asyncRunner, BeaconChainMethodIds.GET_METADATA, 2, rpcEncoding, requestType, expectResponse, altairContextCodec, messageHandler, peerLookup);
        return VersionedEth2RpcMethod.create(rpcEncoding, requestType, expectResponse, List.of(v2Method, v1Method));
    } else {
        return v1Method;
    }
}
Also used : MetadataMessageHandler(tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.MetadataMessageHandler) SingleProtocolEth2RpcMethod(tech.pegasys.teku.networking.eth2.rpc.core.methods.SingleProtocolEth2RpcMethod) MetadataMessage(tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.MetadataMessage) EmptyMessageSchema(tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EmptyMessage.EmptyMessageSchema) EmptyMessage(tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EmptyMessage)

Example 2 with MetadataMessagesFactory

use of tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.MetadataMessagesFactory in project teku by ConsenSys.

the class Eth2PeerManager method create.

public static Eth2PeerManager create(final AsyncRunner asyncRunner, final RecentChainData recentChainData, final StorageQueryChannel historicalChainData, final MetricsSystem metricsSystem, final SubnetSubscriptionService attestationSubnetService, final SubnetSubscriptionService syncCommitteeSubnetService, final RpcEncoding rpcEncoding, final Optional<Checkpoint> requiredCheckpoint, final Duration eth2RpcPingInterval, final int eth2RpcOutstandingPingThreshold, final Duration eth2StatusUpdateInterval, final TimeProvider timeProvider, final int peerRateLimit, final int peerRequestLimit, final Spec spec) {
    final StatusMessageFactory statusMessageFactory = new StatusMessageFactory(recentChainData);
    final MetadataMessagesFactory metadataMessagesFactory = new MetadataMessagesFactory();
    attestationSubnetService.subscribeToUpdates(metadataMessagesFactory::updateAttestationSubnetIds);
    syncCommitteeSubnetService.subscribeToUpdates(metadataMessagesFactory::updateSyncCommitteeSubnetIds);
    final CombinedChainDataClient combinedChainDataClient = new CombinedChainDataClient(recentChainData, historicalChainData, spec);
    return new Eth2PeerManager(spec, asyncRunner, combinedChainDataClient, recentChainData, metricsSystem, new Eth2PeerFactory(spec, metricsSystem, combinedChainDataClient, statusMessageFactory, metadataMessagesFactory, timeProvider, requiredCheckpoint, peerRateLimit, peerRequestLimit), statusMessageFactory, metadataMessagesFactory, rpcEncoding, eth2RpcPingInterval, eth2RpcOutstandingPingThreshold, eth2StatusUpdateInterval);
}
Also used : MetadataMessagesFactory(tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.MetadataMessagesFactory) CombinedChainDataClient(tech.pegasys.teku.storage.client.CombinedChainDataClient) StatusMessageFactory(tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.StatusMessageFactory)

Example 3 with MetadataMessagesFactory

use of tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.MetadataMessagesFactory in project teku by ConsenSys.

the class BeaconChainMethods method createPing.

private static Eth2RpcMethod<PingMessage, PingMessage> createPing(final AsyncRunner asyncRunner, final MetadataMessagesFactory metadataMessagesFactory, final PeerLookup peerLookup, final RpcEncoding rpcEncoding) {
    final PingMessageHandler statusHandler = new PingMessageHandler(metadataMessagesFactory);
    final RpcContextCodec<?, PingMessage> contextCodec = RpcContextCodec.noop(PingMessage.SSZ_SCHEMA);
    return new SingleProtocolEth2RpcMethod<>(asyncRunner, BeaconChainMethodIds.PING, 1, rpcEncoding, PingMessage.SSZ_SCHEMA, true, contextCodec, statusHandler, peerLookup);
}
Also used : SingleProtocolEth2RpcMethod(tech.pegasys.teku.networking.eth2.rpc.core.methods.SingleProtocolEth2RpcMethod) PingMessageHandler(tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.PingMessageHandler) PingMessage(tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.PingMessage)

Aggregations

SingleProtocolEth2RpcMethod (tech.pegasys.teku.networking.eth2.rpc.core.methods.SingleProtocolEth2RpcMethod)2 MetadataMessageHandler (tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.MetadataMessageHandler)1 MetadataMessagesFactory (tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.MetadataMessagesFactory)1 PingMessageHandler (tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.PingMessageHandler)1 StatusMessageFactory (tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.StatusMessageFactory)1 EmptyMessage (tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EmptyMessage)1 EmptyMessageSchema (tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EmptyMessage.EmptyMessageSchema)1 PingMessage (tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.PingMessage)1 MetadataMessage (tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.MetadataMessage)1 CombinedChainDataClient (tech.pegasys.teku.storage.client.CombinedChainDataClient)1