use of org.hyperledger.besu.consensus.common.BlockInterface in project besu by hyperledger.
the class CliqueQueryPluginServiceFactory method appendPluginServices.
@Override
public void appendPluginServices(final BesuPluginContextImpl besuContext) {
final BlockInterface blockInterface = new CliqueBlockInterface();
final PoaQueryServiceImpl service = new PoaQueryServiceImpl(blockInterface, blockchain, nodeKey);
besuContext.addService(PoaQueryService.class, service);
besuContext.addService(PoAMetricsService.class, service);
}
use of org.hyperledger.besu.consensus.common.BlockInterface in project besu by hyperledger.
the class ProposeTest method setup.
@Before
public void setup() {
final Blockchain blockchain = mock(Blockchain.class);
final EpochManager epochManager = mock(EpochManager.class);
final BlockInterface blockInterface = mock(BlockInterface.class);
validatorProvider = BlockValidatorProvider.nonForkingValidatorProvider(blockchain, epochManager, blockInterface);
}
use of org.hyperledger.besu.consensus.common.BlockInterface in project besu by hyperledger.
the class CliqueBlockChoiceTests method setup.
@Before
public void setup() {
keyPairs = IntStream.range(0, 8).mapToObj(i -> SignatureAlgorithmFactory.getInstance().generateKeyPair()).sorted(Comparator.comparing(kp -> publicKeyToAddress(kp.getPublicKey()))).collect(Collectors.toList());
addresses = keyPairs.stream().map(kp -> publicKeyToAddress(kp.getPublicKey())).collect(Collectors.toList());
headerBuilder = new BlockHeaderTestFixture();
final Block genesisBlock = createEmptyBlock(keyPairs.get(0));
blockchain = createInMemoryBlockchain(genesisBlock, new CliqueBlockHeaderFunctions());
final EpochManager epochManager = new EpochManager(30_000);
final BlockInterface blockInterface = new CliqueBlockInterface();
cliqueContext = new CliqueContext(BlockValidatorProvider.nonForkingValidatorProvider(blockchain, epochManager, blockInterface), epochManager, blockInterface);
installCliqueBlockChoiceRule(blockchain, cliqueContext);
for (int i = 1; i < keyPairs.size(); i++) {
headerBuilder.number(i);
headerBuilder.parentHash(blockchain.getChainHeadHash());
blockchain.appendBlock(createEmptyBlock(keyPairs.get(i)), List.of());
}
}
use of org.hyperledger.besu.consensus.common.BlockInterface in project besu by hyperledger.
the class QbftJsonRpcMethods method create.
@Override
protected Map<String, JsonRpcMethod> create() {
final BlockchainQueries blockchainQueries = new BlockchainQueries(context.getBlockchain(), context.getWorldStateArchive());
final BftContext bftContext = context.getConsensusContext(BftContext.class);
final BlockInterface blockInterface = bftContext.getBlockInterface();
final ValidatorProvider validatorProvider = bftContext.getValidatorProvider();
return mapOf(new QbftProposeValidatorVote(validatorProvider), new QbftGetValidatorsByBlockNumber(blockchainQueries, readOnlyValidatorProvider), new QbftDiscardValidatorVote(validatorProvider), new QbftGetValidatorsByBlockHash(context.getBlockchain(), readOnlyValidatorProvider), new QbftGetSignerMetrics(readOnlyValidatorProvider, blockInterface, blockchainQueries), new QbftGetPendingVotes(validatorProvider));
}
use of org.hyperledger.besu.consensus.common.BlockInterface in project besu by hyperledger.
the class IbftJsonRpcMethods method create.
@Override
protected Map<String, JsonRpcMethod> create() {
final MutableBlockchain blockchain = context.getBlockchain();
final BlockchainQueries blockchainQueries = new BlockchainQueries(blockchain, context.getWorldStateArchive());
final BftContext bftContext = context.getConsensusContext(BftContext.class);
final BlockInterface blockInterface = bftContext.getBlockInterface();
final ValidatorProvider validatorProvider = context.getConsensusContext(BftContext.class).getValidatorProvider();
// Must create our own voteTallyCache as using this would pollute the main voteTallyCache
final ValidatorProvider readOnlyValidatorProvider = createValidatorProvider(context, blockchain);
return mapOf(new IbftProposeValidatorVote(validatorProvider), new IbftGetValidatorsByBlockNumber(blockchainQueries, blockInterface), new IbftDiscardValidatorVote(validatorProvider), new IbftGetValidatorsByBlockHash(blockchain, blockInterface), new IbftGetSignerMetrics(readOnlyValidatorProvider, blockInterface, blockchainQueries), new IbftGetPendingVotes(validatorProvider));
}
Aggregations