1

Here is my code. I need to have a "checkpoint" object that stores some information including an array of "delegations" which is another object.

struct delegation{
    uint256 percent;
    address delegator;
}

struct checkpoint{
    uint256 blockNumber;
    uint256 balance;
    delegation[] delegationTable;
}

mapping(address => delegation[]) votePower;
mapping(address => uint256) balance;
mapping(address => checkpoint[]) checkpoints;

function _setCheckpoint(address _who) private{
        checkpoints[_who].push(
            checkpoint(
                uint256(block.number),
                balance[_who],
                votePower[_who]                 
            )
        );
}

Solidity seems to have some issues with pushing dynamic arrays around. But I can't find another way for me to store that delegation array that's in votePower inside the checkpoint object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.