Skip to content

Refactor: Replace ForwardingError.is_critical with nested result #263

@carlaKC

Description

@carlaKC

Describe desired feature

Right now, sim_node enumerates the ways that a payment can fail with ForwardingError enum. If the error is unrecoverable (indicated by is_critical) there is a bug in the simulator and it will shut itself down because it has reached a state that it should never hit.

Combining regular forwarding failures (like insufficient liquidity) with bad state errors (like channel not found) is a layering violation. We should use nested results to differentiate between a failure of the simulator (unrecoverable) from a failure of a payment (expected).

For example:
add_htlcs -> Result<(), (Option<usize>, ForwardingError)>
Can return: Result<Result<(), (Option<usize>, ForwardingError)>, SimulationError>

When we hit these critical errors we don't need to worry about a fail_index to fail the payment back because we're going to shut down anyway.

h/t: elnosh for the convo that made me realize this should be cleaned up!

Use case for feature

This just seems like a reasonable cleanup.

Would you like to contribute code for this feature?

I'll review!

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