From 8701337af7636958603af7823438e2074b917d92 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sat, 2 Jun 2012 16:19:37 -0700 Subject: [PATCH] Work on the wobble logic. --- src/LedgerMaster.h | 3 ++- src/NetworkOPs.cpp | 4 ++-- src/NetworkOPs.h | 3 ++- src/Peer.cpp | 8 +++++++- src/newcoin.proto | 12 ++++++------ 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/LedgerMaster.h b/src/LedgerMaster.h index f180f13c53..8f049b1363 100644 --- a/src/LedgerMaster.h +++ b/src/LedgerMaster.h @@ -40,7 +40,8 @@ public: Ledger::pointer getCurrentLedger() { return mCurrentLedger; } Ledger::pointer getClosedLedger() { return mFinalizedLedger; } - TransactionEngineResult doTransaction(const SerializedTransaction& txn, TransactionEngineParams params) + TransactionEngineResult doTransaction(const SerializedTransaction& txn, uint32 targetLedger, + TransactionEngineParams params) // FIXME: wobble { return mEngine.applyTransaction(txn, params); } void pushLedger(Ledger::pointer newLedger); diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index 50c208cc76..eb3cdc49b9 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -42,7 +42,7 @@ uint32 NetworkOPs::getCurrentLedgerID() return mLedgerMaster->getCurrentLedger()->getLedgerSeq(); } -Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans, Peer* source) +Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans, uint32 tgtLedger, Peer* source) { Transaction::pointer dbtx = theApp->getMasterTransaction().fetch(trans->getID(), true); if (dbtx) return dbtx; @@ -54,7 +54,7 @@ Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans, return trans; } - TransactionEngineResult r = mLedgerMaster->doTransaction(*trans->getSTransaction(), tepNONE); + TransactionEngineResult r = mLedgerMaster->doTransaction(*trans->getSTransaction(), tgtLedger, tepNONE); if (r == tenFAILED) throw Fault(IO_ERROR); if (r == terPRE_SEQ) diff --git a/src/NetworkOPs.h b/src/NetworkOPs.h index 1bc82a9bee..5d6f48b044 100644 --- a/src/NetworkOPs.h +++ b/src/NetworkOPs.h @@ -56,7 +56,8 @@ public: { return mLedgerMaster->getClosedLedger()->getHash(); } // transaction operations - Transaction::pointer processTransaction(Transaction::pointer transaction, Peer* source = NULL); + Transaction::pointer processTransaction(Transaction::pointer transaction, uint32 targetLedger = 0, + Peer* source = NULL); Transaction::pointer findTransactionByID(const uint256& transactionID); int findTransactionsBySource(const uint256& uLedger, std::list&, const NewcoinAddress& sourceAccount, uint32 minSeq, uint32 maxSeq); diff --git a/src/Peer.cpp b/src/Peer.cpp index a2132d1ee0..3d6717ffbe 100644 --- a/src/Peer.cpp +++ b/src/Peer.cpp @@ -597,7 +597,13 @@ void Peer::recvTransaction(newcoin::TMTransaction& packet) } #endif - tx = theApp->getOPs().processTransaction(tx, this); + uint32 targetLedger = 0; + if (packet.has_ledgerindexfinal()) + targetLedger = packet.ledgerindexfinal(); + else if (packet.has_ledgerindexpossible()) + targetLedger = packet.ledgerindexpossible(); + + tx = theApp->getOPs().processTransaction(tx, targetLedger, this); if(tx->getStatus() != INCLUDED) { // transaction wasn't accepted into ledger diff --git a/src/newcoin.proto b/src/newcoin.proto index c39e55b9f8..f69aee626d 100644 --- a/src/newcoin.proto +++ b/src/newcoin.proto @@ -64,12 +64,12 @@ enum TransactionStatus { } message TMTransaction { - required bytes rawTransaction = 1; - required TransactionStatus status = 9; - optional uint64 receiveTimestamp = 10; - optional uint32 ledgerIndexPossible = 11; // the node may not know - optional uint32 ledgerIndexFinal = 12; - optional bytes conflictingTransaction = 13; + required bytes rawTransaction = 1; + required TransactionStatus status = 2; + optional uint64 receiveTimestamp = 3; + optional uint32 ledgerIndexPossible = 4; // the node may not know + optional uint32 ledgerIndexFinal = 5; + optional bytes conflictingTransaction = 6; }