diff --git a/crates/rbuilder-primitives/src/lib.rs b/crates/rbuilder-primitives/src/lib.rs index fb753b207..49848a74f 100644 --- a/crates/rbuilder-primitives/src/lib.rs +++ b/crates/rbuilder-primitives/src/lib.rs @@ -52,7 +52,7 @@ pub struct Metadata { /// Order refund identity. pub refund_identity: Option
, /// `RawBundle` field, round-tripped through `Bundle`. Not consumed by rbuilder. - pub disable_cross_region_sharing: Option, + pub disable_cross_region_sharing: bool, } impl Default for Metadata { @@ -73,7 +73,7 @@ impl Metadata { received_at_timestamp, is_system: false, refund_identity: None, - disable_cross_region_sharing: None, + disable_cross_region_sharing: false, } } @@ -99,17 +99,10 @@ impl Metadata { self.refund_identity = refund_identity; } - pub fn with_disable_cross_region_sharing( - mut self, - disable_cross_region_sharing: Option, - ) -> Self { + pub fn with_disable_cross_region_sharing(mut self, disable_cross_region_sharing: bool) -> Self { self.disable_cross_region_sharing = disable_cross_region_sharing; self } - - pub fn set_disable_cross_region_sharing(&mut self, disable_cross_region_sharing: Option) { - self.disable_cross_region_sharing = disable_cross_region_sharing; - } } impl InMemorySize for Metadata { @@ -117,7 +110,7 @@ impl InMemorySize for Metadata { mem::size_of::() + // received_at_timestamp mem::size_of::>() + // refund_identity mem::size_of::() + // is_system - mem::size_of::>() // disable_cross_region_sharing + mem::size_of::() // disable_cross_region_sharing } } diff --git a/crates/rbuilder-primitives/src/serialize.rs b/crates/rbuilder-primitives/src/serialize.rs index c423aa9aa..d11436eb2 100644 --- a/crates/rbuilder-primitives/src/serialize.rs +++ b/crates/rbuilder-primitives/src/serialize.rs @@ -154,8 +154,12 @@ pub struct RawBundleMetadata { #[serde(skip_serializing_if = "Option::is_none")] pub bundle_hash: Option, /// Disable multiplexing bundle to other region builders. - #[serde(skip_serializing_if = "Option::is_none")] - pub disable_cross_region_sharing: Option, + #[serde(default, skip_serializing_if = "is_false")] + pub disable_cross_region_sharing: bool, +} + +fn is_false(b: &bool) -> bool { + !*b } impl RawBundleMetadata { @@ -234,7 +238,7 @@ impl RawBundleMetadata { version, )); } - if self.disable_cross_region_sharing.is_some() { + if self.disable_cross_region_sharing { return Err(RawBundleConvertError::FieldNotSupportedByVersion( "disable_cross_region_sharing".to_owned(), version, diff --git a/crates/rbuilder/src/backtest/build_block/synthetic_orders.rs b/crates/rbuilder/src/backtest/build_block/synthetic_orders.rs index 6c6af52cd..3f337eef7 100644 --- a/crates/rbuilder/src/backtest/build_block/synthetic_orders.rs +++ b/crates/rbuilder/src/backtest/build_block/synthetic_orders.rs @@ -98,7 +98,7 @@ impl SyntheticOrdersSource { received_at_timestamp: time::OffsetDateTime::from_unix_timestamp(0).unwrap(), is_system: false, refund_identity: None, - disable_cross_region_sharing: None, + disable_cross_region_sharing: false, }, dropping_tx_hashes: Default::default(), refund: None, diff --git a/crates/rbuilder/src/backtest/store.rs b/crates/rbuilder/src/backtest/store.rs index b5bef21b2..3311c239e 100644 --- a/crates/rbuilder/src/backtest/store.rs +++ b/crates/rbuilder/src/backtest/store.rs @@ -744,7 +744,7 @@ mod test { refund_identity: None, version: Some(RawBundle::encode_version(LAST_BUNDLE_VERSION)), bundle_hash: None, - disable_cross_region_sharing: None, + disable_cross_region_sharing: false, }, })), }