Is your feature request related to a problem? Please describe.
We would like to add a contract with the following specifications.
A contract for storing simple log data by external oracles.
The past logs should be 'frozen' after a certain period of time and cannot be changed thereafter.
Describe the solution you'd like
When log data is written, the "number of blocks until freezing (freezingGraceBlockCount)" is simultaneously recorded in the state.
After the "block number at the time the log data was written (createdBlockNumber)" + freezingGraceBlockCount has elapsed, the log data cannot be updated.
Specifications
pragma solidity ^0.8.0;
contract FreezeLog {
event Recorded(address indexed recorder, uint256 index, uint256 _freezingGraceBlockCount);
event Updated(address indexed recorder, uint256 index);
struct Log {
address recorder; // Recorder
string log; // Log text
uint256 createdBlockNumber; // Created block number
uint256 freezingGraceBlockCount; // Freezing grace block count
}
/// Recorder -> Index
mapping (address => uint256) public last_log_index;
/// Recorder > Index -> Log
mapping (address => mapping (uint256 => Log)) public logs;
// [CONSTRUCTOR]
constructor () {}
/// @notice Get last index
/// @param _recorder Recorder
/// @return _index Last index
function lastLogIndex(address _recorder)
public
view
returns (uint256 _index)
{
return _index;
}
/// @notice Record new logs
/// @param _log Log text
/// @param _freezingGraceBlockCount Freezing grace block count
function recordLog(
string memory _log,
uint256 _freezingGraceBlockCount
)
public
{
}
/// @notice Update recorded logs
/// @param _index Index
/// @param _log Log to be updated
function updateLog(
uint256 _index,
string memory _log
)
public
{
}
/// @notice Get log
/// @param _recorder Recorder
/// @param _index Index
function getLog(
address _recorder,
uint256 _index
)
public
view
returns (
uint256 _createdBlockNumber,
uint256 _freezingGraceBlockCount,
string memory _log
)
{
return (_createdBlockNumber, _freezingGraceBlockCount, _log);
}
}
Is your feature request related to a problem? Please describe.
We would like to add a contract with the following specifications.
Describe the solution you'd like
freezingGraceBlockCount
)" is simultaneously recorded in the state.createdBlockNumber
)" +freezingGraceBlockCount
has elapsed, the log data cannot be updated.Specifications