1

I'm looking at this piece of code from Plasma MVP

    function startExit(uint256 utxoPos, bytes txBytes, bytes proof, bytes sigs)
        public
    {
        uint256 blknum = utxoPos / 1000000000;
        uint256 txindex = (utxoPos % 1000000000) / 10000;
        uint256 oindex = utxoPos - blknum * 1000000000 - txindex * 10000; 
        var exitingTx = txBytes.createExitingTx(11, oindex);

        require(msg.sender == exitingTx.exitor);
        bytes32 root = childChain[blknum].root; 
        bytes32 merkleHash = keccak256(keccak256(txBytes), ByteUtils.slice(sigs, 0, 130));
        require(Validate.checkSigs(keccak256(txBytes), root, exitingTx.inputCount, sigs));
        require(merkleHash.checkMembership(txindex, root, proof));
        addExitToQueue(utxoPos, exitingTx.exitor, exitingTx.amount, childChain[blknum].created_at);
}

What is the difference between txindex and oindex? Is it possible to explain in more layman terms? (maybe an illustration or example).

1 Answer 1

1

Integer math, so the division gives the floor. Oindex appears to be the number of utxos since the last 10000. I think it would have been the same result if they would have simply divided by 10000 to begin with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.