Skip to content

Commit

Permalink
TaggedDataPayload cleanup (#1644)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez authored Nov 20, 2023
1 parent 7a1310f commit e595d73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sdk/src/types/block/payload/candidacy_announcement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ use packable::Packable;
pub struct CandidacyAnnouncementPayload;

impl CandidacyAnnouncementPayload {
/// The payload kind of a [`CandidacyAnnouncementPayload`].
/// The [`Payload`](crate::types::block::payload::Payload) kind of a [`CandidacyAnnouncementPayload`].
pub const KIND: u8 = 2;
}
2 changes: 1 addition & 1 deletion sdk/src/types/block/payload/signed_transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct SignedTransactionPayload {
}

impl SignedTransactionPayload {
/// The payload kind of a [`SignedTransactionPayload`].
/// The [`Payload`](crate::types::block::payload::Payload) kind of a [`SignedTransactionPayload`].
pub const KIND: u8 = 1;

/// Creates a new [`SignedTransactionPayload`].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use packable::{
Packable,
};

use crate::types::block::{Block, Error};
use crate::types::block::Error;

pub(crate) type TagLength =
BoundedU8<{ *TaggedDataPayload::TAG_LENGTH_RANGE.start() }, { *TaggedDataPayload::TAG_LENGTH_RANGE.end() }>;
Expand All @@ -30,15 +30,12 @@ pub struct TaggedDataPayload {
}

impl TaggedDataPayload {
/// The payload kind of a [`TaggedDataPayload`].
/// The [`Payload`](crate::types::block::payload::Payload) kind of a [`TaggedDataPayload`].
pub const KIND: u8 = 0;
/// Valid lengths for the tag.
/// Valid length range for the tag.
pub const TAG_LENGTH_RANGE: RangeInclusive<u8> = 0..=64;
/// Valid lengths for the data.
// Less than max block length, because of the other fields in the block and payload kind, tagged payload field
// lengths.
// TODO https://github.com/iotaledger/iota-sdk/issues/1226
pub const DATA_LENGTH_RANGE: RangeInclusive<u32> = 0..=(Block::LENGTH_MAX - Block::LENGTH_MIN - 9) as u32;
/// Valid length range for the data.
pub const DATA_LENGTH_RANGE: RangeInclusive<u32> = 0..=8192;

/// Creates a new [`TaggedDataPayload`].
pub fn new(tag: impl Into<Box<[u8]>>, data: impl Into<Box<[u8]>>) -> Result<Self, Error> {
Expand Down

0 comments on commit e595d73

Please sign in to comment.