use of org.hyperledger.besu.ethereum.api.util.ArrayNodeWrapper in project besu by hyperledger.
the class TraceFilter method response.
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final FilterParameter filterParameter = requestContext.getRequiredParameter(0, FilterParameter.class);
final long fromBlock = resolveBlockNumber(filterParameter.getFromBlock());
final long toBlock = resolveBlockNumber(filterParameter.getToBlock());
LOG.trace("Received RPC rpcName={} fromBlock={} toBlock={}", getName(), fromBlock, toBlock);
final ObjectMapper mapper = new ObjectMapper();
final ArrayNodeWrapper resultArrayNode = new ArrayNodeWrapper(mapper.createArrayNode(), filterParameter.getAfter(), filterParameter.getCount());
long currentBlockNumber = fromBlock;
while (currentBlockNumber <= toBlock && !resultArrayNode.isFull()) {
Optional<Block> blockByNumber = blockchainQueriesSupplier.get().getBlockchain().getBlockByNumber(currentBlockNumber);
blockByNumber.ifPresent(block -> resultArrayNode.addAll(traceBlock(block, Optional.of(filterParameter))));
currentBlockNumber++;
}
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), resultArrayNode.getArrayNode());
}
use of org.hyperledger.besu.ethereum.api.util.ArrayNodeWrapper in project besu by hyperledger.
the class TraceBlock method traceBlock.
protected ArrayNodeWrapper traceBlock(final Block block, final Optional<FilterParameter> filterParameter) {
if (block == null) {
return emptyResult();
}
final ArrayNodeWrapper resultArrayNode = new ArrayNodeWrapper(MAPPER.createArrayNode());
blockTracerSupplier.get().trace(block, new DebugOperationTracer(new TraceOptions(false, false, true))).ifPresent(blockTrace -> generateTracesFromTransactionTraceAndBlock(filterParameter, blockTrace.getTransactionTraces(), block, resultArrayNode));
generateRewardsFromBlock(filterParameter, block, resultArrayNode);
return resultArrayNode;
}
Aggregations