Set wasTruncated flag at GetDataResponse

If we truncated dateSortedTruncatablePayloads we set outTruncated flag to true (used for trade statistics)
This commit is contained in:
chimp1984 2022-08-31 17:05:37 +02:00
parent c40d4ffffa
commit c4467ce03b
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3

View File

@ -349,11 +349,13 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
.map(e -> get32ByteHashAsByteArray((e.getProtectedStoragePayload())))
.toArray());
boolean wasTruncated = wasPersistableNetworkPayloadsTruncated.get() || wasProtectedStorageEntriesTruncated.get();
return new GetDataResponse(
filteredProtectedStorageEntries,
filteredPersistableNetworkPayloads,
getDataRequest.getNonce(),
getDataRequest instanceof GetUpdatedDataRequest);
getDataRequest instanceof GetUpdatedDataRequest,
wasTruncated);
}
@ -428,6 +430,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
int fromIndex = dateSortedTruncatablePayloads.size() - maxItems;
int toIndex = dateSortedTruncatablePayloads.size();
dateSortedTruncatablePayloads = dateSortedTruncatablePayloads.subList(fromIndex, toIndex);
outTruncated.set(true);
log.info("Num truncated dateSortedTruncatablePayloads {}", dateSortedTruncatablePayloads.size());
}
}