Skip to content

Commit 2661cf7

Browse files
committed
simlib: return vec instead of Result in list_nodes
1 parent de92e1f commit 2661cf7

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

simln-lib/src/sim_node.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ pub trait SimNetwork: Send + Sync {
481481
/// Looks up a node in the simulated network and a list of its channel capacities.
482482
fn lookup_node(&self, node: &PublicKey) -> Result<(NodeInfo, Vec<u64>), LightningError>;
483483
/// Lists all nodes in the simulated network.
484-
fn list_nodes(&self) -> Result<Vec<NodeInfo>, LightningError>;
484+
fn list_nodes(&self) -> Vec<NodeInfo>;
485485
}
486486

487487
/// A wrapper struct used to implement the LightningNode trait (can be thought of as "the" lightning node). Passes
@@ -710,7 +710,7 @@ impl<T: SimNetwork> LightningNode for SimNode<'_, T> {
710710
}
711711

712712
async fn get_graph(&mut self) -> Result<Graph, LightningError> {
713-
let nodes = self.network.lock().await.list_nodes()?;
713+
let nodes = self.network.lock().await.list_nodes();
714714

715715
let mut nodes_by_pk = HashMap::new();
716716

@@ -1142,14 +1142,12 @@ impl SimNetwork for SimGraph {
11421142
))
11431143
}
11441144

1145-
fn list_nodes(&self) -> Result<Vec<NodeInfo>, LightningError> {
1146-
let mut nodes = vec![];
1147-
1145+
fn list_nodes(&self) -> Vec<NodeInfo> {
1146+
let mut nodes = Vec::with_capacity(self.nodes.len());
11481147
for node in &self.nodes {
11491148
nodes.push(node_info(*node.0));
11501149
}
1151-
1152-
Ok(nodes)
1150+
nodes
11531151
}
11541152
}
11551153

@@ -1881,7 +1879,7 @@ mod tests {
18811879
);
18821880

18831881
fn lookup_node(&self, node: &PublicKey) -> Result<(NodeInfo, Vec<u64>), LightningError>;
1884-
fn list_nodes(&self) -> Result<Vec<NodeInfo>, LightningError>;
1882+
fn list_nodes(&self) -> Vec<NodeInfo>;
18851883
}
18861884
}
18871885

0 commit comments

Comments
 (0)