krishvishal commented on code in PR #2389:
URL: https://github.com/apache/iggy/pull/2389#discussion_r2551312135


##########
core/common/src/types/consensus/header.rs:
##########
@@ -15,7 +15,310 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use bytemuck::{Pod, Zeroable};
+
 #[expect(unused)]
 pub struct Header {}
 
-pub trait ConsensusHeader {}
+pub trait ConsensusHeader: Sized + Pod + Zeroable {
+    const COMMAND: Command;
+
+    fn size(&self) -> u32;
+    fn command(&self) -> Command;
+    fn checksum(&self) -> u128;
+    fn cluster(&self) -> u128;
+
+    fn validate(&self) -> Result<(), &'static str>;
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(u8)]
+pub enum Command {
+    Reserved = 0,
+
+    Ping = 1,
+    Pong = 2,
+    PingClient = 3,
+    PongClient = 4,
+
+    Request = 5,
+    Prepare = 6,
+    PrepareOk = 7,
+    Reply = 8,
+    Commit = 9,
+
+    StartViewChange = 10,
+    DoViewChange = 11,
+    StartView = 24,
+
+    RequestStartView = 12,
+    RequstHeads = 13,
+    RequestPrepare = 14,
+    RequestReply = 15,
+
+    Headers = 16,
+
+    Eviction = 17,
+
+    RequestBlocks = 18,
+    Block = 19,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[repr(u8)]
+pub enum Operation {
+    Reserved = 0,
+    Root = 1,
+    Register = 2,
+    Reconfigure = 3,
+    Pulse = 4,
+    Upgrade = 5,
+
+    CreateStream = 128,
+    UpdateStream = 129,
+    DeleteStream = 130,
+    PurgeStream = 131,
+    CreateTopic = 132,
+    UpdateTopic = 133,
+    DeleteTopic = 134,
+    PurgeTopic = 135,
+    CreatePartitions = 136,
+    DeletePartitions = 137,
+    DeleteSegments = 138,
+    CreateConsumerGroup = 139,
+    DeleteConsumerGroup = 140,
+    CreateUser = 141,
+    UpdateUser = 142,
+    DeleteUser = 143,
+    ChangePassword = 144,
+    UpdatePermissions = 145,
+    CreatePersonalAccessToken = 146,
+    DeletePersonalAccessToken = 147,
+}
+
+#[repr(C)]
+#[derive(Debug, Clone, Copy)]
+pub struct GenericHeader {
+    pub checksum: u128,
+    pub checksum_padding: u128,
+    pub checksum_body: u128,
+    pub checksum_body_padding: u128,
+    pub nonce_reserved: u128,
+    pub cluster: u128,

Review Comment:
   Tigerbeetle uses a 128 bit random number: 
[here](https://docs.tigerbeetle.com/operating/deploying/#:~:text=%2D%2Dcluster%20specifies%20a%20globally%20unique%20128%20bit%20cluster%20ID.%20It%20is%20recommended%20to%20use%20a%20random%20number%20for%20a%20cluster%20id%2C%20cluster%20ID%200%20is%20reserved%20for%20testing.)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to