Ensure device removal doesn't affect unaffiliated stake
annybs opened this issue · comments
Say a stake is reassigned from device A to device B, creating a pending transaction. Device A won't know it is unassigned until the transaction is processed and enters the blockchain. In this period, it is theoretically possible for device A to be removed, creating a second pending transaction that unassigns the stake (being that the unassign_stake
action doesn't require a device
input).
This is a highly unlikely scenario but we should take the extra step to mitigate it by checking pending transactions before removing a device. If any pending transaction pertains to the target stake, it should be ignored (but other device events still allowed, namely removal).
After this change is made we should also explore the necessity of checking pending transactions for other actions, e.g. adding to network, or anything else that may alter the stake.