Skip to content

Commit

Permalink
Refactor rewarders structure
Browse files Browse the repository at this point in the history
  • Loading branch information
HyunggyuJang committed Oct 18, 2022
1 parent bcc6192 commit 8e2dd3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion farming/logics/traits/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct Data {
pub lp_tokens: Vec<AccountId>,

/// Address of each `rewarder` contract in MasterChef.
pub rewarders: Vec<Option<AccountId>>,
pub rewarders: Mapping<u32, AccountId>,

/// Total allocation points. Must be the sum of all allocation points in all pools.
pub total_alloc_point: u32,
Expand Down
7 changes: 5 additions & 2 deletions farming/logics/traits/farming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ pub trait Farming: Storage<Data> + Storage<ownable::Data> + FarmingGetters + Far
.checked_add(alloc_point)
.ok_or(FarmingError::AddOverflow2)?;
self.data::<Data>().lp_tokens.push(lp_token);
self.data::<Data>().rewarders.push(rewarder);
let pool_length = self.pool_length();

if let Some(rewarder_address) = rewarder {
self.data::<Data>()
.rewarders
.insert(&pool_length, &rewarder_address);
}
self.data::<Data>().pool_info.insert(
&pool_length,
&Pool {
Expand Down

0 comments on commit 8e2dd3a

Please sign in to comment.