mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2026-01-18 13:34:22 +01:00
Implement optimistic locking for read-update-write swap operations (#652)
* Implement optimistic locking for read-update-write swap operations * Fail on stale swap update and add tests
This commit is contained in:
@@ -137,6 +137,7 @@ pub(crate) fn new_chain_swap(
|
||||
}
|
||||
}"#
|
||||
.to_string(),
|
||||
version: 0
|
||||
};
|
||||
}
|
||||
match direction {
|
||||
@@ -223,6 +224,7 @@ pub(crate) fn new_chain_swap(
|
||||
}
|
||||
}
|
||||
}"#.to_string(),
|
||||
version: 0,
|
||||
},
|
||||
Direction::Outgoing => ChainSwap {
|
||||
id: generate_random_string(4),
|
||||
@@ -306,6 +308,7 @@ pub(crate) fn new_chain_swap(
|
||||
}
|
||||
}
|
||||
}"#.to_string(),
|
||||
version: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ pub(crate) fn new_send_swap(payment_state: Option<PaymentState>) -> SendSwap {
|
||||
created_at: utils::now(),
|
||||
state: payment_state.unwrap_or(PaymentState::Created),
|
||||
refund_private_key: "945affeef55f12227f1d4a3f80a17062a05b229ddc5a01591eb5ddf882df92e3".to_string(),
|
||||
version: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +141,7 @@ pub(crate) fn new_receive_swap(payment_state: Option<PaymentState>) -> ReceiveSw
|
||||
mrh_tx_id: None,
|
||||
created_at: utils::now(),
|
||||
state: payment_state.unwrap_or(PaymentState::Created),
|
||||
version: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user