jcc-solidity-utils
Version:
jcc solidity utils
1,141 lines (1,140 loc) • 277 kB
JSON
{
"contractName": "HashList",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.4.24+commit.e67f0147\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/list/HashList.sol\":\"HashList\"},\"evmVersion\":\"byzantium\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/list/HashList.sol\":{\"keccak256\":\"0xf3dbb1450bc3a8e1d0d97d15d105fff11fa689f705416ae5d314ac16e839cead\",\"urls\":[\"bzzr://3e768231f6e9bb4f62bbbe7f83653a3384732d9419a673d5d82708b6b1ec2c18\"]},\"/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x239546071316c89d3bbc9e61b2ccae270a4493bbd2f7c240052f533807d50ab7\",\"urls\":[\"bzzr://267bf48e0a30f7b671aa3c98a6b27ffe7bc64efd6533f49e54188b520baa94c5\"]}},\"version\":1}",
"bytecode": "0x604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f30073000000000000000000000000000000000000000030146080604052600080fd00a165627a7a72305820735cc7feaf7df668d4bff24efd22b0a7451a4521baa4dc7f6832ecc62b729eec0029",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fd00a165627a7a72305820735cc7feaf7df668d4bff24efd22b0a7451a4521baa4dc7f6832ecc62b729eec0029",
"sourceMap": "158:1960:16:-;;132:2:-1;166:7;155:9;146:7;137:37;252:7;246:14;243:1;238:23;232:4;229:33;270:1;265:20;;;;222:63;;265:20;274:9;222:63;;298:9;295:1;288:20;328:4;319:7;311:22;352:7;343;336:24",
"deployedSourceMap": "158:1960:16:-;;;;;;;;",
"source": "pragma solidity >=0.4.24;\n\nimport \"../math/SafeMath.sol\";\n\n/**\n * @dev 交易列表共通,处理交易列表hash数据,只能顺序增加且不重复\n */\nlibrary HashList {\n using SafeMath for uint256;\n\n struct hashMap {\n mapping(bytes32 => uint256) mapList;\n bytes32[] list;\n }\n\n function exist(hashMap storage self, bytes32 _hash)\n internal\n view\n returns (bool)\n {\n if (self.list.length == 0) return false;\n return (self.list[self.mapList[_hash]] == _hash);\n }\n\n /**\n @dev 增加新地址,重复的地址返回失败\n */\n function insert(hashMap storage self, bytes32 _hash) internal returns (bool) {\n if (exist(self, _hash)) {\n return false;\n }\n\n self.mapList[_hash] = self.list.push(_hash).sub(1);\n\n return true;\n }\n\n /**\n @dev 删除地址,相应的下标索引数组自动缩减\n */\n function remove(hashMap storage self, bytes32 _hash) internal returns (bool) {\n if (!exist(self, _hash)) {\n return false;\n }\n\n uint256 row2Del = self.mapList[_hash];\n bytes32 keyToMove = self.list[self.list.length.sub(1)];\n self.list[row2Del] = keyToMove;\n self.mapList[keyToMove] = row2Del;\n self.list.length = self.list.length.sub(1);\n\n return true;\n }\n\n function count(hashMap storage self) internal view returns (uint256) {\n return self.list.length;\n }\n\n function get(hashMap storage self, uint256 index)\n internal\n view\n returns (bytes32)\n {\n require(index < self.list.length, \"index must small than current count\");\n return self.list[index];\n }\n\n /**\n @dev 从指定位置返回多条(不多于count)地址记录,如果不足则空缺\n */\n function getList(\n hashMap storage self,\n uint256 from,\n uint256 _count\n ) internal view returns (bytes32[] memory) {\n uint256 _idx = 0;\n require(_count > 0, \"return number must bigger than 0\");\n bytes32[] memory res = new bytes32[](_count);\n\n for (uint256 i = from; i < self.list.length; i++) {\n if (_idx == _count) {\n break;\n }\n\n res[_idx] = self.list[i];\n _idx = _idx.add(1);\n }\n\n return res;\n }\n}\n",
"sourcePath": "/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/list/HashList.sol",
"ast": {
"absolutePath": "/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/list/HashList.sol",
"exportedSymbols": {
"HashList": [
4016
]
},
"id": 4017,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 3762,
"literals": [
"solidity",
">=",
"0.4",
".24"
],
"nodeType": "PragmaDirective",
"src": "0:25:16"
},
{
"absolutePath": "/Users/chtian/Documents/01_work/01_develope/jcc/jcc-solidity-utils/contracts/math/SafeMath.sol",
"file": "../math/SafeMath.sol",
"id": 3763,
"nodeType": "ImportDirective",
"scope": 4017,
"sourceUnit": 5658,
"src": "27:30:16",
"symbolAliases": [],
"unitAlias": ""
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": "@dev 交易列表共通,处理交易列表hash数据,只能顺序增加且不重复",
"fullyImplemented": true,
"id": 4016,
"linearizedBaseContracts": [
4016
],
"name": "HashList",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 3766,
"libraryName": {
"contractScope": null,
"id": 3764,
"name": "SafeMath",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 5657,
"src": "185:8:16",
"typeDescriptions": {
"typeIdentifier": "t_contract$_SafeMath_$5657",
"typeString": "library SafeMath"
}
},
"nodeType": "UsingForDirective",
"src": "179:27:16",
"typeName": {
"id": 3765,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "198:7:16",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
{
"canonicalName": "HashList.hashMap",
"id": 3774,
"members": [
{
"constant": false,
"id": 3770,
"name": "mapList",
"nodeType": "VariableDeclaration",
"scope": 3774,
"src": "231:35:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$",
"typeString": "mapping(bytes32 => uint256)"
},
"typeName": {
"id": 3769,
"keyType": {
"id": 3767,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "239:7:16",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"nodeType": "Mapping",
"src": "231:27:16",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$",
"typeString": "mapping(bytes32 => uint256)"
},
"valueType": {
"id": 3768,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "250:7:16",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 3773,
"name": "list",
"nodeType": "VariableDeclaration",
"scope": 3774,
"src": "272:14:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$dyn_storage_ptr",
"typeString": "bytes32[]"
},
"typeName": {
"baseType": {
"id": 3771,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "272:7:16",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"id": 3772,
"length": null,
"nodeType": "ArrayTypeName",
"src": "272:9:16",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$dyn_storage_ptr",
"typeString": "bytes32[]"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "hashMap",
"nodeType": "StructDefinition",
"scope": 4016,
"src": "210:81:16",
"visibility": "public"
},
{
"body": {
"id": 3802,
"nodeType": "Block",
"src": "390:104:16",
"statements": [
{
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 3787,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 3783,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3776,
"src": "400:4:16",
"typeDescriptions": {
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap storage pointer"
}
},
"id": 3784,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "list",
"nodeType": "MemberAccess",
"referencedDeclaration": 3773,
"src": "400:9:16",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$dyn_storage",
"typeString": "bytes32[] storage ref"
}
},
"id": 3785,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "length",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "400:16:16",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 3786,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "420:1:16",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "400:21:16",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": null,
"id": 3790,
"nodeType": "IfStatement",
"src": "396:39:16",
"trueBody": {
"expression": {
"argumentTypes": null,
"hexValue": "66616c7365",
"id": 3788,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "bool",
"lValueRequested": false,
"nodeType": "Literal",
"src": "430:5:16",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"value": "false"
},
"functionReturnParameters": 3782,
"id": 3789,
"nodeType": "Return",
"src": "423:12:16"
}
},
{
"expression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"id": 3799,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 3791,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3776,
"src": "449:4:16",
"typeDescriptions": {
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap storage pointer"
}
},
"id": 3792,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "list",
"nodeType": "MemberAccess",
"referencedDeclaration": 3773,
"src": "449:9:16",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$dyn_storage",
"typeString": "bytes32[] storage ref"
}
},
"id": 3797,
"indexExpression": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 3793,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3776,
"src": "459:4:16",
"typeDescriptions": {
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap storage pointer"
}
},
"id": 3794,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "mapList",
"nodeType": "MemberAccess",
"referencedDeclaration": 3770,
"src": "459:12:16",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$",
"typeString": "mapping(bytes32 => uint256)"
}
},
"id": 3796,
"indexExpression": {
"argumentTypes": null,
"id": 3795,
"name": "_hash",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3778,
"src": "472:5:16",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"nodeType": "IndexAccess",
"src": "459:19:16",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"nodeType": "IndexAccess",
"src": "449:30:16",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"id": 3798,
"name": "_hash",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3778,
"src": "483:5:16",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"src": "449:39:16",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
}
],
"id": 3800,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "448:41:16",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"functionReturnParameters": 3782,
"id": 3801,
"nodeType": "Return",
"src": "441:48:16"
}
]
},
"documentation": null,
"id": 3803,
"implemented": true,
"isConstructor": false,
"isDeclaredConst": true,
"modifiers": [],
"name": "exist",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 3779,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 3776,
"name": "self",
"nodeType": "VariableDeclaration",
"scope": 3803,
"src": "310:20:16",
"stateVariable": false,
"storageLocation": "storage",
"typeDescriptions": {
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap"
},
"typeName": {
"contractScope": null,
"id": 3775,
"name": "hashMap",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 3774,
"src": "310:7:16",
"typeDescriptions": {
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 3778,
"name": "_hash",
"nodeType": "VariableDeclaration",
"scope": 3803,
"src": "332:13:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 3777,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "332:7:16",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "309:37:16"
},
"payable": false,
"returnParameters": {
"id": 3782,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 3781,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 3803,
"src": "382:4:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 3780,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "382:4:16",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "381:6:16"
},
"scope": 4016,
"src": "295:199:16",
"stateMutability": "view",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 3837,
"nodeType": "Block",
"src": "640:136:16",
"statements": [
{
"condition": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 3813,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3805,
"src": "656:4:16",
"typeDescriptions": {
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap storage pointer"
}
},
{
"argumentTypes": null,
"id": 3814,
"name": "_hash",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3807,
"src": "662:5:16",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap storage pointer"
},
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
],
"id": 3812,
"name": "exist",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3803,
"src": "650:5:16",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_view$_t_struct$_hashMap_$3774_storage_ptr_$_t_bytes32_$returns$_t_bool_$",
"typeString": "function (struct HashList.hashMap storage pointer,bytes32) view returns (bool)"
}
},
"id": 3815,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "650:18:16",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": null,
"id": 3819,
"nodeType": "IfStatement",
"src": "646:51:16",
"trueBody": {
"id": 3818,
"nodeType": "Block",
"src": "670:27:16",
"statements": [
{
"expression": {
"argumentTypes": null,
"hexValue": "66616c7365",
"id": 3816,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "bool",
"lValueRequested": false,
"nodeType": "Literal",
"src": "685:5:16",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"value": "false"
},
"functionReturnParameters": 3811,
"id": 3817,
"nodeType": "Return",
"src": "678:12:16"
}
]
}
},
{
"expression": {
"argumentTypes": null,
"id": 3833,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"baseExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 3820,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3805,
"src": "703:4:16",
"typeDescriptions": {
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap storage pointer"
}
},
"id": 3823,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "mapList",
"nodeType": "MemberAccess",
"referencedDeclaration": 3770,
"src": "703:12:16",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$",
"typeString": "mapping(bytes32 => uint256)"
}
},
"id": 3824,
"indexExpression": {
"argumentTypes": null,
"id": 3822,
"name": "_hash",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3807,
"src": "716:5:16",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": true,
"nodeType": "IndexAccess",
"src": "703:19:16",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "31",
"id": 3831,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "751:1:16",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
},
"value": "1"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
}
],
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 3828,
"name": "_hash",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3807,
"src": "740:5:16",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
],
"expression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 3825,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3805,
"src": "725:4:16",
"typeDescriptions": {
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap storage pointer"
}
},
"id": 3826,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "list",
"nodeType": "MemberAccess",
"referencedDeclaration": 3773,
"src": "725:9:16",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$dyn_storage",
"typeString": "bytes32[] storage ref"
}
},
"id": 3827,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "push",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "725:14:16",
"typeDescriptions": {
"typeIdentifier": "t_function_arraypush_nonpayable$_t_bytes32_$returns$_t_uint256_$",
"typeString": "function (bytes32) returns (uint256)"
}
},
"id": 3829,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "725:21:16",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 3830,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "sub",
"nodeType": "MemberAccess",
"referencedDeclaration": 5611,
"src": "725:25:16",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_uint256_$_t_uint256_$returns$_t_uint256_$bound_to$_t_uint256_$",
"typeString": "function (uint256,uint256) pure returns (uint256)"
}
},
"id": 3832,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "725:28:16",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "703:50:16",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 3834,
"nodeType": "ExpressionStatement",
"src": "703:50:16"
},
{
"expression": {
"argumentTypes": null,
"hexValue": "74727565",
"id": 3835,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "bool",
"lValueRequested": false,
"nodeType": "Literal",
"src": "767:4:16",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"value": "true"
},
"functionReturnParameters": 3811,
"id": 3836,
"nodeType": "Return",
"src": "760:11:16"
}
]
},
"documentation": "@dev 增加新地址,重复的地址返回失败",
"id": 3838,
"implemented": true,
"isConstructor": false,
"isDeclaredConst": false,
"modifiers": [],
"name": "insert",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 3808,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 3805,
"name": "self",
"nodeType": "VariableDeclaration",
"scope": 3838,
"src": "579:20:16",
"stateVariable": false,
"storageLocation": "storage",
"typeDescriptions": {
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap"
},
"typeName": {
"contractScope": null,
"id": 3804,
"name": "hashMap",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 3774,
"src": "579:7:16",
"typeDescriptions": {
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 3807,
"name": "_hash",
"nodeType": "VariableDeclaration",
"scope": 3838,
"src": "601:13:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 3806,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "601:7:16",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "578:37:16"
},
"payable": false,
"returnParameters": {
"id": 3811,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 3810,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 3838,
"src": "634:4:16",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 3809,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "634:4:16",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "633:6:16"
},
"scope": 4016,
"src": "563:213:16",
"stateMutability": "nonpayable",
"superFunction": null,
"visibility": "internal"
},
{
"body": {
"id": 3906,
"nodeType": "Block",
"src": "931:307:16",
"statements": [
{
"condition": {
"argumentTypes": null,
"id": 3851,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "UnaryOperation",
"operator": "!",
"prefix": true,
"src": "941:19:16",
"subExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 3848,
"name": "self",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3840,
"src": "948:4:16",
"typeDescriptions": {
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap storage pointer"
}
},
{
"argumentTypes": null,
"id": 3849,
"name": "_hash",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3842,
"src": "954:5:16",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_struct$_hashMap_$3774_storage_ptr",
"typeString": "struct HashList.hashMap storage pointer"
},
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
],
"id": 3847,
"name": "exist",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3803,
"src": "942:5:16",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_view$_t_struct$_hashMap_$3774_storage_ptr_$_t_bytes32_$returns$_t_bool_$",
"typeString": "function (struct HashList.hashMap storage pointer,bytes32) view returns (bool)"
}
},
"id": 3850,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "942:18:16",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": null,
"id": 3855,
"nodeType": "IfStatement",
"src": "937:52:16",
"trueBody": {
"id": 3854,
"nodeType": "Block",
"src": "962:27:16",
"statements": [
{
"expression": {
"argumentTypes": null,
"hexValue": "66616c7365",
"id": 3852,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "bool",
"lValueRequested": false,
"nodeType": "Literal",
"src": "977:5:16",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"value": "false"
},
"functionReturnParameters": 3846,
"id": 3853,
"nodeType": "Return",
"src": "970:12:16"
}
]
}
},