Beispiel #1
0
STLedgerEntry::STLedgerEntry (Keylet const& k)
    :  STObject(sfLedgerEntry)
    , key_ (k.key)
    , type_ (k.type)
    , mMutable (true)
{
    mFormat =
        LedgerFormats::getInstance().findByType (type_);
    if (mFormat == nullptr)
        throw std::runtime_error ("invalid ledger entry type");
    set (mFormat->elements);
    setFieldU16 (sfLedgerEntryType,
        static_cast <std::uint16_t> (mFormat->getType ()));
}
Beispiel #2
0
STTx::STTx (TxType type)
    : STObject (sfTransaction)
    , tx_type_ (type)
{
    auto format = TxFormats::getInstance().findByType (type);

    if (format == nullptr)
    {
        WriteLog (lsWARNING, STTx) <<
            "Transaction type: " << type;
        throw std::runtime_error ("invalid transaction type");
    }

    set (format->elements);
    setFieldU16 (sfTransactionType, format->getType ());
}
Beispiel #3
0
STLedgerEntry::STLedgerEntry (Keylet const& k)
    :  STObject(sfLedgerEntry)
    , key_ (k.key)
    , type_ (k.type)
{
    auto const format =
        LedgerFormats::getInstance().findByType (type_);

    if (format == nullptr)
        Throw<std::runtime_error> ("invalid ledger entry type");

    set (format->elements);

    setFieldU16 (sfLedgerEntryType,
                 static_cast <std::uint16_t> (type_));
}
SerializedTransaction::SerializedTransaction (TxType type)
    : STObject (sfTransaction)
    , mType (type)
    , mSigGood (false)
    , mSigBad (false)
{
    mFormat = TxFormats::getInstance()->findByType (type);

    if (mFormat == nullptr)
    {
        WriteLog (lsWARNING, SerializedTransaction) << "Transaction type: " << type;
        throw std::runtime_error ("invalid transaction type");
    }

    set (mFormat->elements);
    setFieldU16 (sfTransactionType, mFormat->getType ());
}
Beispiel #5
0
SerializedLedgerEntry::SerializedLedgerEntry (LedgerEntryType type, uint256 const& index) :
    STObject (sfLedgerEntry), mIndex (index), mType (type), mMutable (true)
{
    LedgerFormats::Item const* const item =
        LedgerFormats::getInstance()->findByType (type);

    if (item != nullptr)
    {
        set (item->elements);

        setFieldU16 (sfLedgerEntryType, static_cast <std::uint16_t> (item->getType ()));
    }
    else
    {
        throw std::runtime_error ("invalid ledger entry type");
    }
}
Beispiel #6
0
STTx::STTx (
        TxType type,
        std::function<void(STObject&)> assembler)
    : STObject (sfTransaction)
{
    auto format = getTxFormat (type);

    set (format->elements);
    setFieldU16 (sfTransactionType, format->getType ());

    assembler (*this);

    tx_type_ = static_cast<TxType>(getFieldU16 (sfTransactionType));

    if (tx_type_ != type)
        LogicError ("Transaction type was mutated during assembly");

    tid_ = getHash(HashPrefix::transactionID);
}