Search in sources :

Example 1 with IbftLegacyContext

use of org.hyperledger.besu.consensus.ibft.IbftLegacyContext in project besu by hyperledger.

the class IbftLegacyBesuControllerBuilder method createConsensusContext.

@Override
protected IbftLegacyContext createConsensusContext(final Blockchain blockchain, final WorldStateArchive worldStateArchive, final ProtocolSchedule protocolSchedule) {
    final IbftLegacyConfigOptions ibftConfig = configOptionsSupplier.get().getIbftLegacyConfigOptions();
    final EpochManager epochManager = new EpochManager(ibftConfig.getEpochLength());
    final ValidatorProvider validatorProvider = BlockValidatorProvider.nonForkingValidatorProvider(blockchain, epochManager, blockInterface);
    return new IbftLegacyContext(validatorProvider, epochManager, blockInterface);
}
Also used : IbftLegacyConfigOptions(org.hyperledger.besu.config.IbftLegacyConfigOptions) IbftLegacyContext(org.hyperledger.besu.consensus.ibft.IbftLegacyContext) EpochManager(org.hyperledger.besu.consensus.common.EpochManager) BlockValidatorProvider(org.hyperledger.besu.consensus.common.validator.blockbased.BlockValidatorProvider) ValidatorProvider(org.hyperledger.besu.consensus.common.validator.ValidatorProvider)

Example 2 with IbftLegacyContext

use of org.hyperledger.besu.consensus.ibft.IbftLegacyContext in project besu by hyperledger.

the class IbftBlockHeaderValidationRulesetFactoryTest method setupContextWithValidators.

private ProtocolContext setupContextWithValidators(final Collection<Address> validators) {
    final IbftLegacyContext bftContext = mock(IbftLegacyContext.class);
    final ValidatorProvider mockValidatorProvider = mock(ValidatorProvider.class);
    when(bftContext.getValidatorProvider()).thenReturn(mockValidatorProvider);
    when(mockValidatorProvider.getValidatorsAfterBlock(any())).thenReturn(validators);
    when(bftContext.as(Mockito.any())).thenReturn(bftContext);
    return new ProtocolContext(null, null, bftContext);
}
Also used : IbftLegacyContext(org.hyperledger.besu.consensus.ibft.IbftLegacyContext) ProtocolContext(org.hyperledger.besu.ethereum.ProtocolContext) ValidatorProvider(org.hyperledger.besu.consensus.common.validator.ValidatorProvider)

Example 3 with IbftLegacyContext

use of org.hyperledger.besu.consensus.ibft.IbftLegacyContext in project besu by hyperledger.

the class IbftLegacyContextBuilder method setupContextWithValidators.

public static IbftLegacyContext setupContextWithValidators(final Collection<Address> validators) {
    final IbftLegacyContext bftContext = mock(IbftLegacyContext.class, withSettings().lenient());
    final ValidatorProvider mockValidatorProvider = mock(ValidatorProvider.class, withSettings().lenient());
    when(bftContext.getValidatorProvider()).thenReturn(mockValidatorProvider);
    when(mockValidatorProvider.getValidatorsAfterBlock(any())).thenReturn(validators);
    when(bftContext.as(Mockito.any())).thenReturn(bftContext);
    return bftContext;
}
Also used : IbftLegacyContext(org.hyperledger.besu.consensus.ibft.IbftLegacyContext) ValidatorProvider(org.hyperledger.besu.consensus.common.validator.ValidatorProvider)

Aggregations

ValidatorProvider (org.hyperledger.besu.consensus.common.validator.ValidatorProvider)3 IbftLegacyContext (org.hyperledger.besu.consensus.ibft.IbftLegacyContext)3 IbftLegacyConfigOptions (org.hyperledger.besu.config.IbftLegacyConfigOptions)1 EpochManager (org.hyperledger.besu.consensus.common.EpochManager)1 BlockValidatorProvider (org.hyperledger.besu.consensus.common.validator.blockbased.BlockValidatorProvider)1 ProtocolContext (org.hyperledger.besu.ethereum.ProtocolContext)1