Fix a bug in TransactionMaster::fetch. Also, don't use this anyway.

This commit is contained in:
JoelKatz
2012-11-21 13:45:09 -08:00
parent b4e7d8c5c3
commit c36d967de8
5 changed files with 32 additions and 15 deletions

View File

@@ -1029,18 +1029,17 @@ void NetworkOPs::pubLedger(Ledger::ref lpAccepted)
for (SHAMapItem::pointer item = txSet.peekFirstItem(); !!item; item = txSet.peekNextItem(item->getTag()))
{
SerializedTransaction::pointer stTxn = theApp->getMasterTransaction().fetch(item, false, 0);
if(stTxn)
{
// XXX Need to support other results.
// XXX Need to give failures too.
TER terResult = tesSUCCESS;
SerializerIterator it(item->peekSerializer());
TransactionMetaSet::pointer meta = boost::make_shared<TransactionMetaSet>(stTxn->getTransactionID(), lpAccepted->getLedgerSeq(), it.getVL());
pubAcceptedTransaction(lpAccepted, *stTxn, terResult,meta);
}
// OPTIMIZEME: Could get transaction from txn master, but still must call getVL
Serializer txnSer(it.getVL());
SerializerIterator txnIt(txnSer);
SerializedTransaction stTxn(txnIt);
TransactionMetaSet::pointer meta = boost::make_shared<TransactionMetaSet>(
stTxn.getTransactionID(), lpAccepted->getLedgerSeq(), it.getVL());
pubAcceptedTransaction(lpAccepted, stTxn, meta->getResultTER(), meta);
}
}
}

View File

@@ -93,6 +93,7 @@ public:
// totality functions
const std::vector<unsigned char>& peekData() const { return mData; }
std::vector<unsigned char> getData() const { return mData; }
std::vector<unsigned char>& modData() { return mData; }
int getCapacity() const { return mData.capacity(); }
int getDataLength() const { return mData.size(); }
const void* getDataPtr() const { return &mData.front(); }

View File

@@ -31,17 +31,30 @@ Transaction::pointer TransactionMaster::fetch(const uint256& txnID, bool checkDi
return txn;
}
SerializedTransaction::pointer TransactionMaster::fetch(SHAMapItem::ref item, bool checkDisk, uint32 uCommitLedger)
SerializedTransaction::pointer TransactionMaster::fetch(SHAMapItem::ref item, SHAMapTreeNode::TNType type,
bool checkDisk, uint32 uCommitLedger)
{
SerializedTransaction::pointer txn;
Transaction::pointer iTx = theApp->getMasterTransaction().fetch(item->getTag(), false);
if (!iTx)
{
if (type == SHAMapTreeNode::tnTRANSACTION_NM)
{
SerializerIterator sit(item->peekSerializer());
txn = boost::make_shared<SerializedTransaction>(boost::ref(sit));
}
else if (type == SHAMapTreeNode::tnTRANSACTION_MD)
{
Serializer s;
int length;
item->peekSerializer().getVL(s.modData(), 0, length);
SerializerIterator sit(s);
txn = boost::make_shared<SerializedTransaction>(boost::ref(sit));
}
}
else
{
if (uCommitLedger)

View File

@@ -16,7 +16,8 @@ public:
TransactionMaster();
Transaction::pointer fetch(const uint256&, bool checkDisk);
SerializedTransaction::pointer fetch(SHAMapItem::ref item, bool checkDisk, uint32 uCommitLedger);
SerializedTransaction::pointer fetch(SHAMapItem::ref item, SHAMapTreeNode:: TNType type,
bool checkDisk, uint32 uCommitLedger);
// return value: true = we had the transaction already
bool canonicalize(Transaction::pointer& txn, bool maybeNew);

View File

@@ -37,6 +37,8 @@ public:
const uint256& getTxID() { return mTransactionID; }
uint32 getLgrSeq() { return mLedger; }
int getResult() const { return mResult; }
TER getResultTER() const { return static_cast<TER>(mResult); }
bool isNodeAffected(const uint256&) const;
void setAffectedNode(const uint256&, SField::ref type, uint16 nodeType);
@@ -45,6 +47,7 @@ public:
const STObject& peekAffectedNode(const uint256&) const;
//std::vector<RippleAddress> getAffectedAccounts();
Json::Value getJson(int p) const { return getAsObject().getJson(p); }
void addRaw(Serializer&, TER);