mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Cache tid in STTx:
The digest for a transaction (its transaction ID, or tid) is computed once upon constructed when the STTx is deserialized. Subsequent calls to retrieve the digest use the cached value. Any code which modifies the STTx and then attempts to retrieve the digest will terminate the process with a logic error contract violation. * Nested types removed * All STTx are contained as const (Except in transaction sign, which must modify) * tid in STTx is computed once on deserialization
This commit is contained in:
@@ -295,11 +295,11 @@ checkTxJsonFields (
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// A move-only struct that makes it easy to return either a Json::Value or a
|
||||
// STTx::pointer from transactionPreProcessImpl ().
|
||||
// std::shared_ptr<STTx const> from transactionPreProcessImpl ().
|
||||
struct transactionPreProcessResult
|
||||
{
|
||||
Json::Value const first;
|
||||
STTx::pointer const second;
|
||||
std::shared_ptr<STTx const> const second;
|
||||
|
||||
transactionPreProcessResult () = delete;
|
||||
transactionPreProcessResult (transactionPreProcessResult const&) = delete;
|
||||
@@ -318,7 +318,7 @@ struct transactionPreProcessResult
|
||||
, second ()
|
||||
{ }
|
||||
|
||||
transactionPreProcessResult (STTx::pointer&& st)
|
||||
transactionPreProcessResult (std::shared_ptr<STTx const>&& st)
|
||||
: first ()
|
||||
, second (std::move (st))
|
||||
{ }
|
||||
@@ -463,7 +463,7 @@ transactionPreProcessImpl (
|
||||
return std::move (err);
|
||||
}
|
||||
|
||||
STTx::pointer stpTrans;
|
||||
std::shared_ptr<STTx> stpTrans;
|
||||
try
|
||||
{
|
||||
// If we're generating a multi-signature the SigningPubKey must be
|
||||
@@ -501,12 +501,12 @@ transactionPreProcessImpl (
|
||||
stpTrans->sign (keypair.secretKey);
|
||||
}
|
||||
|
||||
return std::move (stpTrans);
|
||||
return transactionPreProcessResult {std::move (stpTrans)};
|
||||
}
|
||||
|
||||
static
|
||||
std::pair <Json::Value, Transaction::pointer>
|
||||
transactionConstructImpl (STTx::pointer stpTrans,
|
||||
transactionConstructImpl (std::shared_ptr<STTx const> const& stpTrans,
|
||||
Rules const& rules, Application& app)
|
||||
{
|
||||
std::pair <Json::Value, Transaction::pointer> ret;
|
||||
@@ -931,7 +931,7 @@ Json::Value transactionSubmitMultiSigned (
|
||||
}
|
||||
|
||||
// Grind through the JSON in tx_json to produce a STTx
|
||||
STTx::pointer stpTrans;
|
||||
std::shared_ptr<STTx> stpTrans;
|
||||
{
|
||||
STParsedJSONObject parsedTx_json ("tx_json", tx_json);
|
||||
if (!parsedTx_json.object)
|
||||
@@ -944,8 +944,8 @@ Json::Value transactionSubmitMultiSigned (
|
||||
}
|
||||
try
|
||||
{
|
||||
stpTrans =
|
||||
std::make_shared<STTx> (std::move(parsedTx_json.object.get()));
|
||||
stpTrans = std::make_shared<STTx>(
|
||||
std::move(parsedTx_json.object.get()));
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user