Skip to content

Commit 0968a72

Browse files
authored
Remove unused message ID functions. (#3903)
## Motivation `MessageId` is now used only in the SDK, not in the protocol itself. ## Proposal Remove unused functions. ## Test Plan CI ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent d0d1aac commit 0968a72

File tree

3 files changed

+2
-70
lines changed

3 files changed

+2
-70
lines changed

linera-chain/src/block.rs

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use linera_base::{
1313
crypto::{BcsHashable, CryptoHash},
1414
data_types::{Blob, BlockHeight, Epoch, Event, OracleResponse, Timestamp},
1515
hashed::Hashed,
16-
identifiers::{AccountOwner, BlobId, BlobType, ChainId, MessageId},
16+
identifiers::{AccountOwner, BlobId, BlobType, ChainId},
1717
};
1818
use linera_execution::{BlobState, Operation, OutgoingMessage};
1919
use serde::{ser::SerializeStruct, Deserialize, Serialize};
@@ -437,60 +437,6 @@ impl Block {
437437
})
438438
}
439439

440-
/// Returns the `message_index`th outgoing message created by the `operation_index`th operation,
441-
/// or `None` if there is no such operation or message.
442-
pub fn message_id_for_operation(
443-
&self,
444-
operation_index: usize,
445-
message_index: u32,
446-
) -> Option<MessageId> {
447-
let block = &self.body;
448-
let transaction_index = block.incoming_bundles.len().checked_add(operation_index)?;
449-
if message_index >= u32::try_from(self.body.messages.get(transaction_index)?.len()).ok()? {
450-
return None;
451-
}
452-
let first_message_index = u32::try_from(
453-
self.body
454-
.messages
455-
.iter()
456-
.take(transaction_index)
457-
.map(Vec::len)
458-
.sum::<usize>(),
459-
)
460-
.ok()?;
461-
let index = first_message_index.checked_add(message_index)?;
462-
Some(self.message_id(index))
463-
}
464-
465-
/// Returns the message ID belonging to the `index`th outgoing message in this block.
466-
pub fn message_id(&self, index: u32) -> MessageId {
467-
MessageId {
468-
chain_id: self.header.chain_id,
469-
height: self.header.height,
470-
index,
471-
}
472-
}
473-
474-
/// Returns the outgoing message with the specified id, or `None` if there is no such message.
475-
pub fn message_by_id(&self, message_id: &MessageId) -> Option<&OutgoingMessage> {
476-
let MessageId {
477-
chain_id,
478-
height,
479-
index,
480-
} = message_id;
481-
if self.header.chain_id != *chain_id || self.header.height != *height {
482-
return None;
483-
}
484-
let mut index = usize::try_from(*index).ok()?;
485-
for messages in self.messages() {
486-
if let Some(message) = messages.get(index) {
487-
return Some(message);
488-
}
489-
index -= messages.len();
490-
}
491-
None
492-
}
493-
494440
/// Returns all the blob IDs required by this block.
495441
/// Either as oracle responses or as published blobs.
496442
pub fn required_blob_ids(&self) -> BTreeSet<BlobId> {

linera-chain/src/certificate/confirmed.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use linera_base::{
66
crypto::{ValidatorPublicKey, ValidatorSignature},
77
data_types::{Epoch, Round},
8-
identifiers::{ChainId, MessageId},
8+
identifiers::ChainId,
99
};
1010
use serde::{ser::SerializeStruct, Deserialize, Deserializer, Serialize};
1111

@@ -21,11 +21,6 @@ impl GenericCertificate<ConfirmedBlock> {
2121
self.inner().block()
2222
}
2323

24-
/// Returns whether this value contains the message with the specified ID.
25-
pub fn has_message(&self, message_id: &MessageId) -> bool {
26-
self.block().message_by_id(message_id).is_some()
27-
}
28-
2924
/// Returns the bundles of messages sent to the specified recipient.
3025
/// Messages originating from different transactions of the original block
3126
/// are kept in separate bundles.

linera-chain/src/data_types.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,6 @@ impl ProposedBlock {
123123
);
124124
Ok(())
125125
}
126-
127-
/// Returns the message ID belonging to the `index`th outgoing message in this block.
128-
pub fn message_id(&self, index: u32) -> MessageId {
129-
MessageId {
130-
chain_id: self.chain_id,
131-
height: self.height,
132-
index,
133-
}
134-
}
135126
}
136127

137128
/// A transaction in a block: incoming messages or an operation.

0 commit comments

Comments
 (0)