Skip to content

Commit

Permalink
comment out the new shard id
Browse files Browse the repository at this point in the history
  • Loading branch information
wacban committed Oct 11, 2024
1 parent a8719d4 commit 5059462
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions core/primitives-core/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "new_shard_id")]
use std::fmt::Display;
// #[cfg(feature = "new_shard_id")]
// use std::fmt::Display;

use crate::hash::CryptoHash;

Expand Down Expand Up @@ -49,7 +49,7 @@ pub type ProtocolVersion = u32;

/// The shard identifier. The ShardId is currently being migrated to a newtype -
/// please see the new ShardId definition below.
#[cfg(not(feature = "new_shard_id"))]
// #[cfg(not(feature = "new_shard_id"))]
pub type ShardId = u64;

/// The ShardIndex is the index of the shard in an array of shard data.
Expand All @@ -62,11 +62,11 @@ pub type ShardIndex = usize;
// ShardId as a newtype. It should be replaced / removed / inlined once the
// transition is complete.
pub const fn new_shard_id_tmp(id: u64) -> ShardId {
#[cfg(not(feature = "new_shard_id"))]
// #[cfg(not(feature = "new_shard_id"))]
return id;

#[cfg(feature = "new_shard_id")]
return ShardId::new(id);
// #[cfg(feature = "new_shard_id")]
// return ShardId::new(id);
}

// TODO(wacban) This is a temporary solution to aid the transition to having
Expand All @@ -77,55 +77,55 @@ pub fn new_shard_id_vec_tmp(vec: &[u64]) -> Vec<ShardId> {
}

pub fn shard_id_max() -> ShardId {
#[cfg(not(feature = "new_shard_id"))]
// #[cfg(not(feature = "new_shard_id"))]
return ShardId::MAX;

#[cfg(feature = "new_shard_id")]
return ShardId::max();
// #[cfg(feature = "new_shard_id")]
// return ShardId::max();
}

// TODO(wacban) This is a temporary solution to aid the transition to having
// ShardId as a newtype. It should be replaced / removed / inlined once the
// transition is complete.
pub const fn shard_id_as_usize(id: ShardId) -> usize {
#[cfg(not(feature = "new_shard_id"))]
// #[cfg(not(feature = "new_shard_id"))]
return id as usize;

#[cfg(feature = "new_shard_id")]
return id.get() as usize;
// #[cfg(feature = "new_shard_id")]
// return id.get() as usize;
}

// TODO(wacban) This is a temporary solution to aid the transition to having
// ShardId as a newtype. It should be replaced / removed / inlined once the
// transition is complete.
pub const fn shard_id_as_u16(id: ShardId) -> u16 {
#[cfg(not(feature = "new_shard_id"))]
// #[cfg(not(feature = "new_shard_id"))]
return id as u16;

#[cfg(feature = "new_shard_id")]
return id.get() as u16;
// #[cfg(feature = "new_shard_id")]
// return id.get() as u16;
}

// TODO(wacban) This is a temporary solution to aid the transition to having
// ShardId as a newtype. It should be replaced / removed / inlined once the
// transition is complete.
pub const fn shard_id_as_u32(id: ShardId) -> u32 {
#[cfg(not(feature = "new_shard_id"))]
// #[cfg(not(feature = "new_shard_id"))]
return id as u32;

#[cfg(feature = "new_shard_id")]
return id.get() as u32;
// #[cfg(feature = "new_shard_id")]
// return id.get() as u32;
}

// TODO(wacban) This is a temporary solution to aid the transition to having
// ShardId as a newtype. It should be replaced / removed / inlined once the
// transition is complete.
pub const fn shard_id_as_u64(id: ShardId) -> u64 {
#[cfg(not(feature = "new_shard_id"))]
// #[cfg(not(feature = "new_shard_id"))]
return id as u64;

#[cfg(feature = "new_shard_id")]
return id.get() as u64;
// #[cfg(feature = "new_shard_id")]
// return id.get() as u64;
}

/*
Expand Down

0 comments on commit 5059462

Please sign in to comment.