-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix network in order event #452
base: develop
Are you sure you want to change the base?
Conversation
Now in orers event 38383 the network that comes out is the correct one
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThis pull request integrates asynchronous fetching of the Lightning Network status into multiple order event workflows. A new function Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Order Workflow
participant LN as Lightning Module
participant Tag as order_to_tags Function
Caller->>LN: await get_ln_status()
LN-->>Caller: LnStatus / Error
Caller->>Tag: order_to_tags(order, data, ln_status)
Tag-->>Caller: Generated Tags
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
🔇 Additional comments (8)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@@ -271,6 +271,13 @@ impl LndConnector { | |||
} | |||
} | |||
|
|||
pub async fn get_ln_status() -> Result<LnStatus, MostroError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this function, let's keep using LN_STATUS static
@Catrya as inspiration you could remove all modifications and just add this getter in nip33.rs: use crate::LN_STATUS;
...
pub fn order_to_tags(order: &Order, reputation_data: Option<(f64, i64, i64)>) -> Tags {
let ln_net_string = match LN_STATUS.get() {
Some(status) => status.networks.join(","),
None => "unknown".to_string(),
};
let mut tags: Vec<Tag> = vec![
Tag::custom(
TagKind::Custom(Cow::Borrowed("k")),
vec![order.kind.to_string()],
),
Tag::custom(
TagKind::Custom(Cow::Borrowed("f")),
vec![order.fiat_code.to_string()],
),
Tag::custom(
TagKind::Custom(Cow::Borrowed("s")),
vec![order.status.to_string()],
),
Tag::custom(
TagKind::Custom(Cow::Borrowed("amt")),
vec![order.amount.to_string()],
),
Tag::custom(
TagKind::Custom(Cow::Borrowed("fa")),
create_fiat_amt_array(order),
),
Tag::custom(
TagKind::Custom(Cow::Borrowed("pm")),
vec![order.payment_method.to_string()],
),
Tag::custom(
TagKind::Custom(Cow::Borrowed("premium")),
vec![order.premium.to_string()],
),
Tag::custom(
TagKind::Custom(Cow::Borrowed("network")),
vec![ln_net_string],
),
Tag::custom(
TagKind::Custom(Cow::Borrowed("layer")),
vec!["lightning".to_string()],
),
Tag::custom(
TagKind::Custom(Cow::Borrowed("expiration")),
vec![(order.expires_at + Duration::hours(12).num_seconds()).to_string()],
),
Tag::custom(
TagKind::Custom(Cow::Borrowed("y")),
vec!["mostro".to_string()],
),
Tag::custom(
TagKind::Custom(Cow::Borrowed("z")),
vec!["order".to_string()],
),
];
// Add reputation data if available
if reputation_data.is_some() {
tags.insert(
7,
Tag::custom(
TagKind::Custom(Cow::Borrowed("rating")),
vec![create_rating_tag(reputation_data)],
),
);
}
Tags::new(tags)
} So you have just one central point to touch, I let you the tests! 😄 |
fix #435
Now in order event 38383 the network that comes out is the correct one: mainnet, regtest, etc
Summary by CodeRabbit
New Features
Refactor