solana-playground / solana-playground

Quickly develop, deploy and test Solana programs from browsers
https://beta.solpg.io
Apache License 2.0
398 stars 133 forks source link

Cached blockhash doesn't update on cluster change #214

Closed acheroncrypto closed 1 month ago

acheroncrypto commented 1 month ago

Problem

We cache the latest blockhash info and reuse that for sending transactions:

https://github.com/solana-playground/solana-playground/blob/99a355ff0def83b1997542dd0535555072bf218b/client/src/utils/pg/tx/tx.ts#L165-L166

However, it doesn't update when cluster changes, which results in Blockhash not found error until the cache update.

Solution

Update the latest blockhash cache when the cluster changes.