Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Cherry-pick: warm up more entities #13033

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,17 @@ protected Map<TokenID, List<NftTransfer>> nftChangesFrom(

// The NFT may not have existed before, in which case we'll use a null sender account ID
AccountID senderAccountId;
final var tokenId = nftId.tokenId();
requireNonNull(tokenId);
final var token = writableTokenStore.get(tokenId);
requireNonNull(token);
if (persistedNft != null) {
// If the NFT did not have an owner before set it to the treasury account
senderAccountId = persistedNft.hasOwnerId() ? persistedNft.ownerId() : token.treasuryAccountIdOrThrow();
if (persistedNft.hasOwnerId()) {
senderAccountId = persistedNft.ownerId();
} else {
final var tokenId = nftId.tokenId();
requireNonNull(tokenId);
final var token = writableTokenStore.get(tokenId);
requireNonNull(token);
senderAccountId = token.treasuryAccountIdOrThrow();
}
} else {
senderAccountId = ZERO_ACCOUNT_ID;
}
Expand All @@ -224,6 +228,10 @@ protected Map<TokenID, List<NftTransfer>> nftChangesFrom(
if (modifiedNft.hasOwnerId()) {
receiverAccountId = modifiedNft.ownerId();
} else {
final var tokenId = nftId.tokenId();
requireNonNull(tokenId);
final var token = writableTokenStore.get(tokenId);
requireNonNull(token);
receiverAccountId = token.treasuryAccountIdOrThrow();
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,14 @@ public void warm(@NonNull final WarmupContext context) {
if (treasuryID != null) accountStore.warm(treasuryID);
final List<NftTransfer> nftTransfers = tokenTransferList.nftTransfersOrThrow();
for (final NftTransfer nftTransfer : nftTransfers) {
warmNftTransfer(accountStore, nftStore, tokenRelationStore, tokenID, nftTransfer);
warmNftTransfer(accountStore, tokenStore, nftStore, tokenRelationStore, tokenID, nftTransfer);
}
});
}

private void warmNftTransfer(
@NonNull final ReadableAccountStore accountStore,
@NonNull final ReadableTokenStore tokenStore,
@NonNull final ReadableNftStore nftStore,
@NonNull final ReadableTokenRelationStore tokenRelationStore,
@NonNull final TokenID tokenID,
Expand All @@ -197,7 +198,10 @@ private void warmNftTransfer(
nftTransfer.ifReceiverAccountID(receiverAccountID -> {
final Account receiver = accountStore.getAliasedAccountById(receiverAccountID);
if (receiver != null) {
receiver.ifHeadTokenId(headTokenID -> tokenRelationStore.warm(receiverAccountID, headTokenID));
receiver.ifHeadTokenId(headTokenID -> {
tokenRelationStore.warm(receiverAccountID, headTokenID);
tokenStore.warm(headTokenID);
});
receiver.ifHeadNftId(nftStore::warm);
}
tokenRelationStore.warm(receiverAccountID, tokenID);
Expand Down