Search in sources :

Example 1 with LocalSigner

use of com.radixdlt.qualifier.LocalSigner 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 2 with LocalSigner

use of com.radixdlt.qualifier.LocalSigner in project radixdlt by radixdlt.

the class SimulationNodes method createBFTInstance.

private Injector createBFTInstance(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
        @LocalSigner
        HashSigner hashSigner() {
            return self::sign;
        }
    }, new NodeNetworkMessagesModule(underlyingNetwork), baseModule);
    // can break network behavior if incorrect modules are used
    if (overrideModule != null) {
        module = Modules.override(module).with(overrideModule);
    }
    Module byzantineModule = byzantineNodeModules.get(self);
    if (byzantineModule != null) {
        module = Modules.override(module).with(byzantineModule);
    }
    return Guice.createInjector(module);
}
Also used : BFTNode(com.radixdlt.consensus.bft.BFTNode) ECPublicKey(com.radixdlt.crypto.ECPublicKey) LocalSigner(com.radixdlt.qualifier.LocalSigner) NodeNetworkMessagesModule(com.radixdlt.harness.simulation.NodeNetworkMessagesModule) HashSigner(com.radixdlt.consensus.HashSigner) Self(com.radixdlt.consensus.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)

Aggregations

AbstractModule (com.google.inject.AbstractModule)2 Module (com.google.inject.Module)2 Provides (com.google.inject.Provides)2 ECPublicKey (com.radixdlt.crypto.ECPublicKey)2 NodeNetworkMessagesModule (com.radixdlt.harness.simulation.NodeNetworkMessagesModule)2 LocalSigner (com.radixdlt.qualifier.LocalSigner)2 HashSigner (com.radixdlt.consensus.HashSigner)1 BFTNode (com.radixdlt.consensus.bft.BFTNode)1 Self (com.radixdlt.consensus.bft.Self)1 ECKeyPair (com.radixdlt.crypto.ECKeyPair)1 HashSigner (com.radixdlt.hotstuff.HashSigner)1 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)1 Self (com.radixdlt.hotstuff.bft.Self)1