mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-20 18:45:55 +00:00
STObject::applyTemplate() throws with description of error:
The `STObject` member function `setType()` has been renamed to applyTemplate() and modified to throw if there is a template mismatch. The error description in the exception is, in certain cases, used, to better indicate why a particular transaction was considered ill formed. Fixes #2585.
This commit is contained in:
committed by
Nik Bougalis
parent
c354809e1c
commit
ad5c5f1969
@@ -55,18 +55,15 @@ auto getTxFormat (TxType type)
|
||||
return format;
|
||||
}
|
||||
|
||||
STTx::STTx (STObject&& object)
|
||||
STTx::STTx (STObject&& object) noexcept (false)
|
||||
: STObject (std::move (object))
|
||||
{
|
||||
tx_type_ = static_cast <TxType> (getFieldU16 (sfTransactionType));
|
||||
|
||||
if (!setType (getTxFormat (tx_type_)->elements))
|
||||
Throw<std::runtime_error> ("transaction not valid");
|
||||
|
||||
applyTemplate (getTxFormat (tx_type_)->elements); // may throw
|
||||
tid_ = getHash(HashPrefix::transactionID);
|
||||
}
|
||||
|
||||
STTx::STTx (SerialIter& sit)
|
||||
STTx::STTx (SerialIter& sit) noexcept (false)
|
||||
: STObject (sfTransaction)
|
||||
{
|
||||
int length = sit.getBytesLeft ();
|
||||
@@ -77,9 +74,7 @@ STTx::STTx (SerialIter& sit)
|
||||
set (sit);
|
||||
tx_type_ = static_cast<TxType> (getFieldU16 (sfTransactionType));
|
||||
|
||||
if (!setType (getTxFormat (tx_type_)->elements))
|
||||
Throw<std::runtime_error> ("transaction not valid");
|
||||
|
||||
applyTemplate (getTxFormat (tx_type_)->elements); // May throw
|
||||
tid_ = getHash(HashPrefix::transactionID);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user