forked from zingolabs/zaino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//! Zingo-Proxy Block Cache and Mempool State Engine. | ||
|
||
pub mod block; | ||
pub mod transaction; | ||
pub mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! Block fetching and deserialization functionality. | ||
|
||
/// Block header data. | ||
#[derive(Debug)] | ||
pub struct BlockHeaderData { | ||
pub version: i32, | ||
pub hash_prev_block: Vec<u8>, | ||
pub hash_merkle_root: Vec<u8>, | ||
pub hash_final_sapling_root: Vec<u8>, | ||
pub time: u32, | ||
pub n_bits_bytes: Vec<u8>, | ||
pub nonce: Vec<u8>, | ||
pub solution: Vec<u8>, | ||
} | ||
|
||
/// Complete block header. | ||
#[derive(Debug)] | ||
pub struct FullBlockHeader { | ||
pub raw_block_header: BlockHeaderData, | ||
pub cached_hash: Vec<u8>, | ||
} | ||
|
||
/// Zingo-Proxy Block. | ||
#[derive(Debug)] | ||
pub struct FullBlock { | ||
pub hdr: FullBlockHeader, | ||
pub vtx: Vec<super::transaction::FullTransaction>, | ||
pub height: i32, | ||
} | ||
|
||
// impl parse_from_slice for block_header(&[u8]) -> Result<(Self, &[u8]), ParseError> | ||
|
||
// impl parse_from_slice for full_block(&[u8]) -> Result<(Self, &[u8]), ParseError> | ||
|
||
// impl parse_full_block(&[u8]) -> Result<Self, Error> | ||
|
||
// impl to_compact(Self) -> Result<compact_block, Error> | ||
|
||
// impl parse_to_compact(&[u8]) -> Result<compact_block, Error> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
//! Transaction fetching and deserialization functionality. | ||
|
||
/// Transparent input. | ||
#[derive(Debug)] | ||
pub struct TxIn { | ||
pub script_sig: Vec<u8>, | ||
} | ||
|
||
/// Transparent output. | ||
#[derive(Debug)] | ||
pub struct TxOut { | ||
pub value: u64, | ||
} | ||
|
||
/// Sapling input. | ||
#[derive(Debug)] | ||
pub struct Spend { | ||
pub nullifier: Vec<u8>, | ||
} | ||
|
||
/// Sapling output. | ||
#[derive(Debug)] | ||
pub struct Output { | ||
pub cmu: Vec<u8>, | ||
pub ephemeral_key: Vec<u8>, | ||
pub enc_ciphertext: Vec<u8>, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct JoinSplit { | ||
// Define fields based on your needs | ||
} | ||
|
||
/// Orchard actions. | ||
#[derive(Debug)] | ||
pub struct Action { | ||
pub nullifier: Vec<u8>, | ||
pub cmx: Vec<u8>, | ||
pub ephemeral_key: Vec<u8>, | ||
pub enc_ciphertext: Vec<u8>, | ||
} | ||
|
||
/// Raw transactrion. | ||
#[derive(Debug)] | ||
pub struct TransactionData { | ||
pub f_overwintered: bool, | ||
pub version: u32, | ||
pub n_version_group_id: u32, | ||
pub consensus_branch_id: u32, | ||
pub transparent_inputs: Vec<TxIn>, | ||
pub transparent_outputs: Vec<TxOut>, | ||
pub shielded_spends: Vec<Spend>, | ||
pub shielded_outputs: Vec<Output>, | ||
pub join_splits: Vec<JoinSplit>, | ||
pub orchard_actions: Vec<Action>, | ||
} | ||
|
||
/// Zingo-Proxy transaction data. | ||
#[derive(Debug)] | ||
pub struct FullTransaction { | ||
pub raw_transaction: TransactionData, | ||
pub raw_bytes: Vec<u8>, | ||
pub tx_id: Vec<u8>, | ||
} | ||
|
||
// impl parse_from_slice for TxIn(&[u8]) -> Result<(Self, &[u8]), ParseError> | ||
|
||
// impl parse_from_slice for TxOut(&[u8]) -> Result<(Self, &[u8]), ParseError> | ||
|
||
// imple parse_transparent(&[u8]) -> Result<(????, &[u8]), ParseError> | ||
|
||
// impl parse_from_slice for Spend(&[u8]) -> Result<(Self, &[u8]), ParseError> | ||
|
||
// impl parse_from_slice for Output(&[u8]) -> Result<(Self, &[u8]), ParseError> | ||
|
||
// impl parse_from_slice for JoinSplit(&[u8]) -> Result<(Self, &[u8]), ParseError> | ||
|
||
// impl parse_from_slice for Action(&[u8]) -> Result<(Self, &[u8]), ParseError> | ||
|
||
// impl parse_v4(&[u8]) -> Result<(????, &[u8]), ParseError> | ||
|
||
// impl parse_v5(&[u8]) -> Result<(????, &[u8]), ParseError> | ||
|
||
// impl parse_from_slice for transaction(&[u8]) -> Result<(Self, &[u8]), ParseError> | ||
|
||
// impl to_compact(Self) -> Result<compact_transaction, Error> | ||
|
||
// impl parse_to_compact(&[u8]) -> Result<(compact_transaction, &[u8]), Error> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//! Blockcache utility functionality. | ||
|
||
/// Parser Error Type. | ||
#[derive(Debug)] | ||
pub enum ParseError { | ||
Io(std::io::Error), | ||
InvalidData(String), | ||
} | ||
|
||
trait ParseFromSlice { | ||
fn parse_from_slice(data: &[u8]) -> Result<(&[u8], Self), ParseError> | ||
where | ||
Self: Sized; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters