Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
jed
2012-08-16 16:52:40 -07:00
7 changed files with 42 additions and 19 deletions

View File

@@ -10,7 +10,7 @@ LedgerEntryFormat LedgerFormats[]=
{ S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 },
{ S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 },
{ S_FIELD(LastReceive), STI_UINT32, SOE_REQUIRED, 0 },
{ S_FIELD(LastTxn), STI_UINT32, SOE_REQUIRED, 0 },
{ S_FIELD(LastTxnSeq), STI_UINT32, SOE_REQUIRED, 0 },
{ S_FIELD(AuthorizedKey), STI_ACCOUNT, SOE_IFFLAG, 1 },
{ S_FIELD(EmailHash), STI_HASH128, SOE_IFFLAG, 2 },
{ S_FIELD(WalletLocator), STI_HASH256, SOE_IFFLAG, 4 },

View File

@@ -572,8 +572,8 @@ void Peer::recvHello(newcoin::TMHello& packet)
(void) mVerifyTimer.cancel();
uint32 ourTime = theApp->getOPs().getNetworkTimeNC();
uint32 minTime = ourTime - 10;
uint32 maxTime = ourTime + 10;
uint32 minTime = ourTime - 20;
uint32 maxTime = ourTime + 20;
#ifdef DEBUG
if (packet.has_nettime())

View File

@@ -73,4 +73,34 @@ bool SerializedLedgerEntry::isEquivalent(const SerializedType& t) const
if (mObject != v->mObject) return false;
return true;
}
bool SerializedLedgerEntry::isThreadedType()
{
return getIFieldIndex(sfLastTxnID) != -1;
}
bool SerializedLedgerEntry::isThreaded()
{
return getIFieldPresent(sfLastTxnID);
}
uint256 SerializedLedgerEntry::getThreadedTransaction()
{
return getIFieldH256(sfLastTxnID);
}
uint32 SerializedLedgerEntry::getThreadedLedger()
{
return getIFieldU32(sfLastTxnSeq);
}
void SerializedLedgerEntry::thread(const uint256& txID, uint32 ledgerSeq, uint256& prevTxID, uint32& prevLedgerID)
{
prevTxID = getIFieldH256(sfLastTxnID);
prevLedgerID = getIFieldU32(sfLastTxnID);
assert(prevTxID != txID);
setIFieldH256(sfLastTxnID, txID);
setIFieldU32(sfLastTxnSeq, ledgerSeq);
}
// vim:ts=4

View File

@@ -62,6 +62,12 @@ public:
STAmount getIValueFieldAmount(SOE_Field field) const { return mObject.getValueFieldAmount(field); }
STVector256 getIFieldV256(SOE_Field field) { return mObject.getValueFieldV256(field); }
bool isThreadedType(); // is this a ledger entry that can be threaded
bool isThreaded(); // is this ledger entry actually threaded
uint256 getThreadedTransaction();
uint32 getThreadedLedger();
void thread(const uint256& txID, uint32 ledgerSeq, uint256& prevTxID, uint32& prevLedgerID);
void setIFieldU8(SOE_Field field, unsigned char v) { return mObject.setValueFieldU8(field, v); }
void setIFieldU16(SOE_Field field, uint16 v) { return mObject.setValueFieldU16(field, v); }
void setIFieldU32(SOE_Field field, uint32 v) { return mObject.setValueFieldU32(field, v); }

View File

@@ -64,7 +64,8 @@ enum SOE_Field
sfInvoiceID,
sfLastNode,
sfLastReceive,
sfLastTxn,
sfLastTxnID,
sfLastTxnSeq,
sfLedgerHash,
sfLimitAmount,
sfLowID,

View File

@@ -813,10 +813,7 @@ SLE::pointer TransactionEngine::entryCache(LedgerEntryType letType, const uint25
{
sleEntry = mLedger->getSLE(uIndex);
if (sleEntry)
{
mNodes.entryCache(sleEntry);
mOrigNodes.entryCache(sleEntry); // So the metadata code can compare to the original
}
}
else if (action == taaDELETE)
assert(false);
@@ -893,13 +890,6 @@ void TransactionEngine::txnWrite()
}
}
// This is for when a transaction fails from the issuer's point of view and the current changes need to be cleared so other
// actions can be applied to the ledger.
void TransactionEngine::entryReset()
{
mNodes.setTo(mOrigNodes);
}
TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTransaction& txn,
TransactionEngineParams params)
{
@@ -1220,7 +1210,6 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
if (terSUCCESS == terResult)
{
entryModify(mTxnAccount);
mOrigNodes = mNodes.duplicate();
switch (txn.getTxnType())
{
@@ -1305,7 +1294,6 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
mTxnAccount = SLE::pointer();
mNodes.clear();
mOrigNodes.clear();
mUnfunded.clear();
return terResult;

View File

@@ -175,7 +175,7 @@ public:
class TransactionEngine
{
private:
LedgerEntrySet mNodes, mOrigNodes;
LedgerEntrySet mNodes;
TransactionEngineResult dirAdd(
uint64& uNodeDir, // Node of entry.
@@ -217,8 +217,6 @@ protected:
void entryDelete(SLE::pointer sleEntry, bool unfunded = false);
void entryModify(SLE::pointer sleEntry);
void entryReset();
uint32 rippleTransfer(const uint160& uIssuerID);
STAmount rippleBalance(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
STAmount rippleLimit(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);