diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/IbftJsonRpcMethodsFactory.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/IbftJsonRpcMethodsFactory.java index dd4a91a9b5..416290b11d 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/IbftJsonRpcMethodsFactory.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/IbftJsonRpcMethodsFactory.java @@ -12,9 +12,11 @@ */ package tech.pegasys.pantheon.consensus.ibft.jsonrpc; +import tech.pegasys.pantheon.consensus.common.BlockInterface; import tech.pegasys.pantheon.consensus.ibft.IbftBlockInterface; import tech.pegasys.pantheon.consensus.ibft.IbftContext; import tech.pegasys.pantheon.consensus.ibft.jsonrpc.methods.IbftDiscardValidatorVote; +import tech.pegasys.pantheon.consensus.ibft.jsonrpc.methods.IbftGetValidatorsByBlockHash; import tech.pegasys.pantheon.consensus.ibft.jsonrpc.methods.IbftGetValidatorsByBlockNumber; import tech.pegasys.pantheon.consensus.ibft.jsonrpc.methods.IbftProposeValidatorVote; import tech.pegasys.pantheon.ethereum.ProtocolContext; @@ -37,16 +39,18 @@ public Map methods( final Map rpcMethods = new HashMap<>(); if (jsonRpcApis.contains(IbftRpcApis.IBFT)) { - BlockchainQueries blockchainQueries = + final BlockchainQueries blockchainQueries = new BlockchainQueries(context.getBlockchain(), context.getWorldStateArchive()); + final BlockInterface blockInterface = new IbftBlockInterface(); addMethods( rpcMethods, new IbftProposeValidatorVote( context.getConsensusState().getVoteProposer(), jsonRpcParameter), - new IbftGetValidatorsByBlockNumber( - blockchainQueries, new IbftBlockInterface(), jsonRpcParameter), + new IbftGetValidatorsByBlockNumber(blockchainQueries, blockInterface, jsonRpcParameter), new IbftDiscardValidatorVote( - context.getConsensusState().getVoteProposer(), jsonRpcParameter)); + context.getConsensusState().getVoteProposer(), jsonRpcParameter), + new IbftGetValidatorsByBlockHash( + context.getBlockchain(), blockInterface, jsonRpcParameter)); } return rpcMethods; diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java index 81a8e3bf30..19f5edebb9 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.consensus.ibft.jsonrpc.methods; -import tech.pegasys.pantheon.consensus.ibft.IbftBlockInterface; +import tech.pegasys.pantheon.consensus.common.BlockInterface; import tech.pegasys.pantheon.ethereum.chain.Blockchain; import tech.pegasys.pantheon.ethereum.core.BlockHeader; import tech.pegasys.pantheon.ethereum.core.Hash; @@ -28,15 +28,15 @@ public class IbftGetValidatorsByBlockHash implements JsonRpcMethod { private final Blockchain blockchain; - private final IbftBlockInterface ibftBlockInterface; + private final BlockInterface blockInterface; private final JsonRpcParameter parameters; public IbftGetValidatorsByBlockHash( final Blockchain blockchain, - final IbftBlockInterface ibftBlockInterface, + final BlockInterface blockInterface, final JsonRpcParameter parameters) { this.blockchain = blockchain; - this.ibftBlockInterface = ibftBlockInterface; + this.blockInterface = blockInterface; this.parameters = parameters; } @@ -56,7 +56,7 @@ private Object blockResult(final JsonRpcRequest request) { return blockHeader .map( header -> - ibftBlockInterface + blockInterface .validatorsInBlock(header) .stream() .map(validator -> validator.toString()) diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java index 2b60efeff1..8faf0332aa 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockNumber.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.consensus.ibft.jsonrpc.methods; -import tech.pegasys.pantheon.consensus.ibft.IbftBlockInterface; +import tech.pegasys.pantheon.consensus.common.BlockInterface; import tech.pegasys.pantheon.ethereum.core.BlockHeader; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.AbstractBlockParameterMethod; @@ -27,14 +27,14 @@ public class IbftGetValidatorsByBlockNumber extends AbstractBlockParameterMethod implements JsonRpcMethod { - private final IbftBlockInterface ibftBlockInterface; + private final BlockInterface blockInterface; public IbftGetValidatorsByBlockNumber( final BlockchainQueries blockchainQueries, - final IbftBlockInterface ibftBlockInterface, + final BlockInterface blockInterface, final JsonRpcParameter parameters) { super(blockchainQueries, parameters); - this.ibftBlockInterface = ibftBlockInterface; + this.blockInterface = blockInterface; } @Override @@ -49,7 +49,7 @@ protected Object resultByBlockNumber(final JsonRpcRequest request, final long bl return blockHeader .map( header -> - ibftBlockInterface + blockInterface .validatorsInBlock(header) .stream() .map(validator -> validator.toString())