|
|
|
@ -16,9 +16,11 @@ package org.hyperledger.besu.ethereum.retesteth.methods; |
|
|
|
|
|
|
|
|
|
import org.hyperledger.besu.ethereum.ProtocolContext; |
|
|
|
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; |
|
|
|
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters; |
|
|
|
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; |
|
|
|
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; |
|
|
|
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; |
|
|
|
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; |
|
|
|
|
import org.hyperledger.besu.ethereum.blockcreation.PoWBlockCreator; |
|
|
|
|
import org.hyperledger.besu.ethereum.chain.MutableBlockchain; |
|
|
|
|
import org.hyperledger.besu.ethereum.core.Block; |
|
|
|
@ -44,7 +46,13 @@ public class TestMineBlocks implements JsonRpcMethod { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { |
|
|
|
|
long blocksToMine = requestContext.getRequiredParameter(0, Long.class); |
|
|
|
|
long blocksToMine = 0; |
|
|
|
|
try { |
|
|
|
|
blocksToMine = requestContext.getRequiredParameter(0, Long.class); |
|
|
|
|
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
|
|
|
|
throw new InvalidJsonRpcParameters( |
|
|
|
|
"Invalid blocks to mine (index 0)", RpcErrorType.INVALID_BLOCK_COUNT_PARAMS, e); |
|
|
|
|
} |
|
|
|
|
while (blocksToMine-- > 0) { |
|
|
|
|
if (!mineNewBlock()) { |
|
|
|
|
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), false); |
|
|
|
|