当前位置: 首页>>代码示例>>C++>>正文


C++ OTPseudonym::RemoveIssuedNum方法代码示例

本文整理汇总了C++中OTPseudonym::RemoveIssuedNum方法的典型用法代码示例。如果您正苦于以下问题:C++ OTPseudonym::RemoveIssuedNum方法的具体用法?C++ OTPseudonym::RemoveIssuedNum怎么用?C++ OTPseudonym::RemoveIssuedNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OTPseudonym的用法示例。


在下文中一共展示了OTPseudonym::RemoveIssuedNum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: theNymID

/// Only if it is an inbox, a ledger will loop through the transactions
/// and produce the XML output for the report that's necessary during
/// a balance agreement. (Any balance agreement for an account must
/// include the list of transactions the nym has issued for use, as
/// well as a listing of the transactions in the inbox for that account.
/// This function does that last part :)
///
/// returns a new balance statement item containing the inbox report
/// CALLER IS RESPONSIBLE TO DELETE.
OTItem * OTLedger::GenerateBalanceStatement(const long lAdjustment, const OTTransaction & theOwner, 
											OTPseudonym & theNym, const OTAccount & theAccount, OTLedger & theOutbox) 
{
	if (OTLedger::inbox != GetType())
	{
		OTLog::Error("OTLedger::GenerateBalanceStatement: Wrong ledger type.\n");
		return NULL;
	}
	
	// ------------------------------------------------------
	
	const OTIdentifier theNymID(theNym);
	
	if (
		(theAccount.GetPurportedAccountID()	!= GetPurportedAccountID()) ||
		(theAccount.GetPurportedServerID()	!= GetPurportedServerID()) ||
		(theAccount.GetUserID()				!= GetUserID()) )
	{
		OTLog::Error("Wrong Account passed in to OTLedger::GenerateBalanceStatement.\n");
		return NULL;
	}
	if (
		(theOutbox.GetPurportedAccountID()	!= GetPurportedAccountID()) ||
		(theOutbox.GetPurportedServerID()	!= GetPurportedServerID()) ||
		(theOutbox.GetUserID()				!= GetUserID()) )
	{
		OTLog::Error("Wrong Outbox passed in to OTLedger::GenerateBalanceStatement.\n");
		return NULL;
	}
	if (
		(theNymID	!= GetUserID()))
	{
		OTLog::Error("Wrong Nym passed in to OTLedger::GenerateBalanceStatement.\n");
		return NULL;
	}
	// ---------------------------------------------------------

	// theOwner is the withdrawal, or deposit, or whatever, that wants to change
	// the account balance, and thus that needs a new balance agreement signed.
	//
	OTItem * pBalanceItem = OTItem::CreateItemFromTransaction(theOwner, OTItem::balanceStatement); // <=== balanceStatement type, with user ID, server ID, account ID, transaction ID.

	// The above has an ASSERT, so this this will never actually happen.
	if (NULL == pBalanceItem)
		return NULL;
	
	// ---------------------------------------------------------
	
	// COPY THE ISSUED TRANSACTION NUMBERS FROM THE NYM to the MESSAGE NYM.
	
	OTPseudonym theMessageNym;
	    
	theMessageNym.HarvestIssuedNumbers(this->GetPurportedServerID(), 
                                       theNym /*unused in this case, not saving to disk*/, theNym, false); // bSave = false;
	
	// -------------------------------------
	
    
    
	switch (theOwner.GetType()) 
	{
			// These five options will remove the transaction number from the issued list, SUCCESS OR FAIL.
			// Server will expect the number to be missing from the list, in the case of these.
			// Therefore I remove it here in order to generate a proper balance agreement, acceptable to the server.
		case OTTransaction::processInbox:
		case OTTransaction::deposit:
		case OTTransaction::withdrawal:
        case OTTransaction::cancelCronItem:
		case OTTransaction::exchangeBasket:

			theMessageNym.RemoveIssuedNum(theOwner.GetRealServerID(), theOwner.GetTransactionNum());  // a transaction number is being used, and REMOVED from my list of responsibility,
			theMessageNym.RemoveTransactionNum(theOwner.GetRealServerID(), theOwner.GetTransactionNum());  // a transaction number is being used, and REMOVED from my list of  available numbers.
			break;
		case OTTransaction::transfer:
		case OTTransaction::marketOffer:
		case OTTransaction::paymentPlan:
			// Nothing removed here since the transaction is still in play. (Assuming success.)
			// If the server replies with rejection for any of these three, then I can remove
			// the transaction number from my list of issued/signed for. But if success, then I
			// am responsible for the transaction number until I sign off on closing it.
			// Since the Balance Statement ANTICIPATES SUCCESS, NOT FAILURE, it assumes the number
			// to be "in play" here, and thus DOES NOT remove it (vs the cases above, which do.)
			break;
		default: 
			// Error
			OTLog::vError("OTLedger::GenerateBalanceStatement: wrong owner transaction type: %s\n",
						  theOwner.GetTypeString());
			break;
	}
	
	OTString	strMessageNym(theMessageNym); // Okay now we have the transaction numbers in this MessageNym string.
//.........这里部分代码省略.........
开发者ID:batouzo,项目名称:Open-Transactions,代码行数:101,代码来源:OTLedger.cpp

示例2: onFinalReceipt


//.........这里部分代码省略.........
    // Second, we're verifying the CLOSING number, and using it as the closing number
    // on the FINAL RECEIPT (with that receipt being "InReferenceTo" this->GetTransactionNum())
    //
    const long lRecipientOpeningNumber = this->GetRecipientOpeningNum();
    const long lRecipientClosingNumber = this->GetRecipientClosingNum();
    
    // -----------------------------------------------------------------------------------
    const long lSenderOpeningNumber = theOrigCronItem.GetTransactionNum();

    const long lSenderClosingNumber = (theOrigCronItem.GetCountClosingNumbers() > 0) ? 
        theOrigCronItem.GetClosingTransactionNoAt(0) : 0; // index 0 is closing number for sender, since GetTransactionNum() is his opening #.
    
    // ----------------------------------
        
    const OTString strServerID(GetServerID());
    
    // -----------------------------------------------------------------
    //
    
    if ((lSenderOpeningNumber > 0) &&
        theOriginator.VerifyIssuedNum(strServerID, lSenderOpeningNumber))
    {
        // The Nym (server side) stores a list of all opening and closing cron #s.
        // So when the number is released from the Nym, we also take it off that list.
        //
        std::set<long> & theIDSet = theOriginator.GetSetOpenCronItems();
        theIDSet.erase(lSenderOpeningNumber);
        
        // the RemoveIssued call means the original transaction# (to find this cron item on cron) is now CLOSED.
        // But the Transaction itself is still OPEN. How? Because the CLOSING number is still signed out.
        // The closing number is also USED, since the NotarizePaymentPlan or NotarizeMarketOffer call, but it
        // remains ISSUED, until the final receipt itself is accepted during a process inbox.
        //
        theOriginator.RemoveIssuedNum(*pServerNym, strServerID, lSenderOpeningNumber, false); //bSave=false
        theOriginator.SaveSignedNymfile(*pServerNym);
        // ------------------------------------
        
        OTPseudonym *   pActualNym = NULL;  // use this. DON'T use theActualNym.
        OTPseudonym     theActualNym; // unused unless it's really not already loaded. (use pActualNym.)
        const OTIdentifier ACTUAL_NYM_ID = GetSenderUserID();
        
        if ( (NULL != pServerNym) && pServerNym->CompareID(ACTUAL_NYM_ID) )
            pActualNym = pServerNym;
        else if (theOriginator.CompareID(ACTUAL_NYM_ID))
            pActualNym = &theOriginator;
        else if ( (NULL != pRemover) && pRemover->CompareID(ACTUAL_NYM_ID) )
            pActualNym = pRemover;
        // --------------------------
        else    // We couldn't find the Nym among those already loaded--so we have to load
        {       // it ourselves (so we can update its NymboxHash value.)
            theActualNym.SetIdentifier(ACTUAL_NYM_ID);
            
            if (false == theActualNym.LoadPublicKey()) // Note: this step may be unnecessary since we are only updating his Nymfile, not his key.
            {
                OTString strNymID(ACTUAL_NYM_ID);
                OTLog::vError("OTAgreement::onFinalReceipt: Failure loading public key for Nym: %s. "
                              "(To update his NymboxHash.) \n", strNymID.Get());
            }
            else if (theActualNym.VerifyPseudonym()	&& // this line may be unnecessary.
                     theActualNym.LoadSignedNymfile(*pServerNym)) // ServerNym here is not theActualNym's identity, but merely the signer on this file.
            {
                OTLog::Output(0, "OTAgreement::onFinalReceipt: Loading actual Nym, since he wasn't already loaded. "
                              "(To update his NymboxHash.)\n");
                pActualNym = &theActualNym; //  <=====
            }
            else
开发者ID:coinmint,项目名称:Open-Transactions,代码行数:67,代码来源:OTAgreement.cpp


注:本文中的OTPseudonym::RemoveIssuedNum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。