Skip to content

Commit 329a38b

Browse files
committed
add function to fully add an alt block
1 parent d648871 commit 329a38b

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

storage/blockchain/src/ops/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,6 @@ pub mod key_image;
108108
pub mod output;
109109
pub mod property;
110110
pub mod tx;
111+
pub mod alt_block;
111112

112113
mod macros;

storage/blockchain/src/tables.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
//! accessing _all_ tables defined here at once.
1717
1818
//---------------------------------------------------------------------------------------------------- Import
19-
use crate::types::{Amount, AmountIndex, AmountIndices, BlockBlob, BlockHash, BlockHeight, BlockInfo, KeyImage, Output, PreRctOutputId, PrunableBlob, PrunableHash, PrunedBlob, RctOutput, TxBlob, TxHash, TxId, UnlockTime, RawChainId, AltChainInfo, AltBlockHeight, CompactAltBlockInfo, AltTransactionInfo};
19+
use crate::types::{
20+
AltBlockHeight, AltChainInfo, AltTransactionInfo, Amount, AmountIndex, AmountIndices,
21+
BlockBlob, BlockHash, BlockHeight, BlockInfo, CompactAltBlockInfo, KeyImage, Output,
22+
PreRctOutputId, PrunableBlob, PrunableHash, PrunedBlob, RawChainId, RctOutput, TxBlob, TxHash,
23+
TxId, UnlockTime,
24+
};
2025

2126
//---------------------------------------------------------------------------------------------------- Tables
2227
// Notes:

storage/blockchain/src/types.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,14 @@ impl From<RawChain> for Chain {
348348
}
349349
}
350350

351+
impl From<RawChainId> for RawChain {
352+
fn from(value: RawChainId) -> Self {
353+
assert_ne!(value.0, 0);
354+
355+
RawChain(value.0)
356+
}
357+
}
358+
351359
//---------------------------------------------------------------------------------------------------- RawChainId
352360
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)]
353361
#[repr(transparent)]
@@ -371,16 +379,16 @@ impl Key for RawChainId {}
371379
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)]
372380
#[repr(C)]
373381
pub struct AltChainInfo {
374-
parent_chain: RawChain,
375-
common_ancestor_height: u64
382+
pub parent_chain: RawChain,
383+
pub common_ancestor_height: usize,
376384
}
377385

378386
//---------------------------------------------------------------------------------------------------- AltBlockHeight
379387
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)]
380388
#[repr(C)]
381389
pub struct AltBlockHeight {
382-
chain_id: u64,
383-
height: u64,
390+
pub chain_id: RawChainId,
391+
pub height: usize,
384392
}
385393

386394
impl Key for AltBlockHeight {}
@@ -396,15 +404,14 @@ pub struct CompactAltBlockInfo {
396404
/// The block's proof-of-work hash.
397405
pub pow_hash: [u8; 32],
398406
/// The block's height.
399-
pub height: u64,
407+
pub height: usize,
400408
/// The adjusted block size, in bytes.
401409
pub weight: usize,
402410
/// The long term block weight, which is the weight factored in with previous block weights.
403411
pub long_term_weight: usize,
404412
/// The cumulative difficulty of all blocks up until and including this block.
405413
pub cumulative_difficulty_low: u64,
406414
pub cumulative_difficulty_high: u64,
407-
408415
}
409416

410417
//---------------------------------------------------------------------------------------------------- AltTransactionInfo

0 commit comments

Comments
 (0)