Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,7 @@ public void addRewardToken(Address token) {

@SuppressWarnings("unchecked")
public Map<String, BigInteger> loadCurrentSupply(String owner) {
// Bad handling that is only relevant during migration, otherwise it will always succeed on first scenario
try {
return (Map<String, BigInteger>) Context.call(getContractAddress(), "getBalanceAndSupply", getName(), owner);
} catch (Exception e) {
try {
return (Map<String, BigInteger>) Context.call(getContractAddress(), "getBalanceAndSupply", getName(), Address.fromString(owner));
} catch (Exception _e) {
return Map.of("_totalSupply", BigInteger.ZERO,
"_balance", BigInteger.ZERO);
}
}
return (Map<String, BigInteger>) Context.call(getContractAddress(), "getBalanceAndSupply", getName(), owner);
}

public Map<Address, BigInteger> updateSingleUserData(BigInteger currentTime, BalanceData balances, String user, boolean readOnlyContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,20 @@ public BigInteger getBalnHolding(String _holder) {
public Map<String, BigInteger> getRewards(String _holder) {
Map<String, BigInteger> accruedRewards = getHoldings(_holder);
int dataSourcesCount = DataSourceDB.size();
BigInteger currentTime = getTime();

for (int i = 0; i < dataSourcesCount; i++) {
String name = DataSourceDB.names.get(i);
DataSourceImpl dataSource = DataSourceDB.get(name);
BigInteger currentTime = getTime();
BalanceData balances = new BalanceData();
balances.prevWorkingBalance = dataSource.getWorkingBalance(_holder);
if (balances.prevWorkingBalance.compareTo(BigInteger.ZERO) <= 0) {
continue;
}

balances.prevBalance = dataSource.getBalance(_holder);
balances.prevSupply = dataSource.getTotalSupply();
balances.prevWorkingBalance = dataSource.getWorkingBalance(_holder, true);
balances.prevWorkingSupply = dataSource.getWorkingSupply(true);
balances.prevWorkingSupply = dataSource.getWorkingSupply();
Map<Address, BigInteger> sourceRewards = dataSource.updateSingleUserData(currentTime, balances, _holder, true);
for (Map.Entry<Address, BigInteger> entry : sourceRewards.entrySet()) {
accruedRewards.put(entry.getKey().toString(), accruedRewards.get(entry.getKey().toString()).add(entry.getValue()));
Expand Down
Loading