Skip to content

Commit

Permalink
prevents reorg checks if set account start is genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
jowparks committed Nov 7, 2024
1 parent f5271e3 commit 21794e5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ironfish/src/rpc/routes/wallet/setAccountHead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ routes.register<typeof SetAccountHeadRequestSchema, SetAccountHeadResponse>(
}

// Validate account state
const account = getAccount(context.wallet, request.data.account)
let account = getAccount(context.wallet, request.data.account)

if (account.scanningEnabled) {
throw new RpcResponseError(
Expand All @@ -99,9 +99,13 @@ routes.register<typeof SetAccountHeadRequestSchema, SetAccountHeadResponse>(
)
}

// If startHeader is the genesis block, we can safely reset the account before adding
if (startHeader.sequence === 1) {
await context.wallet.resetAccount(account)
account = getAccount(context.wallet, request.data.account)
}
// Validate account head is compatible with start and end blocks
let accountHead = await account.getHead()

if (accountHead !== null) {
const accountHeader = await context.chain.getHeader(accountHead.hash)
if (!accountHeader) {
Expand Down

0 comments on commit 21794e5

Please sign in to comment.