gottstech / gotts

A blockchain for non-collateralized stable-coins, follow MimbleWimble protocol but with explicit amount.
https://gotts.tech
Apache License 2.0
48 stars 4 forks source link

clean-up some u64 sizes and replace with u32 #14

Closed garyyu closed 4 years ago

garyyu commented 4 years ago

clean-up some u64 sizes and replace with u32 or u8 for those vector length and so on.

  1. CompactBlockBody 3 vector length:
    
    pub struct CompactBlockBody {
    /// List of full outputs - specifically the coinbase output(s)
    pub out_full: Vec<Output>,
    /// List of full kernels - specifically the coinbase kernel(s)
    pub kern_full: Vec<TxKernel>,
    /// List of transaction kernels, excluding those in the full list
    /// (short_ids)
    pub kern_ids: Vec<ShortId>,
    }

2. `MerkleProof` path vector length:
```Rust
pub struct MerkleProof {
    /// The size of the MMR at the time the proof was created.
    pub mmr_size: u64,
    /// The sibling path from the leaf up to the final sibling hashing to the
    /// root.
    pub path: Vec<Hash>,
}
  1. TransactionBody 3 vector length:

    pub struct TransactionBody {
    /// List of inputs by the transaction.
    pub inputs: Vec<InputEx>,
    /// List of outputs the transaction produces.
    pub outputs: Vec<Output>,
    /// List of kernels that make up this transaction (usually a single kernel).
    pub kernels: Vec<TxKernel>,
    }
  2. MsgHeader msg_len. This one we still use u64 in the structure definition but use u32 in the serialization/deserialization. At this moment, I'm not sure whether it's a good idea to directly replace this msg_len with u32 type, I will check it later.

pub struct MsgHeader {
    magic: [u8; 2],
    /// Type of the message.
    pub msg_type: Type,
    /// Total length of the message in bytes.
    pub msg_len: u64,
}