fn handle_cross_shard_recipient_commit()

in fastpay_core/src/authority.rs [205:229]


    fn handle_cross_shard_recipient_commit(
        &mut self,
        certificate: CertifiedTransferOrder,
    ) -> Result<(), FastPayError> {
        // TODO: check certificate again?
        let transfer = &certificate.value.transfer;

        let recipient = match transfer.recipient {
            Address::FastPay(recipient) => recipient,
            Address::Primary(_) => {
                fp_bail!(FastPayError::InvalidCrossShardUpdate);
            }
        };
        fp_ensure!(self.in_shard(&recipient), FastPayError::WrongShard);
        let recipient_account = self
            .accounts
            .entry(recipient)
            .or_insert_with(AccountOffchainState::new);
        recipient_account.balance = recipient_account
            .balance
            .try_add(transfer.amount.into())
            .unwrap_or_else(|_| Balance::max());
        recipient_account.received_log.push(certificate);
        Ok(())
    }