Skip to content

Commit

Permalink
chore: fix access levels, add method get_transfer_info
Browse files Browse the repository at this point in the history
  • Loading branch information
k0k0ne committed Oct 11, 2024
1 parent 1b4e999 commit 175b914
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
1 change: 0 additions & 1 deletion lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ use crate::events::bump_transaction::{AnchorDescriptor, BumpTransactionEvent};
use crate::prelude::*;

use core::{cmp, mem};
use std::path::PathBuf;
use crate::io::{self, Error};
use core::ops::Deref;
use crate::sync::{Mutex, LockTestExt};
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/color_ext/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl PaymentHashKey {
}

#[derive(Clone, Debug, Default)]
struct RgbPaymentCache {
pub(crate) struct RgbPaymentCache {
by_proxy_id: HashMap<ProxyIdKey, RgbPaymentInfo>,
by_payment_hash_key: HashMap<PaymentHashKey, RgbPaymentInfo>,
by_payment_hash: HashMap<PaymentHash, RgbPaymentInfo>,
Expand Down Expand Up @@ -151,7 +151,7 @@ impl RgbPaymentCache {
}

#[derive(Clone, Debug, Default)]
struct TransferInfoCache {
pub(crate) struct TransferInfoCache {
by_txid: HashMap<Txid, TransferInfo>,
}

Expand Down Expand Up @@ -192,7 +192,7 @@ impl RgbInfoKey {
}

#[derive(Clone, Debug, Default)]
struct RgbInfoCache {
pub(crate) struct RgbInfoCache {
by_rgb_info_key: HashMap<RgbInfoKey, RgbInfo>,
}

Expand Down Expand Up @@ -232,7 +232,7 @@ impl Write for ConsignmentBinaryData {
pub struct ConsignmentHandle(usize);

#[derive(Clone, Debug, Default)]
struct ConsignmentCache {
pub(crate) struct ConsignmentCache {
by_channel_id: HashMap<ChannelId, ConsignmentHandle>,
by_funding_txid: HashMap<Txid, ConsignmentHandle>,
data_store: HashMap<ConsignmentHandle, ConsignmentBinaryData>,
Expand Down
10 changes: 7 additions & 3 deletions lightning/src/color_ext/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use std::sync::{Arc, Mutex};

use crate::rgb_utils::{RgbInfo, RgbPaymentInfo, TransferInfo};

#[allow(missing_docs)]
pub mod database;

/// Static blinding costant (will be removed in the future)
Expand Down Expand Up @@ -252,7 +253,6 @@ impl ColorSourceImpl {
);
}

// 获取或插入 RgbPaymentInfo
let rgb_payment_info = self
.database
.rgb_payment()
Expand Down Expand Up @@ -639,7 +639,7 @@ impl ColorSourceImpl {
}

/// Update pending RGB channel amount
pub(crate) fn update_rgb_channel_amount_pending(
pub fn update_rgb_channel_amount_pending(
&self, channel_id: &ChannelId, rgb_offered_htlc: u64, rgb_received_htlc: u64,
) {
self.update_rgb_channel_amount_impl(&channel_id, rgb_offered_htlc, rgb_received_htlc, true)
Expand Down Expand Up @@ -701,7 +701,7 @@ impl ColorSourceImpl {
pub fn update_rgb_channel_amount(&self, payment_hash: &PaymentHash, receiver: bool) {
let payment = self.database.rgb_payment().lock().unwrap().get_by_payment_hash_key(
&PaymentHashKey::new(payment_hash.clone(), PaymentDirection::from(receiver)),
);
).cloned();
if payment.is_none() {
return;
}
Expand All @@ -720,4 +720,8 @@ impl ColorSourceImpl {
if receiver { (0, rgb_payment_info.amount) } else { (rgb_payment_info.amount, 0) };
self.update_rgb_channel_amount_impl(&channel_id, offered, received, false);
}

pub fn get_transfer_info(&self, txid: &Txid) -> Option<TransferInfo> {
self.database.transfer_info().lock().unwrap().get_by_txid(txid).cloned()
}
}
1 change: 1 addition & 0 deletions lightning/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,5 @@ mod sync;

pub mod rgb_utils;
/// RGB specific extensions to the lightning library
#[allow(missing_docs)]
pub mod color_ext;
6 changes: 2 additions & 4 deletions lightning/src/rgb_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use std::collections::HashMap;
use std::fs;
use std::path::{Path, PathBuf};
use std::str::FromStr;
/*
/// Static blinding costant (will be removed in the future)
pub const STATIC_BLINDING: u64 = 777;
/// Name of the file containing the bitcoin network
Expand All @@ -44,9 +43,8 @@ pub const INDEXER_URL_FNAME: &str = "indexer_url";
pub const WALLET_FINGERPRINT_FNAME: &str = "wallet_fingerprint";
/// Name of the file containing the wallet account xPub
pub const WALLET_ACCOUNT_XPUB_FNAME: &str = "wallet_account_xpub";
const INBOUND_EXT: &str = "inbound";
const OUTBOUND_EXT: &str = "outbound";
*/
// const INBOUND_EXT: &str = "inbound";
// const OUTBOUND_EXT: &str = "outbound";
/// RGB channel info
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct RgbInfo {
Expand Down

0 comments on commit 175b914

Please sign in to comment.