libplanet
libplanet copied to clipboard
`IStore.GetTxNonce()` returns the next tx nonce candidate
IStore being an interface for storing BlockChain<T>, Block<T>, and Transaction<T>s, I'd say the most intuitive expectation of IStore.GetTxNonce(Guid, Address)'s return value would be the highest nonce associated with the given Address stored in IStore.
However, the current implementation actually stores the nonce that is one higher than the highest Transaction<T> nonce included in a chain, and returns that value. This means, IStore.GetTxNonce() returns the next expected nonce that is allowed for a Transaction<T> to have to be included in the BlockChain<T>. In that sense, the name IStore.GetTxNonce() seems to be a red herring.
Personally, I see two problems:
IStorestoring the "next expected nonce" forAddresses.IStore.GetTxNonce()'s name (or its behavior)
The latter can be easily dealt with without changing the internal data by simply reducing the returned value to be less by value of $1$. On the other hand, if we also want to fix the former, some form of migration would be needed.
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.