From a4c82632fbab521729225da54ae8daa41f615af3 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Mon, 18 Dec 2023 11:09:16 -0500 Subject: [PATCH] Use pub(crate) for create_db items, not pub --- common/db/src/create_db.rs | 14 +++++++------- coordinator/src/substrate/db.rs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/db/src/create_db.rs b/common/db/src/create_db.rs index 2f3626d2..abd86e46 100644 --- a/common/db/src/create_db.rs +++ b/common/db/src/create_db.rs @@ -42,9 +42,9 @@ macro_rules! create_db { }) => { $( #[derive(Clone, Debug)] - pub struct $field_name; + pub(crate) struct $field_name; impl $field_name { - pub fn key($($arg: $arg_type),*) -> Vec { + pub(crate) fn key($($arg: $arg_type),*) -> Vec { use scale::Encode; $crate::serai_db_key( stringify!($db_name).as_bytes(), @@ -52,17 +52,17 @@ macro_rules! create_db { ($($arg),*).encode() ) } - pub fn set(txn: &mut impl DbTxn $(, $arg: $arg_type)*, data: &$field_type) { + pub(crate) fn set(txn: &mut impl DbTxn $(, $arg: $arg_type)*, data: &$field_type) { let key = $field_name::key($($arg),*); txn.put(&key, borsh::to_vec(data).unwrap()); } - pub fn get(getter: &impl Get, $($arg: $arg_type),*) -> Option<$field_type> { + pub(crate) fn get(getter: &impl Get, $($arg: $arg_type),*) -> Option<$field_type> { getter.get($field_name::key($($arg),*)).map(|data| { borsh::from_slice(data.as_ref()).unwrap() }) } #[allow(dead_code)] - pub fn del(txn: &mut impl DbTxn $(, $arg: $arg_type)*) { + pub(crate) fn del(txn: &mut impl DbTxn $(, $arg: $arg_type)*) { txn.del(&$field_name::key($($arg),*)) } } @@ -83,7 +83,7 @@ macro_rules! db_channel { } impl $field_name { - pub fn send(txn: &mut impl DbTxn $(, $arg: $arg_type)*, value: &$field_type) { + pub(crate) fn send(txn: &mut impl DbTxn $(, $arg: $arg_type)*, value: &$field_type) { // Use index 0 to store the amount of messages let messages_sent_key = $field_name::key($($arg),*, 0); let messages_sent = txn.get(&messages_sent_key).map(|counter| { @@ -98,7 +98,7 @@ macro_rules! db_channel { $field_name::set(txn, $($arg),*, index_to_use, value); } - pub fn try_recv(txn: &mut impl DbTxn $(, $arg: $arg_type)*) -> Option<$field_type> { + pub(crate) fn try_recv(txn: &mut impl DbTxn $(, $arg: $arg_type)*) -> Option<$field_type> { let messages_recvd_key = $field_name::key($($arg),*, 1); let messages_recvd = txn.get(&messages_recvd_key).map(|counter| { u32::from_le_bytes(counter.try_into().unwrap()) diff --git a/coordinator/src/substrate/db.rs b/coordinator/src/substrate/db.rs index 6f000f76..2621e5ef 100644 --- a/coordinator/src/substrate/db.rs +++ b/coordinator/src/substrate/db.rs @@ -13,7 +13,7 @@ mod inner_db { } ); } -pub use inner_db::{NextBlock, BatchInstructionsHashDb}; +pub(crate) use inner_db::{NextBlock, BatchInstructionsHashDb}; pub struct HandledEvent; impl HandledEvent {