Skip to content

Commit 902299b

Browse files
committed
refactor: rename code() to magic_id()
1 parent 523091b commit 902299b

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

internal/cardano-node/mithril-cardano-node-chain/src/chain_observer/pallas_observer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl PallasChainObserver {
5656

5757
/// Creates and returns a new `NodeClient` connected to the specified socket.
5858
async fn new_client(&self) -> StdResult<NodeClient> {
59-
let magic = self.network.code();
59+
let magic = self.network.magic_id();
6060
let client = NodeClient::connect(&self.socket, magic).await?;
6161

6262
Ok(client)

internal/cardano-node/mithril-cardano-node-chain/src/chain_reader/pallas_chain_reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl PallasChainReader {
3838

3939
/// Creates and returns a new `NodeClient` connected to the specified socket.
4040
async fn new_client(&self) -> StdResult<NodeClient> {
41-
let magic = self.network.code();
41+
let magic = self.network.magic_id();
4242
NodeClient::connect(&self.socket, magic)
4343
.await
4444
.map_err(|err| anyhow!(err))

internal/mithril-dmq/src/consumer/pallas.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<M: TryFromBytes + Debug> DmqConsumerPallas<M> {
4545
"socket" => ?self.socket,
4646
"network" => ?self.network
4747
);
48-
DmqClient::connect(&self.socket, self.network.code())
48+
DmqClient::connect(&self.socket, self.network.magic_id())
4949
.await
5050
.with_context(|| "DmqConsumerPallas failed to create a new client")
5151
}

internal/mithril-dmq/src/publisher/pallas.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<M: TryToBytes + Debug> DmqPublisherPallas<M> {
4040

4141
/// Creates and returns a new `DmqClient` connected to the specified socket.
4242
async fn new_client(&self) -> StdResult<DmqClient> {
43-
let magic = self.network.code();
43+
let magic = self.network.magic_id();
4444
DmqClient::connect(&self.socket, magic)
4545
.await
4646
.with_context(|| "DmqPublisherPallas failed to create a new client")

mithril-client/src/utils/bootstrap_files.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn create_bootstrap_node_files(
2323

2424
if let Ok(network) = CardanoNetwork::from_code(network.to_string(), None) {
2525
let mut file = File::create(db_dir.join(PROTOCOL_MAGIC_ID_FILENAME))?;
26-
file.write_all(format!("{}", network.code()).as_bytes())?;
26+
file.write_all(format!("{}", network.magic_id()).as_bytes())?;
2727
};
2828

2929
Ok(())
@@ -47,7 +47,7 @@ mod test {
4747

4848
let file_content =
4949
std::fs::read_to_string(db_dir.join(PROTOCOL_MAGIC_ID_FILENAME)).unwrap();
50-
assert_eq!(file_content, network.code().to_string());
50+
assert_eq!(file_content, network.magic_id().to_string());
5151

5252
assert!(db_dir.join(CLEAN_FILE_NAME).exists());
5353
}
@@ -63,7 +63,7 @@ mod test {
6363

6464
let file_content =
6565
std::fs::read_to_string(db_dir.join(PROTOCOL_MAGIC_ID_FILENAME)).unwrap();
66-
assert_eq!(file_content, network.code().to_string());
66+
assert_eq!(file_content, network.magic_id().to_string());
6767

6868
assert!(db_dir.join(CLEAN_FILE_NAME).exists());
6969
}
@@ -79,7 +79,7 @@ mod test {
7979

8080
let file_content =
8181
std::fs::read_to_string(db_dir.join(PROTOCOL_MAGIC_ID_FILENAME)).unwrap();
82-
assert_eq!(file_content, network.code().to_string());
82+
assert_eq!(file_content, network.magic_id().to_string());
8383

8484
assert!(db_dir.join(CLEAN_FILE_NAME).exists());
8585
}
@@ -96,7 +96,7 @@ mod test {
9696

9797
let file_content =
9898
std::fs::read_to_string(db_dir.join(PROTOCOL_MAGIC_ID_FILENAME)).unwrap();
99-
assert_eq!(file_content, network.code().to_string());
99+
assert_eq!(file_content, network.magic_id().to_string());
100100

101101
assert!(db_dir.join(CLEAN_FILE_NAME).exists());
102102
}

mithril-common/src/entities/cardano_network.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ impl CardanoNetwork {
5252
}
5353
}
5454

55-
/// Returns the code (magic) of the network
56-
pub fn code(&self) -> MagicId {
55+
/// Returns the magic ID of the network
56+
pub fn magic_id(&self) -> MagicId {
5757
match *self {
5858
CardanoNetwork::MainNet => MAINNET_MAGIC_ID,
5959
CardanoNetwork::TestNet(magic_id) => magic_id,
@@ -227,7 +227,7 @@ mod tests {
227227
fn assert_magic_id_conversion_roundtrip(magic_id: MagicId, expected: CardanoNetwork) {
228228
let network = CardanoNetwork::from(magic_id);
229229
assert_eq!(network, expected);
230-
assert_eq!(network.code(), magic_id);
230+
assert_eq!(network.magic_id(), magic_id);
231231
}
232232

233233
assert_magic_id_conversion_roundtrip(MAINNET_MAGIC_ID, CardanoNetwork::MainNet);

0 commit comments

Comments
 (0)