mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-07-25 23:23:11 +00:00
use own type MantleMsgId
This commit is contained in:
@@ -17,6 +17,5 @@ log.workspace = true
|
||||
hex.workspace = true
|
||||
borsh.workspace = true
|
||||
base64.workspace = true
|
||||
logos-blockchain-core.workspace = true
|
||||
url.workspace = true
|
||||
logos-blockchain-common-http-client.workspace = true
|
||||
|
||||
+3
-23
@@ -1,10 +1,10 @@
|
||||
use borsh::{BorshDeserialize, BorshSerialize};
|
||||
use logos_blockchain_core::mantle::ops::channel::MsgId;
|
||||
use sha2::{Digest, Sha256, digest::FixedOutput};
|
||||
|
||||
use crate::transaction::EncodedTransaction;
|
||||
|
||||
pub type HashType = [u8; 32];
|
||||
pub type MantleMsgId = [u8; 32];
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
/// Our own hasher.
|
||||
@@ -50,11 +50,7 @@ pub struct Block {
|
||||
pub header: BlockHeader,
|
||||
pub body: BlockBody,
|
||||
pub bedrock_status: BedrockStatus,
|
||||
#[borsh(
|
||||
serialize_with = "borsh_msg_id::serialize",
|
||||
deserialize_with = "borsh_msg_id::deserialize"
|
||||
)]
|
||||
pub bedrock_parent_id: MsgId,
|
||||
pub bedrock_parent_id: MantleMsgId,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
|
||||
@@ -69,7 +65,7 @@ impl HashableBlockData {
|
||||
pub fn into_pending_block(
|
||||
self,
|
||||
signing_key: &nssa::PrivateKey,
|
||||
bedrock_parent_id: MsgId,
|
||||
bedrock_parent_id: MantleMsgId,
|
||||
) -> Block {
|
||||
let data_bytes = borsh::to_vec(&self).unwrap();
|
||||
let signature = nssa::Signature::new(signing_key, &data_bytes);
|
||||
@@ -106,22 +102,6 @@ impl From<Block> for HashableBlockData {
|
||||
}
|
||||
}
|
||||
|
||||
mod borsh_msg_id {
|
||||
use std::io::{Read, Write};
|
||||
|
||||
use logos_blockchain_core::mantle::ops::channel::MsgId;
|
||||
|
||||
pub fn serialize<W: Write>(v: &MsgId, w: &mut W) -> std::io::Result<()> {
|
||||
w.write_all(v.as_ref())
|
||||
}
|
||||
|
||||
pub fn deserialize<R: Read>(r: &mut R) -> std::io::Result<MsgId> {
|
||||
let mut buf = [0u8; 32];
|
||||
r.read_exact(&mut buf)?;
|
||||
Ok(MsgId::from(buf))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{block::HashableBlockData, test_utils};
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use logos_blockchain_core::mantle::ops::channel::MsgId;
|
||||
|
||||
use crate::{
|
||||
block::{Block, HashableBlockData},
|
||||
transaction::{EncodedTransaction, NSSATransaction},
|
||||
@@ -32,7 +30,7 @@ pub fn produce_dummy_block(
|
||||
transactions,
|
||||
};
|
||||
|
||||
block_data.into_pending_block(&sequencer_sign_key_for_testing(), MsgId::from([0; 32]))
|
||||
block_data.into_pending_block(&sequencer_sign_key_for_testing(), [0; 32])
|
||||
}
|
||||
|
||||
pub fn produce_dummy_empty_transaction() -> EncodedTransaction {
|
||||
|
||||
Reference in New Issue
Block a user