Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Delete the staled order (#1407)
Browse files Browse the repository at this point in the history
Co-authored-by: Xavier Lau <[email protected]>
  • Loading branch information
boundless-forest and AurevoirXavier authored Aug 19, 2022
1 parent 02b55ff commit 33c4750
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
24 changes: 22 additions & 2 deletions node/runtime/pangolin/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
}

fn migrate() -> Weight {
0
// RuntimeBlockWeights::get().max_block
// --- paritytech ---
use frame_support::{migration::storage_key_iter, Blake2_128Concat};
// --- darwinia-network ---
use bp_messages::{LaneId, MessageNonce};
use pallet_fee_market::{types::Order, Orders};

let module: &[u8] = b"PangoroFeeMarket";
let item: &[u8] = b"Orders";
for ((lane_id, nonce), order) in storage_key_iter::<
(LaneId, MessageNonce),
Order<AccountId, BlockNumber, Balance>,
Blake2_128Concat,
>(module, item)
.drain()
{
if lane_id != [0, 0, 0, 0] || lane_id != [0, 0, 0, 1] {
Orders::<Runtime, WithPangoroFeeMarket>::insert((lane_id, nonce), order);
}
}

// 0
RuntimeBlockWeights::get().max_block
}
24 changes: 22 additions & 2 deletions node/runtime/pangoro/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
}

fn migrate() -> Weight {
0
// RuntimeBlockWeights::get().max_block
// --- paritytech ---
use frame_support::{migration::storage_key_iter, Blake2_128Concat};
// --- darwinia-network ---
use bp_messages::{LaneId, MessageNonce};
use pallet_fee_market::{types::Order, Orders};

let module: &[u8] = b"PangolinFeeMarket";
let item: &[u8] = b"Orders";
for ((lane_id, nonce), order) in storage_key_iter::<
(LaneId, MessageNonce),
Order<AccountId, BlockNumber, Balance>,
Blake2_128Concat,
>(module, item)
.drain()
{
if lane_id != [0, 0, 0, 0] || lane_id != [0, 0, 0, 1] {
Orders::<Runtime, WithPangolinFeeMarket>::insert((lane_id, nonce), order);
}
}

// 0
RuntimeBlockWeights::get().max_block
}

0 comments on commit 33c4750

Please sign in to comment.