use of kotlin.collections.ArrayDeque in project besu by hyperledger.
the class AccountRangeMessage method accountData.
public AccountRangeData accountData(final boolean withRequestId) {
final TreeMap<Bytes32, Bytes> accounts = new TreeMap<>();
final ArrayDeque<Bytes> proofs = new ArrayDeque<>();
final RLPInput input = new BytesValueRLPInput(data, false);
input.enterList();
if (withRequestId)
input.skipNext();
input.readList(rlpInput -> {
rlpInput.enterList();
Map.Entry<Bytes32, Bytes> entry = Maps.immutableEntry(rlpInput.readBytes32(), toFullAccount(rlpInput.readAsRlp()));
rlpInput.leaveList();
return entry;
}).forEach(entry -> accounts.put(entry.getKey(), entry.getValue()));
input.enterList();
while (!input.isEndOfCurrentList()) {
proofs.add(input.readBytes());
}
input.leaveList();
input.leaveList();
return ImmutableAccountRangeData.builder().accounts(accounts).proofs(proofs).build();
}
use of kotlin.collections.ArrayDeque in project besu by hyperledger.
the class ByteCodesMessage method bytecodes.
public ByteCodes bytecodes(final boolean withRequestId) {
final ArrayDeque<Bytes> codes = new ArrayDeque<>();
final RLPInput input = new BytesValueRLPInput(data, false);
input.enterList();
if (withRequestId)
input.skipNext();
input.enterList();
while (!input.isEndOfCurrentList()) {
codes.add(input.readBytes());
}
input.leaveList();
input.leaveList();
return ImmutableByteCodes.builder().codes(codes).build();
}
use of kotlin.collections.ArrayDeque in project besu by hyperledger.
the class StorageRangeMessage method slotsData.
public SlotRangeData slotsData(final boolean withRequestId) {
final ArrayDeque<TreeMap<Bytes32, Bytes>> slots = new ArrayDeque<>();
final ArrayDeque<Bytes> proofs = new ArrayDeque<>();
final RLPInput input = new BytesValueRLPInput(data, false);
input.enterList();
if (withRequestId)
input.skipNext();
input.readList(accountRlpInput -> {
slots.add(new TreeMap<>());
return accountRlpInput.readList(slotRlpInput -> {
slotRlpInput.enterList();
slots.last().put(slotRlpInput.readBytes32(), slotRlpInput.readBytes());
slotRlpInput.leaveList();
// we don't need the response
return Void.TYPE;
});
});
input.enterList();
while (!input.isEndOfCurrentList()) {
proofs.add(input.readBytes());
}
input.leaveList();
input.leaveList();
return ImmutableSlotRangeData.builder().slots(slots).proofs(proofs).build();
}
use of kotlin.collections.ArrayDeque in project besu by hyperledger.
the class TrieNodesMessage method nodes.
public ArrayDeque<Bytes> nodes(final boolean withRequestId) {
final ArrayDeque<Bytes> trieNodes = new ArrayDeque<>();
final RLPInput input = new BytesValueRLPInput(data, false);
input.enterList();
if (withRequestId)
input.skipNext();
input.enterList();
while (!input.isEndOfCurrentList()) {
trieNodes.add(input.readBytes());
}
input.leaveList();
input.leaveList();
return trieNodes;
}
use of kotlin.collections.ArrayDeque in project besu by hyperledger.
the class RequestDataStep method requestStorage.
public CompletableFuture<List<Task<SnapDataRequest>>> requestStorage(final List<Task<SnapDataRequest>> requestTasks) {
final List<Bytes32> accountHashes = requestTasks.stream().map(Task::getData).map(StorageRangeDataRequest.class::cast).map(StorageRangeDataRequest::getAccountHash).collect(Collectors.toList());
final BlockHeader blockHeader = fastSyncState.getPivotBlockHeader().get();
final Bytes32 minRange = requestTasks.size() == 1 ? ((StorageRangeDataRequest) requestTasks.get(0).getData()).getStartKeyHash() : RangeManager.MIN_RANGE;
final Bytes32 maxRange = requestTasks.size() == 1 ? ((StorageRangeDataRequest) requestTasks.get(0).getData()).getEndKeyHash() : RangeManager.MAX_RANGE;
final EthTask<StorageRangeMessage.SlotRangeData> getStorageRangeTask = RetryingGetStorageRangeFromPeerTask.forStorageRange(ethContext, accountHashes, minRange, maxRange, blockHeader, metricsSystem);
downloadState.addOutstandingTask(getStorageRangeTask);
return getStorageRangeTask.run().handle((response, error) -> {
if (response != null) {
downloadState.removeOutstandingTask(getStorageRangeTask);
for (int i = 0; i < response.slots().size(); i++) {
final StorageRangeDataRequest request = (StorageRangeDataRequest) requestTasks.get(i).getData();
request.setRootHash(blockHeader.getStateRoot());
request.addResponse(downloadState, worldStateProofProvider, response.slots().get(i), i < response.slots().size() - 1 ? new ArrayDeque<>() : response.proofs());
}
}
return requestTasks;
});
}
Aggregations