-
Notifications
You must be signed in to change notification settings - Fork 773
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
tx: add getDataFee to tx cache #1532
Changes from 5 commits
59e1bda
22f7d8b
3bff689
9f37892
9021108
abcfd9c
9116e96
f94bdd6
503171e
cd0db8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,6 +218,19 @@ export default class Transaction extends BaseTransaction<Transaction> { | |
} | ||
} | ||
|
||
/** | ||
* The amount of gas paid for the data in this tx | ||
*/ | ||
getDataFee(): BN { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to add this? would it not work falling back to the default baseTransaction method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a little weird because the cache is created in baseTransaction, but caching doesn't actually happen in baseTransaction because it doesn't have the option to be frozen. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, just remembered, my first attempt was to implement the caching in baseTransaction, but the issue I ran into was that eip1559Transaction and eip2930Transaction both call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, guess that makes sense. Can you structurally align this method with the other two methods? So with this |
||
if (Object.isFrozen(this)) { | ||
if (!this.cache.dataFee) { | ||
this.cache.dataFee = super.getDataFee() | ||
} | ||
return this.cache.dataFee | ||
} | ||
return super.getDataFee() | ||
} | ||
|
||
/** | ||
* The up front amount that an account must have for this transaction to be valid | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the first
if
condition you can remove theObject.isFrozen(this)
check and on the second thethis.cache.dataFee
check. Guess this reads a bit better and is less redundant, also for the other tx types.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call - updated and it does read better