mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 21:49:26 +00:00
Ensure the transaction-chaining scheduler doesn't accumulate the same output multiple times
This commit is contained in:
@@ -13,6 +13,7 @@ create_db! {
|
||||
TransactionChainingScheduler {
|
||||
OperatingCosts: (coin: Coin) -> Amount,
|
||||
SerializedOutputs: (key: &[u8], coin: Coin) -> Vec<u8>,
|
||||
AlreadyAccumulatedOutput: (id: &[u8]) -> (),
|
||||
// We should be immediately able to schedule the fulfillment of payments, yet this may not be
|
||||
// possible if we're in the middle of a multisig rotation (as our output set will be split)
|
||||
SerializedQueuedPayments: (key: &[u8], coin: Coin) -> Vec<u8>,
|
||||
@@ -58,6 +59,21 @@ impl<S: ScannerFeed> Db<S> {
|
||||
SerializedOutputs::del(txn, key.to_bytes().as_ref(), coin);
|
||||
}
|
||||
|
||||
pub(crate) fn set_already_accumulated_output(
|
||||
txn: &mut impl DbTxn,
|
||||
output: <OutputFor<S> as ReceivedOutput<KeyFor<S>, AddressFor<S>>>::Id,
|
||||
) {
|
||||
AlreadyAccumulatedOutput::set(txn, output.as_ref(), &());
|
||||
}
|
||||
pub(crate) fn take_if_already_accumulated_output(
|
||||
txn: &mut impl DbTxn,
|
||||
output: <OutputFor<S> as ReceivedOutput<KeyFor<S>, AddressFor<S>>>::Id,
|
||||
) -> bool {
|
||||
let res = AlreadyAccumulatedOutput::get(txn, output.as_ref()).is_some();
|
||||
AlreadyAccumulatedOutput::del(txn, output.as_ref());
|
||||
res
|
||||
}
|
||||
|
||||
pub(crate) fn queued_payments(
|
||||
getter: &impl Get,
|
||||
key: KeyFor<S>,
|
||||
|
||||
Reference in New Issue
Block a user