Use make_bincode_serializer like in other places

This commit is contained in:
Bogdan-Ștefan Neacşu
2025-06-23 10:28:57 +00:00
parent ec9635447a
commit 7957d33d38
2 changed files with 12 additions and 8 deletions
+7
View File
@@ -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 {
+5 -8
View File
@@ -1,7 +1,7 @@
// Copyright 2021-2024 - Nym Technologies SA <contact@nymtech.net>
// 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<Self, crate::error::GatewayStorageError> {
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,
})
}