Skip to content

Commit

Permalink
map: make the struct public
Browse files Browse the repository at this point in the history
Reported-by: @tareknaser
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Jul 29, 2024
1 parent 34a7387 commit 59917c2
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions gossip_map/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ use crate::gossip_types::{GossipChannel, GossipNode, GossipNodeId, GossipStoredH
/// Gossip map implementation, that allow you to manage the gossip_store
/// written by core lightning.
#[derive(Debug)]
struct GossipMap {
// FIXME: make this optional
path: String,
pub struct GossipMap {
path: Option<String>,
version: u8,
stream: Option<BufReader<File>>,

Check warning on line 32 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

field `stream` is never read

warning: field `stream` is never read --> gossip_map/src/lib.rs:32:5 | 29 | pub struct GossipMap { | --------- field in this struct ... 32 | stream: Option<BufReader<File>>, | ^^^^^^ | = note: `GossipMap` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis = note: `#[warn(dead_code)]` on by default

Check warning on line 32 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (stable)

field `stream` is never read

Check warning on line 32 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (stable)

field `stream` is never read

Check warning on line 32 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

field `stream` is never read

Check warning on line 32 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

field `stream` is never read

Check warning on line 32 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (beta)

field `stream` is never read

Check warning on line 32 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (beta)

field `stream` is never read
nodes: HashMap<GossipNodeId, GossipNode>,
Expand All @@ -41,7 +40,7 @@ impl GossipMap {
pub fn new(version: u8) -> Self {
log::debug!("gossip map version `{version}`");
GossipMap {
path: "".to_owned(),
path: None,
version,
stream: None,
nodes: HashMap::new(),
Expand All @@ -55,7 +54,7 @@ impl GossipMap {
let gossip_store = File::open(file_name)?;
let stream = BufReader::new(gossip_store);
let mut gossip_map = GossipMap {
path: file_name.to_owned(),
path: Some(file_name.to_owned()),
version: 0,
stream: Some(stream),
nodes: HashMap::new(),
Expand All @@ -76,13 +75,21 @@ impl GossipMap {
}

/// add a node announcement message inside the gossip map
fn add_node_announcement(&mut self, node_announce: NodeAnnouncement) {}
fn add_node_announcement(&mut self, node_announce: NodeAnnouncement) {

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

methods `add_node_announcement` and `add_channel_announcement` are never used

warning: methods `add_node_announcement` and `add_channel_announcement` are never used --> gossip_map/src/lib.rs:78:8 | 38 | impl GossipMap { | -------------- methods in this implementation ... 78 | fn add_node_announcement(&mut self, node_announce: NodeAnnouncement) { | ^^^^^^^^^^^^^^^^^^^^^ ... 83 | fn add_channel_announcement(&mut self, channel_announce: ChannelAnnouncement) { | ^^^^^^^^^^^^^^^^^^^^^^^^

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `node_announce`

warning: unused variable: `node_announce` --> gossip_map/src/lib.rs:78:41 | 78 | fn add_node_announcement(&mut self, node_announce: NodeAnnouncement) { | ^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_node_announce` | = note: `#[warn(unused_variables)]` on by default

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (stable)

unused variable: `node_announce`

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (stable)

methods `add_node_announcement` and `add_channel_announcement` are never used

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (stable)

unused variable: `node_announce`

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (stable)

methods `add_node_announcement` and `add_channel_announcement` are never used

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

unused variable: `node_announce`

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

methods `add_node_announcement` and `add_channel_announcement` are never used

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

unused variable: `node_announce`

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

methods `add_node_announcement` and `add_channel_announcement` are never used

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (beta)

unused variable: `node_announce`

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (beta)

methods `add_node_announcement` and `add_channel_announcement` are never used

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (beta)

unused variable: `node_announce`

Check warning on line 78 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (beta)

methods `add_node_announcement` and `add_channel_announcement` are never used
unimplemented!()
}

/// add a channel announcement message inside the gossip map.
fn add_channel_announcement(&mut self, channel_announce: ChannelAnnouncement) {}
fn add_channel_announcement(&mut self, channel_announce: ChannelAnnouncement) {

Check warning on line 83 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `channel_announce`

warning: unused variable: `channel_announce` --> gossip_map/src/lib.rs:83:44 | 83 | fn add_channel_announcement(&mut self, channel_announce: ChannelAnnouncement) { | ^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_channel_announce`

Check warning on line 83 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (stable)

unused variable: `channel_announce`

Check warning on line 83 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (stable)

unused variable: `channel_announce`

Check warning on line 83 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

unused variable: `channel_announce`

Check warning on line 83 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

unused variable: `channel_announce`

Check warning on line 83 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (beta)

unused variable: `channel_announce`

Check warning on line 83 in gossip_map/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (beta)

unused variable: `channel_announce`
unimplemented!()
}

fn refresh(&mut self) -> anyhow::Result<()> {
let gossip_store = File::open(self.path.clone())?;
let gossip_store = File::open(
self.path
.as_ref()
.ok_or(anyhow::anyhow!("Gossip map not found"))?,
)?;
let mut stream = BufReader::new(gossip_store);

let version = u8::from_wire(&mut stream)? as u16;
Expand Down

0 comments on commit 59917c2

Please sign in to comment.