Search in sources :

Example 6 with Self

use of com.radixdlt.hotstuff.bft.Self in project radixdlt by radixdlt.

the class SimulationNodes method createBFTModule.

private Module createBFTModule(ECKeyPair self) {
    Module module = Modules.combine(new AbstractModule() {

        @Provides
        @Self
        private BFTNode self() {
            return BFTNode.create(self.getPublicKey());
        }

        @Provides
        @Self
        private ECPublicKey key() {
            return self.getPublicKey();
        }

        @Provides
        private ECKeyPair keyPair() {
            return self;
        }

        @Provides
        @LocalSigner
        HashSigner hashSigner() {
            return self::sign;
        }
    }, new NodeNetworkMessagesModule(underlyingNetwork), baseModule);
    // can break network behavior if incorrect modules are used
    if (overrideModules.containsKey(self.getPublicKey())) {
        final var nodeOverrideModules = overrideModules.get(self.getPublicKey());
        module = Modules.override(module).with(nodeOverrideModules);
    }
    return module;
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) ECPublicKey(com.radixdlt.crypto.ECPublicKey) LocalSigner(com.radixdlt.qualifier.LocalSigner) NodeNetworkMessagesModule(com.radixdlt.harness.simulation.NodeNetworkMessagesModule) ECKeyPair(com.radixdlt.crypto.ECKeyPair) HashSigner(com.radixdlt.hotstuff.HashSigner) Self(com.radixdlt.hotstuff.bft.Self) Module(com.google.inject.Module) NodeNetworkMessagesModule(com.radixdlt.harness.simulation.NodeNetworkMessagesModule) AbstractModule(com.google.inject.AbstractModule) Provides(com.google.inject.Provides) AbstractModule(com.google.inject.AbstractModule)

Example 7 with Self

use of com.radixdlt.hotstuff.bft.Self in project radixdlt by radixdlt.

the class Radix method start.

public static void start(RuntimeProperties properties) {
    long start = System.currentTimeMillis();
    var injector = Guice.createInjector(new RadixNodeModule(properties));
    final Map<String, ModuleRunner> moduleRunners = injector.getInstance(Key.get(new TypeLiteral<Map<String, ModuleRunner>>() {
    }));
    final var p2pNetworkRunner = moduleRunners.get(Runners.P2P_NETWORK);
    p2pNetworkRunner.start();
    final var systemInfoRunner = moduleRunners.get(Runners.SYSTEM_INFO);
    systemInfoRunner.start();
    final var syncRunner = moduleRunners.get(Runners.SYNC);
    syncRunner.start();
    final var mempoolReceiverRunner = moduleRunners.get(Runners.MEMPOOL);
    mempoolReceiverRunner.start();
    final var peerServer = injector.getInstance(PeerServerBootstrap.class);
    try {
        peerServer.start();
    } catch (InterruptedException e) {
        log.error("Cannot start p2p server", e);
    }
    final var undertow = injector.getInstance(Undertow.class);
    undertow.start();
    final var consensusRunner = moduleRunners.get(Runners.CONSENSUS);
    consensusRunner.start();
    final BFTNode self = injector.getInstance(Key.get(BFTNode.class, Self.class));
    long finish = System.currentTimeMillis();
    var systemCounters = injector.getInstance(SystemCounters.class);
    systemCounters.set(SystemCounters.CounterType.STARTUP_TIME_MS, finish - start);
    Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdown(injector)));
    log.info("Node '{}' started successfully in {} seconds", self, (finish - start) / 1000);
}
Also used : BFTNode(com.radixdlt.hotstuff.bft.BFTNode) TypeLiteral(com.google.inject.TypeLiteral) ModuleRunner(com.radixdlt.modules.ModuleRunner) RadixNodeModule(com.radixdlt.RadixNodeModule) Self(com.radixdlt.hotstuff.bft.Self)

Aggregations

Self (com.radixdlt.hotstuff.bft.Self)7 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)5 AbstractModule (com.google.inject.AbstractModule)3 TypeLiteral (com.google.inject.TypeLiteral)3 HashSigner (com.radixdlt.hotstuff.HashSigner)3 SystemCounters (com.radixdlt.counters.SystemCounters)2 ECKeyPair (com.radixdlt.crypto.ECKeyPair)2 ECPublicKey (com.radixdlt.crypto.ECPublicKey)2 EventDispatcher (com.radixdlt.environment.EventDispatcher)2 RemoteEventDispatcher (com.radixdlt.environment.RemoteEventDispatcher)2 ScheduledEventDispatcher (com.radixdlt.environment.ScheduledEventDispatcher)2 BFTConfiguration (com.radixdlt.hotstuff.BFTConfiguration)2 HighQC (com.radixdlt.hotstuff.HighQC)2 Proposal (com.radixdlt.hotstuff.Proposal)2 Vote (com.radixdlt.hotstuff.Vote)2 BFTCommittedUpdate (com.radixdlt.hotstuff.bft.BFTCommittedUpdate)2 BFTHighQCUpdate (com.radixdlt.hotstuff.bft.BFTHighQCUpdate)2 BFTInsertUpdate (com.radixdlt.hotstuff.bft.BFTInsertUpdate)2 BFTRebuildUpdate (com.radixdlt.hotstuff.bft.BFTRebuildUpdate)2 BFTValidatorSet (com.radixdlt.hotstuff.bft.BFTValidatorSet)2