From 7c96caf1863e5e08e02b274fab7a5db137260a9f Mon Sep 17 00:00:00 2001 From: Shaopeng Wang <spxwang@gmail.com> Date: Mon, 29 Jun 2020 09:35:22 +1200 Subject: [PATCH] Change Option<bool> storage to Option<()>. (#215) --- auction/src/lib.rs | 8 ++++---- auction/src/tests.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/auction/src/lib.rs b/auction/src/lib.rs index de9d6ad..6cd3a7a 100644 --- a/auction/src/lib.rs +++ b/auction/src/lib.rs @@ -37,7 +37,7 @@ decl_storage! { trait Store for Module<T: Trait> as Auction { pub Auctions get(fn auctions): map hasher(twox_64_concat) T::AuctionId => Option<AuctionInfo<T::AccountId, T::Balance, T::BlockNumber>>; pub AuctionsIndex get(fn auctions_index): T::AuctionId; - pub AuctionEndTime get(fn auction_end_time): double_map hasher(twox_64_concat) T::BlockNumber, hasher(twox_64_concat) T::AuctionId => Option<bool>; + pub AuctionEndTime get(fn auction_end_time): double_map hasher(twox_64_concat) T::BlockNumber, hasher(twox_64_concat) T::AuctionId => Option<()>; } } @@ -96,7 +96,7 @@ decl_module! { <AuctionEndTime<T>>::remove(&old_end_block, id); } if let Some(new_end_block) = new_end { - <AuctionEndTime<T>>::insert(&new_end_block, id, true); + <AuctionEndTime<T>>::insert(&new_end_block, id, ()); } auction.end = new_end; }, @@ -150,7 +150,7 @@ impl<T: Trait> Auction<T::AccountId, T::BlockNumber> for Module<T> { <AuctionEndTime<T>>::remove(&old_end, id); } if let Some(new_end) = info.end { - <AuctionEndTime<T>>::insert(&new_end, id, true); + <AuctionEndTime<T>>::insert(&new_end, id, ()); } <Auctions<T>>::insert(id, info); Ok(()) @@ -162,7 +162,7 @@ impl<T: Trait> Auction<T::AccountId, T::BlockNumber> for Module<T> { <AuctionsIndex<T>>::mutate(|n| *n += Self::AuctionId::one()); <Auctions<T>>::insert(auction_id, auction); if let Some(end_block) = end { - <AuctionEndTime<T>>::insert(&end_block, auction_id, true); + <AuctionEndTime<T>>::insert(&end_block, auction_id, ()); } auction_id diff --git a/auction/src/tests.rs b/auction/src/tests.rs index f6546d5..7076dbd 100644 --- a/auction/src/tests.rs +++ b/auction/src/tests.rs @@ -76,7 +76,7 @@ fn remove_auction_should_work() { assert_eq!(AuctionModule::new_auction(10, Some(100)), 0); assert_eq!(AuctionModule::auctions_index(), 1); assert_eq!(AuctionModule::auctions(0).is_some(), true); - assert_eq!(AuctionModule::auction_end_time(100, 0), Some(true)); + assert_eq!(AuctionModule::auction_end_time(100, 0), Some(())); AuctionModule::remove_auction(0); assert_eq!(AuctionModule::auctions(0), None); assert_eq!(AuctionModule::auction_end_time(100, 0), None); -- GitLab