-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node-wasm)!: Align JS api to use camelCase (#383)
- Loading branch information
Showing
5 changed files
with
118 additions
and
15 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
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
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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod libp2p; | ||
pub mod node; |
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,51 @@ | ||
use lumina_node::node::{PeerTrackerInfo, SyncingInfo}; | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen(inspectable)] | ||
#[derive(Debug)] | ||
pub struct PeerTrackerInfoSnapshot { | ||
pub num_connected_peers: u64, | ||
pub num_connected_trusted_peers: u64, | ||
} | ||
|
||
#[wasm_bindgen(inspectable)] | ||
#[derive(Debug, Clone)] | ||
pub struct BlockRange { | ||
pub start: u64, | ||
pub end: u64, | ||
} | ||
|
||
#[wasm_bindgen(inspectable)] | ||
#[derive(Debug)] | ||
pub struct SyncingInfoSnapshot { | ||
#[wasm_bindgen(getter_with_clone)] | ||
pub stored_headers: Vec<BlockRange>, | ||
pub subjective_head: u64, | ||
} | ||
|
||
impl From<PeerTrackerInfo> for PeerTrackerInfoSnapshot { | ||
fn from(value: PeerTrackerInfo) -> Self { | ||
Self { | ||
num_connected_peers: value.num_connected_peers, | ||
num_connected_trusted_peers: value.num_connected_trusted_peers, | ||
} | ||
} | ||
} | ||
|
||
impl From<SyncingInfo> for SyncingInfoSnapshot { | ||
fn from(value: SyncingInfo) -> Self { | ||
let stored_headers = value | ||
.stored_headers | ||
.into_inner() | ||
.iter() | ||
.map(|r| BlockRange { | ||
start: *r.start(), | ||
end: *r.end(), | ||
}) | ||
.collect(); | ||
Self { | ||
stored_headers, | ||
subjective_head: value.subjective_head, | ||
} | ||
} | ||
} |