From 592ae310d73690b37c9e7571c8fa21e2e7523c66 Mon Sep 17 00:00:00 2001 From: Alex Coats Date: Mon, 6 Nov 2023 15:45:13 -0500 Subject: [PATCH] comments --- sdk/src/types/block/capabilities.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdk/src/types/block/capabilities.rs b/sdk/src/types/block/capabilities.rs index 1d23dedac3..d647be374c 100644 --- a/sdk/src/types/block/capabilities.rs +++ b/sdk/src/types/block/capabilities.rs @@ -52,11 +52,14 @@ impl Capabilities { if bytes.last().map(|b| *b == 0).unwrap_or_default() { return Err(Error::TrailingCapabilityBytes); } + // Check if the bytes are valid instances of the flag type. for (index, &byte) in bytes.iter().enumerate() { + // Get the max value of the flags at this index let mut b = 0; for flag in Flag::all().filter(|f| f.index() == index) { b |= flag.as_byte(); } + // Check whether the byte contains erroneous bits by using the max value as a mask if b | byte != b { return Err(Error::InvalidCapabilityByte { index, byte }); }