Maintain order of yielded claim events
authorWilmer Paulino <wilmer@wilmerpaulino.com>
Tue, 14 Feb 2023 23:49:37 +0000 (15:49 -0800)
committerWilmer Paulino <wilmer@wilmerpaulino.com>
Mon, 20 Mar 2023 18:32:14 +0000 (11:32 -0700)
commit4be56b93b043189f580bb62026b6d8b0da10fd4e
tree0e45583764cb6108ef83d6e6a15114dec0bba5bf
parent7b9c28a02113fe1f36d2b4d332f52fa898f8ba2f
Maintain order of yielded claim events

Since the claim events are stored internally within a HashMap, they will
be yielded in a random order once dispatched. Claim events may be
invalidated if a conflicting claim has confirmed on-chain and we need to
generate a new claim event; the randomized order could result in the
new claim event being handled prior to the previous. To maintain the
order in which the claim events are generated, we track them in a Vec
instead and ensure only one instance of a PackageId only ever exists
within it.

This would have certain performance implications, but since we're
bounded by the total number of HTLCs in a commitment anyway, we're
comfortable with taking the cost.
lightning/src/chain/onchaintx.rs