问题描述
我不知道如何用两个键来获取数据。一键是“地址”,第二键是“ IsCollect”
我的映射:
mapping(address => Player) public users;
结构表:
struct Deposit {
uint256 depositTime;
uint256 amount;
bool IsCollect;
}
推送:
users[addr].deposits.push(Deposit(Now,amount,false);
检索:
function getPlayerDepositHistory(address addr) public view returns (uint256[] memory,uint256[] memory,bool[] memory) {
DepositHistory[] memory invests = users[addr].deposithistory;
uint256[] memory baseTimes = new uint256[](invests.length);
uint256[] memory values = new uint256[](invests.length);
bool[] memory IsCollect = new bool[](invests.length);
uint256 i = 0;
uint256 timeSpent = 0;
while (i < invests.length){
DepositHistory memory invest = invests[i];
// if (invest.IsCollect=false)
// {
if (invest.lastDepositTime < invest.depositTime.add(PERIOD[0])){
uint256 remainedTime = PERIOD[0].sub(invest.lastDepositTime.sub(invest.depositTime));
if (remainedTime > 0){
timeSpent=Now.sub(invest.lastDepositTime);
if (remainedTime <= timeSpent){
timeSpent = remainedTime;
}
}
baseTimes[i] = invest.depositTime;
values[i] = invest.amount;
IsCollect[i] = invest.IsCollect;
}i++;
// }
}
return (baseTimes,values,IsCollect);
}
我需要第二个键IsCollect = true。如果为true,则只需要显示True
我尝试使用:if(invest.IsCollect == false){
}
如果使用IsCollect(如果不存在),我得到的任何结果: org.tron.core.vm.program.Program $ OutOfTimeException类:'DUP2'操作执行的cpu超时
如果存在,我说对了,如果更新不显示,则从不显示行,并且总是得到: org.tron.core.vm.program.Program $ OutOfTimeException类:'DUP2'操作执行的cpu超时
它不起作用。
感谢帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)