From 6dbe02f24fb9d622856ee7f9a3a8724ad40bd3c0 Mon Sep 17 00:00:00 2001 From: "Denis K." Date: Thu, 20 Feb 2025 18:21:03 +0700 Subject: [PATCH] FIX: try_push error handler, warp on --- frame/rws/src/lib.rs | 17 ++++++++++------- node/service/src/dev.rs | 10 +++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/frame/rws/src/lib.rs b/frame/rws/src/lib.rs index d5866a60..63317778 100644 --- a/frame/rws/src/lib.rs +++ b/frame/rws/src/lib.rs @@ -196,6 +196,8 @@ pub mod pallet { NewSubscription(T::AccountId, Subscription), /// Started new RWS subscription auction. NewAuction(Subscription, T::AuctionIndex), + /// Can't start a new RWS subscription auction. + NewAuctionCreationError(T::AuctionIndex), } #[pallet::storage] @@ -431,14 +433,15 @@ pub mod pallet { let index = Self::auction_next(); >::mutate(|x| *x += 1u8.into()); - // insert auction ledger - >::insert(&index, AuctionLedger::new(kind.clone())); - // insert auction into queue - let _ = >::mutate(|queue| queue.try_push(index.clone())); - - // deposit descriptive event - Self::deposit_event(Event::NewAuction(kind, index)); + if let Ok(_) = >::mutate(|queue| queue.try_push(index.clone())) { + // insert auction ledger + >::insert(&index, AuctionLedger::new(kind.clone())); + // deposit descriptive event + Self::deposit_event(Event::NewAuction(kind, index)); + } else { + Self::deposit_event(Event::NewAuctionCreationError(index)); + }; } /// Rotate current auctions, register subscriptions and queue next. diff --git a/node/service/src/dev.rs b/node/service/src/dev.rs index 0eb7a769..c23eac83 100644 --- a/node/service/src/dev.rs +++ b/node/service/src/dev.rs @@ -285,11 +285,11 @@ where ); net_config.add_notification_protocol(grandpa_protocol_config); - // let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new( - // backend.clone(), - // grandpa_link.shared_authority_set().clone(), - // Vec::default(), - // )); + let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new( + backend.clone(), + grandpa_link.shared_authority_set().clone(), + Vec::default(), + )); let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) = sc_service::build_network(sc_service::BuildNetworkParams {