Skip to content

AST Cleanup: Split After / Older into more specific types? #270

@JeremyRubin

Description

@JeremyRubin

Suggestion:

While keeping the parsing and output intact for compatibility, we could modify our internal representations of After and Older to be:

AfterHeight(), AfterTime(), WaitBlocks(), WaitDuration() or an internal enum (e.g., After(Height | Time), Wait(Blocks | Duration)).

In Sapio I accomplish this at the user level, but it would probably make sense for those branches to be distinct. This also allows (as I've done in the library) to narrow the types used in the internal representations from e.g. u32s for relative timelocks to u16s making the values correct by construction. This also rules out using non-standardized values.

Users of the Library from Rust would have the improved interface, which would make it easier to write "correct" generic code as users would be able to be unconcerned with checking inputs u32s for well formedness to a Older/After clause, while users using this as a string interface would see the old API (unless we modify the spec to have the 4 types of clause).

If the more generic API of Older/After is desired, this could be accomplished with a function Older/After (or type with Into) that takes a u32 and downcasts into the appropriate type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions