Encapsulate feature flag checking and manipulation
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 10 Apr 2020 00:08:48 +0000 (17:08 -0700)
committerJeffrey Czyz <jkczyz@gmail.com>
Wed, 29 Apr 2020 18:07:47 +0000 (11:07 -0700)
commit491bbc56cfcfa5c62c79113d1af2d17c37fbb75d
tree02cffb91126f70f153a6efbb4581e002f08bba5d
parent07cea6bfeda1641c2a1440f4e4847c747507c4f0
Encapsulate feature flag checking and manipulation

Each feature is represented by two bits within Features' flags field.
Working with these flags requires bitwise operations, which can be error
prone. Rather than directly checking and manipulating bits, encapsulate
the bits within each feature trait and provide mechanisms for doing so.

This removes the need to comment on which features correspond to bitwise
expressions since the expressions use feature trait identifiers instead.

With this approach, byte literals and expressions can be evaluated at
compile time still. However, for these cases, knowing which byte within
the flags that a feature corresponds to still must be determined by the
implementor.

Remove the special case where initial_routing_sync has no even bit. Now,
it (bit 2) is considered known by the implementation.
lightning/src/ln/features.rs