Skip to content

Commit

Permalink
do not return Result in ChannelManager constructor
Browse files Browse the repository at this point in the history
* Since it is now pointless.
  • Loading branch information
joemphilips committed Jun 22, 2020
1 parent 7b2577d commit 25d8804
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bindings/src/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub(crate) fn construct_channel_manager(
get_est_sat_per_1000_weight_ptr: Ref<fee_estimator_fn::GetEstSatPer1000WeightPtr>,
cur_block_height: usize,

) -> Result<FFIArcChannelManager, secp256k1::Error> {
) -> FFIArcChannelManager {
let network = ffi_network.to_network();
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
let mut seed: [u8; 32] = unsafe_block!("it points to valid length buffer" => seed.as_ref()).clone().bytes;
Expand Down Expand Up @@ -176,7 +176,7 @@ ffi! {
log_ref,
get_est_sat_per_1000_weight_ptr,
cur_block_height,
)?;
);
unsafe_block!("We know chan_man is not null by wrapper macro. And we know `Out` is writable" => chan_man.init(HandleShared::alloc(chan_man_raw)));
FFIResult::ok()
}
Expand Down
8 changes: 3 additions & 5 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,10 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
/// the ChannelManager as a listener to the BlockNotifier and call the BlockNotifier's
/// `block_(dis)connected` methods, which will notify all registered listeners in one
/// go.
pub fn new(network: Network, fee_est: F, monitor: M, tx_broadcaster: T, logger: L, keys_manager: K, config: UserConfig, current_blockchain_height: usize) -> Result<ChannelManager<ChanSigner, M, T, K, F, L>, secp256k1::Error> {
pub fn new(network: Network, fee_est: F, monitor: M, tx_broadcaster: T, logger: L, keys_manager: K, config: UserConfig, current_blockchain_height: usize) -> ChannelManager<ChanSigner, M, T, K, F, L> {
let secp_ctx = Secp256k1::new();

let res = ChannelManager {
ChannelManager {
default_configuration: config.clone(),
genesis_hash: genesis_block(network).header.bitcoin_hash(),
fee_estimator: fee_est,
Expand Down Expand Up @@ -804,9 +804,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
keys_manager,

logger,
};

Ok(res)
}
}

/// Creates a new outbound channel to the given remote node and with the given value.
Expand Down

0 comments on commit 25d8804

Please sign in to comment.