If I modify account data more than once in one transaction, and I subscribe this account throw accountSubscribe or programSubscribe. If the transaction has been included in one block, could I receive the notification more than once with each modified data? Or I receive notification only once?
1 Answer
This was a more complicated question than expected! Looking through the code, it appears that you'll only get one notification per block about an account changing.
The pubsub service receives a notification at https://github.com/solana-labs/solana/blob/5f54f6a7d9739154591c1a454c16aa04c5cfdc64/rpc/src/rpc_subscriptions.rs#L773 and then fans them out to subscribers at https://github.com/solana-labs/solana/blob/5f54f6a7d9739154591c1a454c16aa04c5cfdc64/rpc/src/rpc_subscriptions.rs#L932 -- you'll see that there's only one notification for the new bank, and not on every single transaction that gets processed.
This means that you'll only get one update per slot, maximum. Note that I'm not an expert in this area of the code and may have misunderstood.