Search in sources :

Example 1 with BlockInformation

use of org.ethereum.db.BlockInformation in project rskj by rsksmart.

the class Web3Impl method eth_getBlocksByNumber.

public BlockInformationResult[] eth_getBlocksByNumber(String number) {
    long blockNumber;
    try {
        blockNumber = TypeConverter.stringNumberAsBigInt(number).longValue();
    } catch (NumberFormatException | StringIndexOutOfBoundsException e) {
        throw new JsonRpcInvalidParamException("invalid blocknumber " + number);
    }
    List<BlockInformationResult> result = new ArrayList<>();
    List<BlockInformation> binfos = blockchain.getBlocksInformationByNumber(blockNumber);
    for (BlockInformation binfo : binfos) {
        result.add(getBlockInformationResult(binfo));
    }
    return result.toArray(new BlockInformationResult[result.size()]);
}
Also used : JsonRpcInvalidParamException(org.ethereum.rpc.exception.JsonRpcInvalidParamException) BlockInformation(org.ethereum.db.BlockInformation)

Aggregations

BlockInformation (org.ethereum.db.BlockInformation)1 JsonRpcInvalidParamException (org.ethereum.rpc.exception.JsonRpcInvalidParamException)1