Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralize txn size calculation #4064

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/transactions/TransactionFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ TransactionFrame::getNumOperations() const
Resource
TransactionFrame::getResources(bool useByteLimitInClassic) const
{
int64_t txSize = xdr::xdr_size(mEnvelope);
auto txSize = static_cast<int64_t>(this->getSize());
if (isSoroban())
{
auto r = sorobanResources();
Expand Down Expand Up @@ -751,7 +751,7 @@ TransactionFrame::validateSorobanResources(SorobanNetworkConfig const& config,
return false;
}
}
auto txSize = xdr::xdr_size(mEnvelope);
auto txSize = this->getSize();
if (txSize > config.txMaxSizeBytes())
{
pushSimpleDiagnosticError(
Expand Down Expand Up @@ -1900,4 +1900,11 @@ TransactionFrame::getDiagnosticEvents() const
{
return mSorobanExtension->mDiagnosticEvents;
}

uint32_t
TransactionFrame::getSize() const
{
ZoneScoped;
return static_cast<uint32_t>(xdr::xdr_size(mEnvelope));
}
} // namespace stellar
3 changes: 3 additions & 0 deletions src/transactions/TransactionFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ using TransactionFramePtr = std::shared_ptr<TransactionFrame>;

class TransactionFrame : public TransactionFrameBase
{
private:
uint32_t getSize() const;

protected:
TransactionEnvelope mEnvelope;
TransactionResult mResult;
Expand Down