10 solidity数组里有100000个人都要参加投票,要给这100000个选民分配权重weght,用for 语句能行吗?

singleLegLength是数组长度。

function votingBegins() public {
    //时间戳,用1970年到现在的秒
    require(admin == msg.sender, "Admin what?");
    willVotingBegin = true;
    endOfVotingTimestamp = block.timestamp + 2592000000; //投票期限一个月
    totalVotingAgreeWeight = 0;
    totalVotingWeight = 0;

    for (uint256 i = 0; i < singleLegLength; i++) {
        voters[singleLeg[i]].weight = users[singleLeg[i]].amount;
        voters[singleLeg[i]].voted = false;
        voters[singleLeg[i]].agreeOrNot = false;
    }
}
请先 登录 后评论

2 个回答

pan
请先 登录 后评论
Tiny熊 - 布道者
  擅长:智能合约,以太坊
请先 登录 后评论