commit 7a479be882040996a46d0b26d99b0e87eba25bb7
parent fd0e1329a1cce2e437a081fa59b5fbee06ac2f08
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 10 Oct 2026 13:32:39 +0400
lib: hand-written NFData for FeatureVector, no Generic
FeatureVector is abstract, so it shouldn't expose a Generic
representation. Also documents which contexts admit no known feature.
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/Lightning/Protocol/BOLT9.hs b/lib/Lightning/Protocol/BOLT9.hs
@@ -82,7 +82,7 @@ module Lightning.Protocol.BOLT9 (
, channel_type_features
) where
-import Control.DeepSeq (NFData)
+import Control.DeepSeq (NFData(..))
import qualified Data.Bits as B
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
@@ -109,7 +109,6 @@ import GHC.Generics (Generic)
-- >>> set_bit 1 empty
-- parse "\STX"
newtype FeatureVector = FeatureVector ByteString
- deriving Generic
instance Eq FeatureVector where
FeatureVector a == FeatureVector b = strip a == strip b
@@ -118,7 +117,8 @@ instance Show FeatureVector where
showsPrec d (FeatureVector bs) = showParen (d > 10) $
showString "parse " . showsPrec 11 bs
-instance NFData FeatureVector
+instance NFData FeatureVector where
+ rnf (FeatureVector bs) = rnf bs
-- | Parse a feature vector from its wire bytes. Every byte string is a
-- valid feature vector.
@@ -558,7 +558,9 @@ instance NFData ValidationError
-- * each set feature's dependencies are set. A dependency on an
-- ASSUMED feature counts as met even when its bits are clear.
--
--- Errors are reported in that order.
+-- Errors are reported in that order. No known feature is presented
+-- in 'ChannelContext' or 'BlindedContext', so only the empty vector
+-- passes there (as BOLT #4 requires of @allowed_features@).
--
-- >>> validate_local InitContext (set_feature OptionZeroconf Optional empty)
-- Left (MissingDependency OptionZeroconf OptionScidAlias :| [])