-
Notifications
You must be signed in to change notification settings - Fork 94
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
[r2r] Include maker/taker pubkeys in MM2.db stats_swaps table #1665
Changes from 14 commits
430b2a9
4bf3833
630a9fe
b9a233e
c860d15
12b2b41
0c642a2
6b057da
dc612e9
f39c52d
76d0929
4aa8539
ef088e3
a581dfb
fe856bf
275bf27
012c2a3
526ffa0
12ec822
5f5a3ea
f40f582
0e3f647
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,14 @@ use super::{broadcast_my_swap_status, broadcast_p2p_tx_msg, broadcast_swap_messa | |
check_other_coin_balance_for_swap, detect_secret_hash_algo, dex_fee_amount_from_taker_coin, | ||
get_locked_amount, recv_swap_msg, swap_topic, taker_payment_spend_deadline, tx_helper_topic, | ||
wait_for_maker_payment_conf_until, AtomicSwap, LockedAmount, MySwapInfo, NegotiationDataMsg, | ||
NegotiationDataV2, NegotiationDataV3, RecoveredSwap, RecoveredSwapAction, SavedSwap, SavedSwapIo, | ||
SavedTradeFee, SecretHashAlgo, SwapConfirmationsSettings, SwapError, SwapMsg, SwapTxDataMsg, SwapsContext, | ||
NegotiationDataV2, RecoveredSwap, RecoveredSwapAction, SavedSwap, SavedSwapIo, SavedTradeFee, | ||
SecretHashAlgo, SwapConfirmationsSettings, SwapError, SwapMsg, SwapTxDataMsg, SwapsContext, | ||
TransactionIdentifier, WAIT_CONFIRM_INTERVAL}; | ||
use crate::mm2::lp_dispatcher::{DispatcherContext, LpEvents}; | ||
use crate::mm2::lp_network::subscribe_to_topic; | ||
use crate::mm2::lp_ordermatch::{MakerOrderBuilder, OrderConfirmationsSettings}; | ||
use crate::mm2::lp_price::fetch_swap_coins_price; | ||
use crate::mm2::lp_swap::{broadcast_swap_message, taker_payment_spend_duration}; | ||
use crate::mm2::lp_swap::{broadcast_swap_message, taker_payment_spend_duration, NegotiationDataV3, SwapPubkeys}; | ||
use coins::{CanRefundHtlc, CheckIfMyPaymentSentArgs, FeeApproxStage, FoundSwapTxSpend, MmCoinEnum, | ||
PaymentInstructions, PaymentInstructionsErr, SearchForSwapTxSpendInput, SendMakerPaymentArgs, | ||
SendMakerRefundsPaymentArgs, SendMakerSpendsTakerPaymentArgs, TradeFee, TradePreimageValue, | ||
|
@@ -1875,6 +1875,21 @@ impl MakerSavedSwap { | |
self.taker_coin_usd_price = Some(rates.rel); | ||
} | ||
} | ||
|
||
pub fn swap_pubkeys(&self) -> SwapPubkeys { | ||
shamardy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let mut swap_pubkeys = SwapPubkeys::default(); | ||
|
||
// TODO: Adjust for private coins when/if they are braodcasted | ||
for data in &self.events { | ||
if let MakerSwapEvent::Started(started) = &data.event { | ||
swap_pubkeys.maker = Some(started.my_persistent_pub); | ||
swap_pubkeys.taker = started.maker_coin_htlc_pubkey; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't those 2 pubkeys the maker's? can you please add a unit test to test that the right pubkeys are saved to DB? you should use 3 nodes for the test (taker/maker/seednode) and use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
}; | ||
} | ||
|
||
drop_mutability!(swap_pubkeys); | ||
swap_pubkeys | ||
} | ||
} | ||
|
||
#[allow(clippy::large_enum_variant)] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,14 @@ use super::trade_preimage::{TradePreimageRequest, TradePreimageRpcError, TradePr | |
use super::{broadcast_my_swap_status, broadcast_swap_message, broadcast_swap_message_every, | ||
check_other_coin_balance_for_swap, dex_fee_amount_from_taker_coin, dex_fee_rate, dex_fee_threshold, | ||
get_locked_amount, recv_swap_msg, swap_topic, wait_for_maker_payment_conf_until, AtomicSwap, LockedAmount, | ||
MySwapInfo, NegotiationDataMsg, NegotiationDataV2, NegotiationDataV3, RecoveredSwap, RecoveredSwapAction, | ||
SavedSwap, SavedSwapIo, SavedTradeFee, SwapConfirmationsSettings, SwapError, SwapMsg, SwapTxDataMsg, | ||
SwapsContext, TransactionIdentifier, WAIT_CONFIRM_INTERVAL}; | ||
MySwapInfo, NegotiationDataMsg, NegotiationDataV2, RecoveredSwap, RecoveredSwapAction, SavedSwap, | ||
SavedSwapIo, SavedTradeFee, SwapConfirmationsSettings, SwapError, SwapMsg, SwapTxDataMsg, SwapsContext, | ||
TransactionIdentifier, WAIT_CONFIRM_INTERVAL}; | ||
use crate::mm2::lp_network::subscribe_to_topic; | ||
use crate::mm2::lp_ordermatch::{MatchBy, OrderConfirmationsSettings, TakerAction, TakerOrderBuilder}; | ||
use crate::mm2::lp_price::fetch_swap_coins_price; | ||
use crate::mm2::lp_swap::{broadcast_p2p_tx_msg, tx_helper_topic, wait_for_maker_payment_conf_duration, | ||
TakerSwapWatcherData}; | ||
NegotiationDataV3, SwapPubkeys, TakerSwapWatcherData}; | ||
use coins::{lp_coinfind, CanRefundHtlc, CheckIfMyPaymentSentArgs, FeeApproxStage, FoundSwapTxSpend, MmCoinEnum, | ||
PaymentInstructions, PaymentInstructionsErr, SearchForSwapTxSpendInput, SendSpendPaymentArgs, | ||
SendTakerPaymentArgs, SendTakerRefundsPaymentArgs, SendTakerSpendsMakerPaymentArgs, TradeFee, | ||
|
@@ -301,6 +301,21 @@ impl TakerSavedSwap { | |
self.taker_coin_usd_price = Some(rates.rel); | ||
} | ||
} | ||
|
||
pub fn swap_pubkeys(&self) -> SwapPubkeys { | ||
let mut swap_pubkeys = SwapPubkeys::default(); | ||
|
||
// TODO: Adjust for private coins when/if they are braodcasted | ||
for data in &self.events { | ||
if let TakerSwapEvent::Started(started) = &data.event { | ||
swap_pubkeys.maker = started.maker_coin_htlc_pubkey; | ||
swap_pubkeys.taker = Some(started.my_persistent_pub); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for those 2 pubkeys, aren't they both the taker's? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shamardy this is ready for another round of review! |
||
}; | ||
} | ||
|
||
drop_mutability!(swap_pubkeys); | ||
swap_pubkeys | ||
} | ||
} | ||
|
||
#[allow(clippy::large_enum_variant)] | ||
|
@@ -1171,7 +1186,7 @@ impl TakerSwap { | |
maker_payment_locktime: maker_data.payment_locktime(), | ||
// using default to avoid misuse of this field | ||
// maker_coin_htlc_pubkey and taker_coin_htlc_pubkey must be used instead | ||
maker_pubkey: H264Json::default(), | ||
maker_pubkey: Default::default(), | ||
secret_hash: maker_data.secret_hash().into(), | ||
maker_coin_swap_contract_addr, | ||
taker_coin_swap_contract_addr, | ||
|
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.
Can't just
"ALTER TABLE stats_swaps ADD COLUMN maker_pubkey VARCHAR(255), ADD COLUMN taker_pubkey VARCHAR(255);
work?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.
yes thanks.. it could be this also, but I followed a convention that I already used before https://github.com/KomodoPlatform/atomicDEX-API/blob/54081307cd093cce321939b618a684ad16c915a7/mm2src/mm2_main/src/database/stats_swaps.rs#L49-L52