Changeset View
Changeset View
Standalone View
Standalone View
chronik/chronik-bridge/src/ffi.rs
| Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | mod ffi_inner { | ||||
| /// Wrapper struct for a raw block header. | /// Wrapper struct for a raw block header. | ||||
| #[derive(Clone, Debug, Eq, PartialEq)] | #[derive(Clone, Debug, Eq, PartialEq)] | ||||
| pub struct RawBlockHeader { | pub struct RawBlockHeader { | ||||
| /// Raw block header | /// Raw block header | ||||
| pub data: [u8; 80], | pub data: [u8; 80], | ||||
| } | } | ||||
| /// Wrapper struct for a raw block hash. | |||||
| #[derive(Clone, Debug, Eq, PartialEq)] | |||||
| pub struct RawBlockHash { | |||||
| /// Raw block hash | |||||
| pub data: [u8; 32], | |||||
| } | |||||
| #[allow(missing_debug_implementations)] | #[allow(missing_debug_implementations)] | ||||
| unsafe extern "C++" { | unsafe extern "C++" { | ||||
| include!("blockindex.h"); | include!("blockindex.h"); | ||||
| include!("chronik-cpp/chronik_bridge.h"); | include!("chronik-cpp/chronik_bridge.h"); | ||||
| include!("coins.h"); | include!("coins.h"); | ||||
| include!("node/context.h"); | include!("node/context.h"); | ||||
| include!("primitives/block.h"); | include!("primitives/block.h"); | ||||
| include!("primitives/transaction.h"); | include!("primitives/transaction.h"); | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | unsafe extern "C++" { | ||||
| /// Get a range of consecutive block headers. | /// Get a range of consecutive block headers. | ||||
| fn get_block_headers_by_range( | fn get_block_headers_by_range( | ||||
| self: &ChronikBridge, | self: &ChronikBridge, | ||||
| start: i32, | start: i32, | ||||
| end: i32, | end: i32, | ||||
| ) -> Result<Vec<RawBlockHeader>>; | ) -> Result<Vec<RawBlockHeader>>; | ||||
| /// Get a range of consecutive block hashes. | |||||
| fn get_block_hashes_by_range( | |||||
| self: &ChronikBridge, | |||||
| start: i32, | |||||
| end: i32, | |||||
| ) -> Result<Vec<RawBlockHash>>; | |||||
| /// Load the CBlock data of this CBlockIndex from the disk | /// Load the CBlock data of this CBlockIndex from the disk | ||||
| fn load_block( | fn load_block( | ||||
| self: &ChronikBridge, | self: &ChronikBridge, | ||||
| block_index: &CBlockIndex, | block_index: &CBlockIndex, | ||||
| ) -> Result<UniquePtr<CBlock>>; | ) -> Result<UniquePtr<CBlock>>; | ||||
| /// Load the CBlockUndo data of this CBlockIndex from the disk undo data | /// Load the CBlockUndo data of this CBlockIndex from the disk undo data | ||||
| fn load_block_undo( | fn load_block_undo( | ||||
| ▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines | |||||