perf(wallet): reuse created account snapshot reads

This commit is contained in:
Ricardo Guilherme Schmidt
2026-07-17 20:34:28 -03:00
parent addccf3850
commit fc1658635b
2 changed files with 11 additions and 2 deletions
@@ -329,9 +329,16 @@ WalletAccountCreation LogosWalletProvider::createAccount(bool isPublic)
return creation;
}
if (isPublic)
creation.publicAccount = readPublicAccount(creation.accountId);
creation.snapshot = snapshot(true);
if (isPublic) {
for (const WalletAccountRead& read : creation.snapshot.publicAccountReads) {
if (read.accountId == creation.accountId) {
creation.publicAccount = read;
return creation;
}
}
creation.publicAccount = readPublicAccount(creation.accountId);
}
return creation;
}
@@ -319,12 +319,14 @@ void LogosWalletProviderTest::createsAndPersistsAccounts()
QVERIFY(provider.connect({}).ok());
const int savesBeforeCreate = modules.logos_execution_zone.saveCalls;
const int publicReadsBeforeCreate = modules.logos_execution_zone.publicReadCalls;
const WalletAccountCreation creation = provider.createAccount(true);
QVERIFY(creation.ok());
QCOMPARE(creation.accountId, ACCOUNT_A);
QVERIFY(creation.publicAccount.ok());
QCOMPARE(creation.snapshot.accounts.size(), 1);
QVERIFY(modules.logos_execution_zone.saveCalls > savesBeforeCreate);
QCOMPARE(modules.logos_execution_zone.publicReadCalls, publicReadsBeforeCreate + 1);
modules.logos_execution_zone.saveResult = 1;
QCOMPARE(provider.createAccount(true).failure, WalletFailure::SaveFailed);