Skip to content
Snippets Groups Projects
Unverified Commit 7c96caf1 authored by Shaopeng Wang's avatar Shaopeng Wang Committed by GitHub
Browse files

Change Option<bool> storage to Option<()>. (#215)

parent 19689f81
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment