Skip to content

Instantly share code, notes, and snippets.

@regalfaith
Last active April 3, 2018 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save regalfaith/3e62c20e214bb74c68fae7fd46a6b67d to your computer and use it in GitHub Desktop.
Save regalfaith/3e62c20e214bb74c68fae7fd46a6b67d to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.18;
contract Blacklist {
struct Reporter {
address reporterAddress;
bytes32 latitude;
bytes32 longitude;
bytes32 platform;
}
struct Blacklist {
bytes32 phoneNum;
uint totalCount;
Reporter[] reporters;
}
mapping (bytes32 => Blacklist) private blacklistInfo;
function addList(bytes32 number, bytes32 latitude, bytes32 longitude, bytes32 platform) public {
blacklistInfo[number].phoneNum = number;
blacklistInfo[number].totalCount += 1;
blacklistInfo[number].reporters.push(Reporter(msg.sender, latitude, longitude, platform));
}
function getCount(bytes32 number) view returns (uint)
{
return blacklistInfo[number].totalCount;
}
function getLength(bytes32 number) view returns (uint)
{
return blacklistInfo[number].reporters.length;
}
function getInfo(bytes32 number, uint index) view returns (address reporterAddress, bytes32 latitude, bytes32 longitude, bytes32 platform)
{
return (blacklistInfo[number].reporters[index].reporterAddress,
blacklistInfo[number].reporters[index].latitude,
blacklistInfo[number].reporters[index].longitude,
blacklistInfo[number].reporters[index].platform);
}
function deleteInfo(bytes32 number, uint index)
{
// 해당 인덱스의 정보를 모두 0으로 초기화 하지만 배열 길이가 줄어들지는 않음
delete blacklistInfo[number].reporters[index];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment