Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

IbftGetValidatorsByBlockHash added to json factory #607

Merged
merged 3 commits into from
Jan 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,16 +39,18 @@ public Map<String, JsonRpcMethod> methods(
final Map<String, JsonRpcMethod> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -56,7 +56,7 @@ private Object blockResult(final JsonRpcRequest request) {
return blockHeader
.map(
header ->
ibftBlockInterface
blockInterface
.validatorsInBlock(header)
.stream()
.map(validator -> validator.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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())
Expand Down