{
    "Function": "receivePayload",
    "File": "contracts/mocks/LZEndpointMock.sol",
    "Parent Contracts": [
        "contracts/OFT/interfaces/ILayerZeroEndpoint.sol",
        "contracts/OFT/interfaces/ILayerZeroUserApplicationConfig.sol"
    ],
    "High-Level Calls": [
        "ILayerZeroReceiver"
    ],
    "Internal Calls": [
        "keccak256(bytes)",
        "keccak256(bytes)",
        "require(bool,string)",
        "receiveNonReentrant"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function receivePayload(uint16 _srcChainId, bytes calldata _path, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload) external override receiveNonReentrant {\n        StoredPayload storage sp = storedPayload[_srcChainId][_path];\n\n        // assert and increment the nonce. no message shuffling\n        require(_nonce == ++inboundNonce[_srcChainId][_path], \"LayerZeroMock: wrong nonce\");\n\n        // queue the following msgs inside of a stack to simulate a successful send on src, but not fully delivered on dst\n        if (sp.payloadHash != bytes32(0)) {\n            QueuedPayload[] storage msgs = msgsToDeliver[_srcChainId][_path];\n            QueuedPayload memory newMsg = QueuedPayload(_dstAddress, _nonce, _payload);\n\n            // warning, might run into gas issues trying to forward through a bunch of queued msgs\n            // shift all the msgs over so we can treat this like a fifo via array.pop()\n            if (msgs.length > 0) {\n                // extend the array\n                msgs.push(newMsg);\n\n                // shift all the indexes up for pop()\n                for (uint i = 0; i < msgs.length - 1; i++) {\n                    msgs[i + 1] = msgs[i];\n                }\n\n                // put the newMsg at the bottom of the stack\n                msgs[0] = newMsg;\n            } else {\n                msgs.push(newMsg);\n            }\n        } else if (nextMsgBlocked) {\n            storedPayload[_srcChainId][_path] = StoredPayload(uint64(_payload.length), _dstAddress, keccak256(_payload));\n            emit PayloadStored(_srcChainId, _path, _dstAddress, _nonce, _payload, bytes(\"\"));\n            // ensure the next msgs that go through are no longer blocked\n            nextMsgBlocked = false;\n        } else {\n            storedMessage = _payload;\n            try ILayerZeroReceiver(_dstAddress).lzReceive{gas: _gasLimit}(_srcChainId, _path, _nonce, _payload) {} catch (bytes memory reason) {\n                storedPayload[_srcChainId][_path] = StoredPayload(uint64(_payload.length), _dstAddress, keccak256(_payload));\n                emit PayloadStored(_srcChainId, _path, _dstAddress, _nonce, _payload, reason);\n                // ensure the next msgs that go through are no longer blocked\n                nextMsgBlocked = false;\n            }\n        }\n    }"
}