From 4639b0d7c6ca268b5e171e2b0514ac294489d9be Mon Sep 17 00:00:00 2001 From: Chris Sosnin Date: Mon, 17 Apr 2023 23:43:27 +0400 Subject: [PATCH] option watermark --- .../parachain-system/src/unincluded_segment.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pallets/parachain-system/src/unincluded_segment.rs b/pallets/parachain-system/src/unincluded_segment.rs index 7e122751b03..21e42a65ec3 100644 --- a/pallets/parachain-system/src/unincluded_segment.rs +++ b/pallets/parachain-system/src/unincluded_segment.rs @@ -289,7 +289,7 @@ pub struct SegmentTracker { /// Bandwidth used by the segment. used_bandwidth: UsedBandwidth, /// The mark which specifies the block number up to which all inbound HRMP messages are processed. - hrmp_watermark: relay_chain::BlockNumber, + hrmp_watermark: Option, /// `H` is the type of para head hash. phantom_data: PhantomData, } @@ -302,15 +302,17 @@ impl SegmentTracker { hrmp_watermark: relay_chain::BlockNumber, limits: &TotalBandwidthLimits, ) -> Result<(), BandwidthUpdateError> { - if self.hrmp_watermark > 0 && hrmp_watermark <= self.hrmp_watermark { - return Err(BandwidthUpdateError::InvalidHrmpWatermark { - submitted: hrmp_watermark, - latest: self.hrmp_watermark, - }) + if let Some(watermark) = self.hrmp_watermark.as_ref() { + if &hrmp_watermark <= watermark { + return Err(BandwidthUpdateError::InvalidHrmpWatermark { + submitted: hrmp_watermark, + latest: *watermark, + }) + } } self.used_bandwidth = self.used_bandwidth.append(block.used_bandwidth(), limits)?; - self.hrmp_watermark = hrmp_watermark; + self.hrmp_watermark.replace(hrmp_watermark); Ok(()) }