More toward using STAmount.

This commit is contained in:
Arthur Britto
2012-05-18 20:17:28 -07:00
parent b8468770f0
commit abccd3aeb6
5 changed files with 12 additions and 7 deletions

View File

@@ -99,7 +99,7 @@ public:
const uint256& getParentHash() const { return mParentHash; }
const uint256& getTransHash() const { return mTransHash; }
const uint256& getAccountHash() const { return mAccountHash; }
STAmount getTotalCoins() const { return mTotCoins; }
uint64 getTotalCoins() const { return mTotCoins; }
uint64 getCloseTimeNC() const { return mCloseTime; }
uint32 getLedgerSeq() const { return mLedgerSeq; }
uint16 getInterval() const { return mLedgerInterval; }

View File

@@ -11,7 +11,7 @@ SerializedTransaction::SerializedTransaction(TransactionType type) : mType(type)
mMiddleTxn.giveObject(new STAccount("SourceAccount"));
mMiddleTxn.giveObject(new STUInt32("Sequence"));
mMiddleTxn.giveObject(new STUInt8("Type", static_cast<unsigned char>(type)));
mMiddleTxn.giveObject(new STUInt64("Fee"));
mMiddleTxn.giveObject(new STAmount("Fee"));
mInnerTxn=STObject(mFormat->elements, "InnerTransaction");
}
@@ -37,7 +37,7 @@ SerializedTransaction::SerializedTransaction(SerializerIterator& sit, int length
mMiddleTxn.giveObject(new STUInt32("Type", static_cast<uint32>(mType)));
mFormat = getTxnFormat(mType);
if (!mFormat) throw std::runtime_error("Transaction has invalid type");
mMiddleTxn.giveObject(new STUInt64("Fee", sit.get64()));
mMiddleTxn.giveObject(new STAmount("Fee", sit.get64()));
mInnerTxn = STObject(mFormat->elements, sit, "InnerTransaction");
}
@@ -169,7 +169,7 @@ STAmount SerializedTransaction::getTransactionFee() const
void SerializedTransaction::setTransactionFee(STAmount saFee)
{
STUInt64* v = dynamic_cast<STUInt64*>(mMiddleTxn.getPIndex(TransactionIFee));
STAmount* v = dynamic_cast<STAmount*>(mMiddleTxn.getPIndex(TransactionIFee));
if (!v) throw std::runtime_error("corrupt transaction");
v->setValue(saFee);
}

View File

@@ -227,6 +227,7 @@ public:
int getOffset() const { return mOffset; }
uint64 getValue() const { return mValue; }
void setValue(const STAmount& v) { mValue=v; }
bool isNative() const { return mIsNative; }
const uint160& getCurrency() const { return mCurrency; }
void zero() { mOffset = mIsNative ? -100 : 0; mValue = 0; }

View File

@@ -159,7 +159,7 @@ Transaction::pointer Transaction::setCreate(
{
mTransaction->setITFieldU32(sfFlags, tfCreateAccount);
mTransaction->setITFieldAccount(sfDestination, naCreateAccountID);
mTransaction->setITFieldU64(sfAmount, uFund);
mTransaction->setITFieldAmount(sfAmount, uFund);
sign(naPrivateKey);
@@ -192,7 +192,7 @@ Transaction::pointer Transaction::setPayment(
STAmount saAmount)
{
mTransaction->setITFieldAccount(sfDestination, toAccount);
mTransaction->setITFieldU64(sfAmount, saAmount);
mTransaction->setITFieldAmount(sfAmount, saAmount);
sign(naPrivateKey);

View File

@@ -120,7 +120,11 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
if (saSrcBalance < saPaid)
{
std::cerr << "applyTransaction: Delay transaction: insufficent balance" << std::endl;
std::cerr
<< str(boost::format("applyTransaction: Delay transaction: insufficent balance: balance=%s paid=%s")
% saSrcBalance
% saPaid)
<< std::endl;
return terINSUF_FEE_B;
}