Skip to content

Commit

Permalink
fix: don't override a transaction's recentBlockhash when calling simu…
Browse files Browse the repository at this point in the history
…late if it's already set (#24280)

* Update simulate to add blockhash if not exist

Simulate has been overriding the recentBlockhash of the passed
Transaction which can be considered destructive and with side effects.

Since the purpose of this function is to purely simulate, it should not
override recentBlockhash if it has already been set

Refs solana-labs/solana#24279

* Apply prettier
  • Loading branch information
dvcrn committed Apr 13, 2022
1 parent 7dd66ca commit e707c2b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3888,7 +3888,11 @@ export class Connection {
} else {
let disableCache = this._disableBlockhashCaching;
for (;;) {
transaction.recentBlockhash = await this._recentBlockhash(disableCache);
if (!transaction.recentBlockhash) {
transaction.recentBlockhash = await this._recentBlockhash(
disableCache,
);
}

if (!signers) break;

Expand Down

0 comments on commit e707c2b

Please sign in to comment.