Ejemplo n.º 1
0
bool Transaction::convertToTransactions (uint32 firstLedgerSeq, uint32 secondLedgerSeq,
        bool checkFirstTransactions, bool checkSecondTransactions, const SHAMap::Delta& inMap,
        std::map<uint256, std::pair<Transaction::pointer, Transaction::pointer> >& outMap)
{
    // convert a straight SHAMap payload difference to a transaction difference table
    // return value: true=ledgers are valid, false=a ledger is invalid
    SHAMap::Delta::const_iterator it;

    for (it = inMap.begin (); it != inMap.end (); ++it)
    {
        uint256 const& id = it->first;
        SHAMapItem::ref first = it->second.first;
        SHAMapItem::ref second = it->second.second;

        Transaction::pointer firstTrans, secondTrans;

        if (!!first)
        {
            // transaction in our table
            firstTrans = sharedTransaction (first->peekData (), checkFirstTransactions);

            if ((firstTrans->getStatus () == INVALID) || (firstTrans->getID () != id ))
            {
                firstTrans->setStatus (INVALID, firstLedgerSeq);
                return false;
            }
            else firstTrans->setStatus (INCLUDED, firstLedgerSeq);
        }

        if (!!second)
        {
            // transaction in other table
            secondTrans = sharedTransaction (second->peekData (), checkSecondTransactions);

            if ((secondTrans->getStatus () == INVALID) || (secondTrans->getID () != id))
            {
                secondTrans->setStatus (INVALID, secondLedgerSeq);
                return false;
            }
            else secondTrans->setStatus (INCLUDED, secondLedgerSeq);
        }

        assert (firstTrans || secondTrans);

        if (firstTrans && secondTrans && (firstTrans->getStatus () != INVALID) && (secondTrans->getStatus () != INVALID))
            return false; // one or the other SHAMap is structurally invalid or a miracle has happened

        outMap[id] = std::pair<Transaction::pointer, Transaction::pointer> (firstTrans, secondTrans);
    }

    return true;
}
Ejemplo n.º 2
0
SHAMapTreeNode::SHAMapTreeNode (const SHAMapNode& node, SHAMapItem::ref item, TNType type, uint32 seq) :
    SHAMapNode (node), mItem (item), mSeq (seq), mType (type), mIsBranch (0), mFullBelow (false)
{
    assert (item->peekData ().size () >= 12);
    updateHash ();
}