From 7957d33d38fe2144bfb41233f8caac203c85c5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C5=9Fu?= Date: Mon, 23 Jun 2025 10:28:57 +0000 Subject: [PATCH] Use make_bincode_serializer like in other places --- common/gateway-storage/src/lib.rs | 7 +++++++ common/gateway-storage/src/models.rs | 13 +++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/common/gateway-storage/src/lib.rs b/common/gateway-storage/src/lib.rs index 4c9746d3ee..ee58eb5464 100644 --- a/common/gateway-storage/src/lib.rs +++ b/common/gateway-storage/src/lib.rs @@ -36,6 +36,13 @@ pub use inboxes::InboxManager; use crate::traits::{BandwidthGatewayStorage, InboxGatewayStorage, SharedKeyGatewayStorage}; +fn make_bincode_serializer() -> impl bincode::Options { + use bincode::Options; + bincode::DefaultOptions::new() + .with_big_endian() + .with_varint_encoding() +} + // note that clone here is fine as upon cloning the same underlying pool will be used #[derive(Clone)] pub struct GatewayStorage { diff --git a/common/gateway-storage/src/models.rs b/common/gateway-storage/src/models.rs index 7bcaaa594c..723b90351e 100644 --- a/common/gateway-storage/src/models.rs +++ b/common/gateway-storage/src/models.rs @@ -1,7 +1,7 @@ // Copyright 2021-2024 - Nym Technologies SA // SPDX-License-Identifier: GPL-3.0-only -use crate::error::GatewayStorageError; +use crate::{error::GatewayStorageError, make_bincode_serializer}; use nym_credentials_interface::{AvailableBandwidth, ClientTicket, CredentialSpendingData}; use nym_gateway_requests::shared_key::{LegacySharedKeys, SharedGatewayKey, SharedSymmetricKey}; use sqlx::FromRow; @@ -121,13 +121,10 @@ impl WireguardPeer { ) -> Result { Ok(WireguardPeer { public_key: value.public_key.to_string(), - allowed_ips: bincode::Options::serialize( - bincode::DefaultOptions::new(), - &value.allowed_ips, - ) - .map_err(|e| { - crate::error::GatewayStorageError::TypeConversion(format!("allowed ips {e}")) - })?, + allowed_ips: bincode::Options::serialize(make_bincode_serializer(), &value.allowed_ips) + .map_err(|e| { + crate::error::GatewayStorageError::TypeConversion(format!("allowed ips {e}")) + })?, client_id, }) }