Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# direnv related temp files/directories
.direnv
/result*

/tests/nodes/*/fiber/store
/tests/nodes/*/config.yml
/tests/nodes/*/dev.toml
Expand All @@ -13,9 +12,11 @@ tests/nodes/.ports
/*.info
.vscode
/migrate/target
/gui/target
/node_modules
/fiber-js/dist
/crates/fiber-wasm/dist
/crates/fiber-wasm-db-worker/dist
/dump*.txt
package-lock.json

2 changes: 1 addition & 1 deletion crates/fiber-lib/src/fiber/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4851,7 +4851,7 @@ impl ChannelActorState {

// Get the total liquid capacity of the channel, which will exclude the reserved ckb amount.
// This is the capacity used for gossiping channel information.
pub(crate) fn get_liquid_capacity(&self) -> u128 {
pub fn get_liquid_capacity(&self) -> u128 {
self.to_local_amount + self.to_remote_amount
}

Expand Down
4 changes: 2 additions & 2 deletions crates/fiber-lib/src/fiber/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2434,7 +2434,7 @@ pub struct ConnectedPeer {
pub struct PersistentNetworkActorState {
// This map is used to store the public key of the peer.
#[serde_as(as = "Vec<(DisplayFromStr, _)>")]
peer_pubkey_map: HashMap<PeerId, Pubkey>,
pub peer_pubkey_map: HashMap<PeerId, Pubkey>,
// These addresses are saved by the user (e.g. the user sends a ConnectPeer rpc to the node),
// we will then save these addresses to the peer store.
#[serde_as(as = "Vec<(DisplayFromStr, _)>")]
Expand All @@ -2446,7 +2446,7 @@ impl PersistentNetworkActorState {
Default::default()
}

fn get_peer_addresses(&self, peer_id: &PeerId) -> Vec<Multiaddr> {
pub fn get_peer_addresses(&self, peer_id: &PeerId) -> Vec<Multiaddr> {
self.saved_peer_addresses
.get(peer_id)
.cloned()
Expand Down
8 changes: 8 additions & 0 deletions crates/fiber-lib/src/fiber/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@ impl From<Point> for Pubkey {
}
}

impl std::fmt::Display for crate::fiber::types::Pubkey {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
use hex::ToHex;
let bytes = self.serialize();
write!(f, "0x{}", bytes.encode_hex::<String>())
}
}

impl From<tentacle::secio::PublicKey> for Pubkey {
fn from(pk: tentacle::secio::PublicKey) -> Self {
secp256k1::PublicKey::from_slice(pk.inner_ref())
Expand Down
2 changes: 1 addition & 1 deletion crates/fiber-lib/src/store/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod db_migrate;
pub mod migration;
mod schema;
pub mod schema;
pub mod store_impl;
pub use store_impl::Store;
#[cfg(test)]
Expand Down
26 changes: 13 additions & 13 deletions crates/fiber-lib/src/store/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
//! | 224 | Hash256 | ChannelData |
//! +--------------+----------------------+-----------------------------+

pub(crate) const CHANNEL_ACTOR_STATE_PREFIX: u8 = 0;
pub(crate) const PEER_ID_NETWORK_ACTOR_STATE_PREFIX: u8 = 16;
pub(crate) const CKB_INVOICE_PREFIX: u8 = 32;
pub(crate) const PREIMAGE_PREFIX: u8 = 33;
pub(crate) const CKB_INVOICE_STATUS_PREFIX: u8 = 34;
pub(crate) const PEER_ID_CHANNEL_ID_PREFIX: u8 = 64;
pub(crate) const CHANNEL_OUTPOINT_CHANNEL_ID_PREFIX: u8 = 65;
pub(crate) const BROADCAST_MESSAGE_PREFIX: u8 = 96;
pub(crate) const BROADCAST_MESSAGE_TIMESTAMP_PREFIX: u8 = 97;
pub(crate) const PAYMENT_SESSION_PREFIX: u8 = 192;
pub(crate) const PAYMENT_HISTORY_TIMED_RESULT_PREFIX: u8 = 193;
pub(crate) const PAYMENT_CUSTOM_RECORD_PREFIX: u8 = 194;
pub const CHANNEL_ACTOR_STATE_PREFIX: u8 = 0;
pub const PEER_ID_NETWORK_ACTOR_STATE_PREFIX: u8 = 16;
pub const CKB_INVOICE_PREFIX: u8 = 32;
pub const PREIMAGE_PREFIX: u8 = 33;
pub const CKB_INVOICE_STATUS_PREFIX: u8 = 34;
pub const PEER_ID_CHANNEL_ID_PREFIX: u8 = 64;
pub const CHANNEL_OUTPOINT_CHANNEL_ID_PREFIX: u8 = 65;
pub const BROADCAST_MESSAGE_PREFIX: u8 = 96;
pub const BROADCAST_MESSAGE_TIMESTAMP_PREFIX: u8 = 97;
pub const PAYMENT_SESSION_PREFIX: u8 = 192;
pub const PAYMENT_HISTORY_TIMED_RESULT_PREFIX: u8 = 193;
pub const PAYMENT_CUSTOM_RECORD_PREFIX: u8 = 194;
#[cfg(feature = "watchtower")]
pub(crate) const WATCHTOWER_CHANNEL_PREFIX: u8 = 224;
pub const WATCHTOWER_CHANNEL_PREFIX: u8 = 224;
2 changes: 1 addition & 1 deletion crates/fiber-lib/src/store/store_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(crate) fn serialize_to_vec<T: ?Sized + Serialize>(value: &T, field_name: &st
.unwrap_or_else(|e| panic!("serialization of {} failed: {}", field_name, e))
}

pub(crate) fn deserialize_from<'a, T>(slice: &'a [u8], field_name: &str) -> T
pub fn deserialize_from<'a, T>(slice: &'a [u8], field_name: &str) -> T
where
T: serde::Deserialize<'a>,
{
Expand Down
Loading