Add StakeInstruction::Merge (#10503)

automerge
This commit is contained in:
Michael Vines
2020-06-10 17:22:47 -07:00
committed by GitHub
parent 4c140acb3b
commit 60bc64629c
3 changed files with 381 additions and 0 deletions

View File

@ -21,6 +21,7 @@ pub enum AccountOperation {
SplitDestination,
SystemAccountEnroll,
FailedToMaintainMinimumBalance,
MergeSource,
}
#[derive(Serialize, Deserialize, Debug)]
@ -172,6 +173,29 @@ fn process_transaction(
}
}
}
StakeInstruction::Merge => {
// Merge invalidates the source account, but does not affect the
// destination account
let source_merge_account_index = instruction.accounts[1] as usize;
let source_stake_pubkey =
message.account_keys[source_merge_account_index].to_string();
if let Some(mut source_account_info) =
accounts.get_mut(&source_stake_pubkey)
{
if source_account_info.compliant_since.is_some() {
source_account_info.compliant_since = None;
source_account_info
.transactions
.push(AccountTransactionInfo {
op: AccountOperation::MergeSource,
slot,
signature: signature.clone(),
});
}
}
}
StakeInstruction::Withdraw(_) => {
// Withdrawing is not permitted