@netvote/elections-solidity
Version:
Elections Contracts
1,144 lines (1,143 loc) • 131 kB
JSON
{
"contractName": "UtilizationTracker",
"abi": [
{
"constant": false,
"inputs": [
{
"name": "addr",
"type": "address"
}
],
"name": "removeAdmin",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "addr",
"type": "address"
}
],
"name": "isAdmin",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "gran",
"type": "uint256"
}
],
"name": "setGranularity",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "removeSelf",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint256"
}
],
"name": "windows",
"outputs": [
{
"name": "windowStart",
"type": "uint256"
},
{
"name": "utilization",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "addr",
"type": "address"
}
],
"name": "addAdmin",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "horizon",
"type": "uint256"
}
],
"name": "getWindowCountSince",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "owner",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "horizon",
"type": "uint256"
}
],
"name": "getUtilizationSince",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
}
],
"bytecode": "0x6060604052610e10600355341561001557600080fd5b60008054600160a060020a03191633600160a060020a03161790556002805460018101610042838261007f565b91600052602060002090600202016000604080519081016040524281526000602082015291905081518155602082015181600101555050506100d7565b8154818355818115116100ab576002028160020283600052602060002091820191016100ab91906100b0565b505050565b6100d491905b808211156100d057600080825560018201556002016100b6565b5090565b90565b610527806100e66000396000f3006060604052600436106100a35763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631785f53c81146100a857806324d7806c146100c95780633b5fce92146100fc5780635e898dac14610112578063637e7006146101255780637048027514610153578063801ae77b146101725780638da5cb5b1461019a5780639b7de2a5146101c9578063f2fde38b146101df575b600080fd5b34156100b357600080fd5b6100c7600160a060020a03600435166101fe565b005b34156100d457600080fd5b6100e8600160a060020a036004351661023a565b604051901515815260200160405180910390f35b341561010757600080fd5b6100c7600435610289565b341561011d57600080fd5b6100c76102a2565b341561013057600080fd5b61013b6004356102d8565b60405191825260208201526040908101905180910390f35b341561015e57600080fd5b6100c7600160a060020a0360043516610304565b341561017d57600080fd5b610188600435610346565b60405190815260200160405180910390f35b34156101a557600080fd5b6101ad6103b4565b604051600160a060020a03909116815260200160405180910390f35b34156101d457600080fd5b6101886004356103c3565b34156101ea57600080fd5b6100c7600160a060020a036004351661044a565b60005433600160a060020a0390811691161461021957600080fd5b600160a060020a03166000908152600160205260409020805460ff19169055565b6000600160a060020a038216158015906102835750600054600160a060020a03838116911614806102835750600160a060020a03821660009081526001602052604090205460ff165b92915050565b6102923361023a565b151561029d57600080fd5b600355565b6102ab3361023a565b15156102b657600080fd5b600160a060020a0333166000908152600160205260409020805460ff19169055565b60028054829081106102e657fe5b60009182526020909120600290910201805460019091015490915082565b60005433600160a060020a0390811691161461031f57600080fd5b600160a060020a03166000908152600160208190526040909120805460ff19169091179055565b6002546000908190815b60008211156103ab576001820390508460028281548110151561036f57fe5b906000526020600020906002020160000154101561038c576103ab565b61039d83600163ffffffff6104e516565b925060001990910190610350565b50909392505050565b600054600160a060020a031681565b6002546000908190815b60008211156103ab57600182039050846002828154811015156103ec57fe5b9060005260206000209060020201600001541015610409576103ab565b61043c60028281548110151561041b57fe5b906000526020600020906002020160010154846104e590919063ffffffff16565b9250600019909101906103cd565b60005433600160a060020a0390811691161461046557600080fd5b600160a060020a038116151561047a57600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000828201838110156104f457fe5b93925050505600a165627a7a72305820209b785aecb7e2741fd94526e910c3995ce773181e7148903c3d355f5d08ab110029",
"deployedBytecode": "0x6060604052600436106100a35763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631785f53c81146100a857806324d7806c146100c95780633b5fce92146100fc5780635e898dac14610112578063637e7006146101255780637048027514610153578063801ae77b146101725780638da5cb5b1461019a5780639b7de2a5146101c9578063f2fde38b146101df575b600080fd5b34156100b357600080fd5b6100c7600160a060020a03600435166101fe565b005b34156100d457600080fd5b6100e8600160a060020a036004351661023a565b604051901515815260200160405180910390f35b341561010757600080fd5b6100c7600435610289565b341561011d57600080fd5b6100c76102a2565b341561013057600080fd5b61013b6004356102d8565b60405191825260208201526040908101905180910390f35b341561015e57600080fd5b6100c7600160a060020a0360043516610304565b341561017d57600080fd5b610188600435610346565b60405190815260200160405180910390f35b34156101a557600080fd5b6101ad6103b4565b604051600160a060020a03909116815260200160405180910390f35b34156101d457600080fd5b6101886004356103c3565b34156101ea57600080fd5b6100c7600160a060020a036004351661044a565b60005433600160a060020a0390811691161461021957600080fd5b600160a060020a03166000908152600160205260409020805460ff19169055565b6000600160a060020a038216158015906102835750600054600160a060020a03838116911614806102835750600160a060020a03821660009081526001602052604090205460ff165b92915050565b6102923361023a565b151561029d57600080fd5b600355565b6102ab3361023a565b15156102b657600080fd5b600160a060020a0333166000908152600160205260409020805460ff19169055565b60028054829081106102e657fe5b60009182526020909120600290910201805460019091015490915082565b60005433600160a060020a0390811691161461031f57600080fd5b600160a060020a03166000908152600160208190526040909120805460ff19169091179055565b6002546000908190815b60008211156103ab576001820390508460028281548110151561036f57fe5b906000526020600020906002020160000154101561038c576103ab565b61039d83600163ffffffff6104e516565b925060001990910190610350565b50909392505050565b600054600160a060020a031681565b6002546000908190815b60008211156103ab57600182039050846002828154811015156103ec57fe5b9060005260206000209060020201600001541015610409576103ab565b61043c60028281548110151561041b57fe5b906000526020600020906002020160010154846104e590919063ffffffff16565b9250600019909101906103cd565b60005433600160a060020a0390811691161461046557600080fd5b600160a060020a038116151561047a57600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000828201838110156104f457fe5b93925050505600a165627a7a72305820209b785aecb7e2741fd94526e910c3995ce773181e7148903c3d355f5d08ab110029",
"sourceMap": "984:1503:17:-;;;1117:7;1098:26;;1218:116;;;;;;;;494:5:21;:18;;-1:-1:-1;;;;;;494:18:21;502:10;-1:-1:-1;;;;;494:18:21;;;;1265:7:17;:62;;-1:-1:-1;1265:62:17;;;:7;:62;;:::i;:::-;;;;;;;;;;;;1278:48;;;;;;;;1304:3;1278:48;;1322:1;1278:48;;;;;1265:62;-1:-1:-1;1278:48:17;1265:62;;;;;;;;;;;;;;984:1503;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;",
"deployedSourceMap": "984:1503:17:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1460:95:0;;;;;;;;;;-1:-1:-1;;;;;1460:95:0;;;;;;;1212:145;;;;;;;;;;-1:-1:-1;;;;;1212:145:0;;;;;;;;;;;;;;;;;;;;;;1340:83:17;;;;;;;;;;;;;;1561:84:0;;;;;;;;;;;;1064:28:17;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1363:91:0;;;;;;;;;;-1:-1:-1;;;;;1363:91:0;;;;;1429:351:17;;;;;;;;;;;;;;;;;;;;;;;;;;;;;238:20:21;;;;;;;;;;;;;;;-1:-1:-1;;;;;238:20:21;;;;;;;;;;;;;;1786:370:17;;;;;;;;;;;;;;827:169:21;;;;;;;;;;-1:-1:-1;;;;;827:169:21;;;;;1460:95:0;647:5:21;;633:10;-1:-1:-1;;;;;633:19:21;;;647:5;;633:19;625:28;;;;;;-1:-1:-1;;;;;1522:18:0;1543:5;1522:18;;;:12;:18;;;;;:26;;-1:-1:-1;;1522:26:0;;;1460:95::o;1212:145::-;1268:4;-1:-1:-1;;;;;1291:18:0;;;;;;:59;;-1:-1:-1;1322:5:0;;-1:-1:-1;;;;;1314:13:0;;;1322:5;;1314:13;;:35;;-1:-1:-1;;;;;;1331:18:0;;;;;;:12;:18;;;;;;;;1314:35;1284:66;1212:145;-1:-1:-1;;1212:145:0:o;1340:83:17:-;1168:19:0;1176:10;1168:7;:19::i;:::-;1160:28;;;;;;;;1398:11:17;:18;1340:83::o;1561:84:0:-;1168:19;1176:10;1168:7;:19::i;:::-;1160:28;;;;;;;;-1:-1:-1;;;;;1619:10:0;1606:24;1633:5;1606:24;;;:12;:24;;;;;:32;;-1:-1:-1;;1606:32:0;;;1561:84::o;1064:28:17:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1064:28:17;:::o;1363:91:0:-;647:5:21;;633:10;-1:-1:-1;;;;;633:19:21;;;647:5;;633:19;625:28;;;;;;-1:-1:-1;;;;;1422:18:0;;;;;1443:4;1422:18;;;;;;;;:25;;-1:-1:-1;;1422:25:0;;;;;;1363:91::o;1429:351:17:-;1560:7;:14;1500:7;;;;;1546:206;1580:1;1576;:5;1546:206;;;1615:1;1613;:3;1602:14;;1661:7;1634;1642:3;1634:12;;;;;;;;;;;;;;;;;;;;:24;;;:34;1630:78;;;1688:5;;1630:78;1729:12;:5;1739:1;1729:12;:9;:12;:::i;:::-;1721:20;-1:-1:-1;;;1583:3:17;;;;1546:206;;;-1:-1:-1;1768:5:17;;1429:351;-1:-1:-1;;;1429:351:17:o;238:20:21:-;;;-1:-1:-1;;;;;238:20:21;;:::o;1786:370:17:-;1916:7;:14;1857:7;;;;;1902:227;1936:1;1932;:5;1902:227;;;1971:1;1969;:3;1958:14;;2017:7;1990;1998:3;1990:12;;;;;;;;;;;;;;;;;;;;:24;;;:34;1986:78;;;2044:5;;1986:78;2084:34;2093:7;2101:3;2093:12;;;;;;;;;;;;;;;;;;;;:24;;;2084:4;:8;;:34;;;;:::i;:::-;2077:41;-1:-1:-1;;;1939:3:17;;;;1902:227;;827:169:21;647:5;;633:10;-1:-1:-1;;;;;633:19:21;;;647:5;;633:19;625:28;;;;;;-1:-1:-1;;;;;903:22:21;;;;895:31;;;;;;953:5;;-1:-1:-1;;;;;932:37:21;;;;953:5;932:37;;;;;;;;;;975:5;:16;;-1:-1:-1;;975:16:21;-1:-1:-1;;;;;975:16:21;;;;;;;;;;827:169::o;680:133:20:-;742:7;769:5;;;787:6;;;;780:14;;;;807:1;680:133;-1:-1:-1;;;680:133:20:o",
"source": "// ------------------------------------------------------------------------------\n// This file is part of netvote.\n//\n// netvote is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// netvote is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with solidity. If not, see <http://www.gnu.org/licenses/>\n//\n// (c) 2017 netvote contributors.\n//------------------------------------------------------------------------------\n\npragma solidity ^0.4.18;\n\nimport \"../auth/Adminable.sol\";\nimport \"zeppelin-solidity/contracts/math/SafeMath.sol\";\n\n\ncontract UtilizationTracker is Adminable {\n using SafeMath for uint256;\n\n UsageWindow[] public windows;\n uint granularity = 1 hours;\n\n struct UsageWindow {\n uint windowStart;\n uint256 utilization;\n }\n\n function UtilizationTracker() public {\n windows.push(UsageWindow({windowStart: now, utilization: 0 }));\n }\n\n function setGranularity(uint gran) public admin {\n granularity = gran;\n }\n\n function getWindowCountSince(uint256 horizon) public constant returns (uint256) {\n uint256 count = 0;\n for (uint i = windows.length; i > 0; i--) {\n uint idx = i-1;\n if (windows[idx].windowStart < horizon) {\n break;\n }\n count = count.add(1);\n }\n return count;\n }\n\n function getUtilizationSince(uint256 horizon) public constant returns (uint256) {\n uint256 util = 0;\n for (uint i = windows.length; i > 0; i--) {\n uint idx = i-1;\n if (windows[idx].windowStart < horizon) {\n break;\n }\n util = util.add(windows[idx].utilization);\n }\n return util;\n }\n\n function incrementUtilization() internal {\n uint idx = windows.length-1;\n if (windows[idx].windowStart < (now - (granularity))) {\n windows.push(UsageWindow({windowStart: now, utilization: 1}));\n } else {\n windows[idx].utilization = windows[idx].utilization.add(1);\n }\n }\n}\n",
"sourcePath": "/Users/slanders/netvote/elections-solidity/contracts/stats/UtilizationTracker.sol",
"ast": {
"attributes": {
"absolutePath": "/Users/slanders/netvote/elections-solidity/contracts/stats/UtilizationTracker.sol",
"exportedSymbols": {
"UtilizationTracker": [
2390
]
}
},
"children": [
{
"attributes": {
"literals": [
"solidity",
"^",
"0.4",
".18"
]
},
"id": 2199,
"name": "PragmaDirective",
"src": "868:24:17"
},
{
"attributes": {
"SourceUnit": 85,
"absolutePath": "/Users/slanders/netvote/elections-solidity/contracts/auth/Adminable.sol",
"file": "../auth/Adminable.sol",
"scope": 2391,
"symbolAliases": [
null
],
"unitAlias": ""
},
"id": 2200,
"name": "ImportDirective",
"src": "894:31:17"
},
{
"attributes": {
"SourceUnit": 2648,
"absolutePath": "zeppelin-solidity/contracts/math/SafeMath.sol",
"file": "zeppelin-solidity/contracts/math/SafeMath.sol",
"scope": 2391,
"symbolAliases": [
null
],
"unitAlias": ""
},
"id": 2201,
"name": "ImportDirective",
"src": "926:55:17"
},
{
"attributes": {
"contractDependencies": [
84,
2703
],
"contractKind": "contract",
"documentation": null,
"fullyImplemented": true,
"linearizedBaseContracts": [
2390,
84,
2703
],
"name": "UtilizationTracker",
"scope": 2391
},
"children": [
{
"attributes": {
"arguments": [
null
]
},
"children": [
{
"attributes": {
"contractScope": null,
"name": "Adminable",
"referencedDeclaration": 84,
"type": "contract Adminable"
},
"id": 2202,
"name": "UserDefinedTypeName",
"src": "1015:9:17"
}
],
"id": 2203,
"name": "InheritanceSpecifier",
"src": "1015:9:17"
},
{
"children": [
{
"attributes": {
"contractScope": null,
"name": "SafeMath",
"referencedDeclaration": 2647,
"type": "library SafeMath"
},
"id": 2204,
"name": "UserDefinedTypeName",
"src": "1037:8:17"
},
{
"attributes": {
"name": "uint256",
"type": "uint256"
},
"id": 2205,
"name": "ElementaryTypeName",
"src": "1050:7:17"
}
],
"id": 2206,
"name": "UsingForDirective",
"src": "1031:27:17"
},
{
"attributes": {
"constant": false,
"name": "windows",
"scope": 2390,
"stateVariable": true,
"storageLocation": "default",
"type": "struct UtilizationTracker.UsageWindow storage ref[] storage ref",
"value": null,
"visibility": "public"
},
"children": [
{
"attributes": {
"length": null,
"type": "struct UtilizationTracker.UsageWindow storage ref[] storage pointer"
},
"children": [
{
"attributes": {
"contractScope": null,
"name": "UsageWindow",
"referencedDeclaration": 2217,
"type": "struct UtilizationTracker.UsageWindow storage pointer"
},
"id": 2207,
"name": "UserDefinedTypeName",
"src": "1064:11:17"
}
],
"id": 2208,
"name": "ArrayTypeName",
"src": "1064:13:17"
}
],
"id": 2209,
"name": "VariableDeclaration",
"src": "1064:28:17"
},
{
"attributes": {
"constant": false,
"name": "granularity",
"scope": 2390,
"stateVariable": true,
"storageLocation": "default",
"type": "uint256",
"visibility": "internal"
},
"children": [
{
"attributes": {
"name": "uint",
"type": "uint256"
},
"id": 2210,
"name": "ElementaryTypeName",
"src": "1098:4:17"
},
{
"attributes": {
"argumentTypes": null,
"hexvalue": "31",
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"subdenomination": "hours",
"token": "number",
"type": "int_const 3600",
"value": "1"
},
"id": 2211,
"name": "Literal",
"src": "1117:7:17"
}
],
"id": 2212,
"name": "VariableDeclaration",
"src": "1098:26:17"
},
{
"attributes": {
"canonicalName": "UtilizationTracker.UsageWindow",
"name": "UsageWindow",
"scope": 2390,
"visibility": "public"
},
"children": [
{
"attributes": {
"constant": false,
"name": "windowStart",
"scope": 2217,
"stateVariable": false,
"storageLocation": "default",
"type": "uint256",
"value": null,
"visibility": "internal"
},
"children": [
{
"attributes": {
"name": "uint",
"type": "uint256"
},
"id": 2213,
"name": "ElementaryTypeName",
"src": "1160:4:17"
}
],
"id": 2214,
"name": "VariableDeclaration",
"src": "1160:16:17"
},
{
"attributes": {
"constant": false,
"name": "utilization",
"scope": 2217,
"stateVariable": false,
"storageLocation": "default",
"type": "uint256",
"value": null,
"visibility": "internal"
},
"children": [
{
"attributes": {
"name": "uint256",
"type": "uint256"
},
"id": 2215,
"name": "ElementaryTypeName",
"src": "1186:7:17"
}
],
"id": 2216,
"name": "VariableDeclaration",
"src": "1186:19:17"
}
],
"id": 2217,
"name": "StructDefinition",
"src": "1131:81:17"
},
{
"attributes": {
"constant": false,
"implemented": true,
"isConstructor": true,
"modifiers": [
null
],
"name": "UtilizationTracker",
"payable": false,
"scope": 2390,
"stateMutability": "nonpayable",
"superFunction": null,
"visibility": "public"
},
"children": [
{
"attributes": {
"parameters": [
null
]
},
"children": [],
"id": 2218,
"name": "ParameterList",
"src": "1245:2:17"
},
{
"attributes": {
"parameters": [
null
]
},
"children": [],
"id": 2219,
"name": "ParameterList",
"src": "1255:0:17"
},
{
"children": [
{
"children": [
{
"attributes": {
"argumentTypes": null,
"isConstant": false,
"isLValue": false,
"isPure": false,
"isStructConstructorCall": false,
"lValueRequested": false,
"names": [
null
],
"type": "uint256",
"type_conversion": false
},
"children": [
{
"attributes": {
"argumentTypes": [
{
"typeIdentifier": "t_struct$_UsageWindow_$2217_memory",
"typeString": "struct UtilizationTracker.UsageWindow memory"
}
],
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"member_name": "push",
"referencedDeclaration": null,
"type": "function (struct UtilizationTracker.UsageWindow storage ref) returns (uint256)"
},
"children": [
{
"attributes": {
"argumentTypes": null,
"overloadedDeclarations": [
null
],
"referencedDeclaration": 2209,
"type": "struct UtilizationTracker.UsageWindow storage ref[] storage ref",
"value": "windows"
},
"id": 2220,
"name": "Identifier",
"src": "1265:7:17"
}
],
"id": 2222,
"name": "MemberAccess",
"src": "1265:12:17"
},
{
"attributes": {
"argumentTypes": null,
"isConstant": false,
"isLValue": false,
"isPure": false,
"isStructConstructorCall": true,
"lValueRequested": false,
"names": [
"windowStart",
"utilization"
],
"type": "struct UtilizationTracker.UsageWindow memory",
"type_conversion": false
},
"children": [
{
"attributes": {
"argumentTypes": null,
"overloadedDeclarations": [
null
],
"referencedDeclaration": 2217,
"type": "type(struct UtilizationTracker.UsageWindow storage pointer)",
"value": "UsageWindow"
},
"id": 2223,
"name": "Identifier",
"src": "1278:11:17"
},
{
"attributes": {
"argumentTypes": null,
"overloadedDeclarations": [
null
],
"referencedDeclaration": 3240,
"type": "uint256",
"value": "now"
},
"id": 2224,
"name": "Identifier",
"src": "1304:3:17"
},
{
"attributes": {
"argumentTypes": null,
"hexvalue": "30",
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"subdenomination": null,
"token": "number",
"type": "int_const 0",
"value": "0"
},
"id": 2225,
"name": "Literal",
"src": "1322:1:17"
}
],
"id": 2226,
"name": "FunctionCall",
"src": "1278:48:17"
}
],
"id": 2227,
"name": "FunctionCall",
"src": "1265:62:17"
}
],
"id": 2228,
"name": "ExpressionStatement",
"src": "1265:62:17"
}
],
"id": 2229,
"name": "Block",
"src": "1255:79:17"
}
],
"id": 2230,
"name": "FunctionDefinition",
"src": "1218:116:17"
},
{
"attributes": {
"constant": false,
"implemented": true,
"isConstructor": false,
"name": "setGranularity",
"payable": false,
"scope": 2390,
"stateMutability": "nonpayable",
"superFunction": null,
"visibility": "public"
},
"children": [
{
"children": [
{
"attributes": {
"constant": false,
"name": "gran",
"scope": 2242,
"stateVariable": false,
"storageLocation": "default",
"type": "uint256",
"value": null,
"visibility": "internal"
},
"children": [
{
"attributes": {
"name": "uint",
"type": "uint256"
},
"id": 2231,
"name": "ElementaryTypeName",
"src": "1364:4:17"
}
],
"id": 2232,
"name": "VariableDeclaration",
"src": "1364:9:17"
}
],
"id": 2233,
"name": "ParameterList",
"src": "1363:11:17"
},
{
"attributes": {
"parameters": [
null
]
},
"children": [],
"id": 2236,
"name": "ParameterList",
"src": "1388:0:17"
},
{
"attributes": {
"arguments": [
null
]
},
"children": [
{
"attributes": {
"argumentTypes": null,
"overloadedDeclarations": [
null
],
"referencedDeclaration": 19,
"type": "modifier ()",
"value": "admin"
},
"id": 2234,
"name": "Identifier",
"src": "1382:5:17"
}
],
"id": 2235,
"name": "ModifierInvocation",
"src": "1382:5:17"
},
{
"children": [
{
"children": [
{
"attributes": {
"argumentTypes": null,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"operator": "=",
"type": "uint256"
},
"children": [
{
"attributes": {
"argumentTypes": null,
"overloadedDeclarations": [
null
],
"referencedDeclaration": 2212,
"type": "uint256",
"value": "granularity"
},
"id": 2237,
"name": "Identifier",
"src": "1398:11:17"
},
{
"attributes": {
"argumentTypes": null,
"overloadedDeclarations": [
null
],
"referencedDeclaration": 2232,
"type": "uint256",
"value": "gran"
},
"id": 2238,
"name": "Identifier",
"src": "1412:4:17"
}
],
"id": 2239,
"name": "Assignment",
"src": "1398:18:17"
}
],
"id": 2240,
"name": "ExpressionStatement",
"src": "1398:18:17"
}
],
"id": 2241,
"name": "Block",
"src": "1388:35:17"
}
],
"id": 2242,
"name": "FunctionDefinition",
"src": "1340:83:17"
},
{
"attributes": {
"constant": true,
"implemented": true,
"isConstructor": false,
"modifiers": [
null
],
"name": "getWindowCountSince",
"payable": false,
"scope": 2390,
"stateMutability": "view",
"superFunction": null,
"visibility": "public"
},
"children": [
{
"children": [
{
"attributes": {
"constant": false,
"name": "horizon",
"scope": 2291,
"stateVariable": false,
"storageLocation": "default",
"type": "uint256",
"value": null,
"visibility": "internal"
},
"children": [
{
"attributes": {
"name": "uint256",
"type": "uint256"
},
"id": 2243,
"name": "ElementaryTypeName",
"src": "1458:7:17"
}
],
"id": 2244,
"name": "VariableDeclaration",
"src": "1458:15:17"
}
],
"id": 2245,
"name": "ParameterList",
"src": "1457:17:17"
},
{
"children": [
{
"attributes": {
"constant": false,
"name": "",
"scope": 2291,
"stateVariable": false,
"storageLocation": "default",
"type": "uint256",
"value": null,
"visibility": "internal"
},
"children": [
{
"attributes": {
"name": "uint256",
"type": "uint256"
},
"id": 2246,
"name": "ElementaryTypeName",
"src": "1500:7:17"
}
],
"id": 2247,
"name": "VariableDeclaration",
"src": "1500:7:17"
}
],
"id": 2248,
"name": "ParameterList",
"src": "1499:9:17"
},
{
"children": [
{
"attributes": {
"assignments": [
2250
]
},
"children": [
{
"attributes": {
"constant": false,
"name": "count",
"scope": 2291,
"stateVariable": false,
"storageLocation": "default",
"type": "uint256",
"value": null,
"visibility": "internal"
},
"children": [
{
"attributes": {
"name": "uint256",
"type": "uint256"
},
"id": 2249,
"name": "ElementaryTypeName",
"src": "1519:7:17"
}
],
"id": 2250,
"name": "VariableDeclaration",
"src": "1519:13:17"
},
{
"attributes": {
"argumentTypes": null,
"hexvalue": "30",
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"subdenomination": null,
"token": "number",
"type": "int_const 0",
"value": "0"
},
"id": 2251,
"name": "Literal",
"src": "1535:1:17"
}
],
"id": 2252,
"name": "VariableDeclarationStatement",
"src": "1519:17:17"
},
{
"children": [
{
"attributes": {
"assignments": [
2254
]
},
"children": [
{
"attributes": {
"constant": false,
"name": "i",
"scope": 2291,
"stateVariable": false,
"storageLocation": "default",
"type": "uint256",
"value": null,
"visibility": "internal"
},
"children": [
{
"attributes": {
"name": "uint",
"type": "uint256"
},
"id": 2253,
"name": "ElementaryTypeName",
"src": "1551:4:17"
}
],
"id": 2254,
"name": "VariableDeclaration",
"src": "1551:6:17"
},
{
"attributes": {
"argumentTypes": null,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"member_name": "length",
"referencedDeclaration": null,
"type": "uint256"
},
"children": [
{
"attributes": {
"argumentTypes": null,
"overloadedDeclarations": [
null
],
"referencedDeclaration": 2209,
"type": "struct UtilizationTracker.UsageWindow storage ref[] storage ref",
"value": "windows"
},
"id": 2255,
"name": "Identifier",
"src": "1560:7:17"
}
],
"id": 2256,
"name": "MemberAccess",
"src": "1560:14:17"
}
],
"id": 2257,
"name": "VariableDeclarationStatement",
"src": "1551:23:17"
},
{
"attributes": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"operator": ">",
"type": "bool"
},
"children": [
{
"attributes": {
"argumentTypes": null,
"overloadedDeclarations": [
null
],
"referencedDeclaration": 2254,
"type": "uint256",
"value": "i"
},
"id": 2258,
"name": "Identifier",
"src": "1576:1:17"
},
{
"attributes": {
"argumentTypes": null,
"hexvalue": "30",
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"subdenomination": null,
"token": "number",
"type": "int_const 0",
"value": "0"
},
"id": 2259,
"name": "Literal",
"src": "1580:1:17"
}
],
"id": 2260,
"name": "BinaryOperation",
"src": "1576:5:17"
},
{
"children": [
{
"attributes": {
"argumentTypes": null,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"operator": "--",
"prefix": false,
"type": "uint256"
},
"children": [
{
"attributes": {
"argumentTypes": null,
"overloadedDeclarations": [
null
],
"referencedDeclaration": 2254,
"type": "uint256",
"value": "i"
},
"id": 2261,
"name": "Identifier",
"src": "1583:1:17"
}
],
"id": 2262,
"name": "UnaryOperation",
"src": "1583:3:17"
}
],
"id": 2263,
"name": "ExpressionStatement",
"src": "1583:3:17"
},
{
"children": [
{
"attributes": {
"assignments": [
2265
]
},
"children": [
{
"attributes": {
"constant": false,
"name": "idx",
"scope": 2291,
"stateVariable": false,
"storageLocation": "default",
"type": "uint256",
"value": null,
"visibility": "internal"
},
"children": [
{
"attributes": {
"name": "uint",
"type": "uint256"
},
"id": 2264,
"name": "ElementaryTypeName",
"src": "1602:4:17"
}
],
"id": 2265,
"name": "VariableDeclaration",
"src": "1602:8:17"
},
{
"attributes": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"operator": "-",
"type": "uint256"
},
"children": [
{
"attributes": {
"argumentTypes": null,
"overloadedDeclarations": [
null
],
"referencedDeclaration": 2254,
"type": "uint256",
"value": "i"
},