Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add StateCommitted event #70

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions contracts/StateReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ pragma solidity ^0.5.11;
import { RLPReader } from "solidity-rlp/contracts/RLPReader.sol";

import { System } from "./System.sol";
import { IStateReceiver } from "./IStateReceiver.sol";

contract StateReceiver is System {
using RLPReader for bytes;
using RLPReader for RLPReader.RLPItem;

uint256 public lastStateId;

function commitState(uint256 syncTime, bytes calldata recordBytes) onlySystem external returns(bool success) {
event StateCommitted(uint256 indexed stateId, bool success);

function commitState(uint256 syncTime, bytes calldata recordBytes) external onlySystem returns(bool success) {
// parse state data
RLPReader.RLPItem[] memory dataList = recordBytes.toRlpItem().toList();
uint256 stateId = dataList[0].toUint();
Expand All @@ -31,12 +32,14 @@ contract StateReceiver is System {
assembly {
success := call(txGas, receiver, 0, add(data, 0x20), mload(data), 0, 0)
}
emit StateCommitted(stateId, success);
}
}

// check if address is contract
function isContract(address _addr) private view returns (bool){
uint32 size;
// solium-disable-next-line security/no-inline-assembly
assembly {
size := extcodesize(_addr)
}
Expand Down
Loading
Loading