feat: add expires_in API with backward compatibility for BTL #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a new, more intuitive API for managing entity expiration times while maintaining full backward compatibility with the existing BTL (Block-to-Live) system.
Changes
New ExpirationTime Builder Class
from_seconds(),from_hours(),from_days(),from_blocks()New API Fields
expires_in(int | ExpirationTime) replacesbtlinArkivCreateandArkivUpdateduration(int | ExpirationTime) replacesnumber_of_blocksinArkivExtendint, it represents duration in seconds (not blocks)Examples
Simple way - seconds as int:
With builder - more readable:
Legacy API (deprecated but still works):
Backward Compatibility
Deprecated but Functional
btlfield (inArkivCreateandArkivUpdate)number_of_blocksfield (inArkivExtend)Priority System
expires_in>btlduration>number_of_blocksMigration
Technical Details
resolve_expiration_blocks()for expires_in/btl resolutionresolve_extension_blocks()for duration/number_of_blocks resolutionutils.pyto use resolution functions in RLP encodingMigration Guide
Users can migrate gradually: