Skip to content

Commit db5e03c

Browse files
author
Stavros
committed
small change to save up some gas
1 parent 77b012a commit db5e03c

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

contracts/GetWhitelist.sol

+19-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ contract GetWhitelist is Ownable {
77
using SafeMathLib for uint;
88

99
event NewEntry(address whitelisted);
10+
event NewBatch();
1011
event EdittedEntry(address whitelisted, uint tier);
1112
event WhitelisterChange(address whitelister, bool iswhitelister);
1213

@@ -46,15 +47,30 @@ contract GetWhitelist is Ownable {
4647
}
4748

4849
function acceptBatched(address[] _addresses, bool _isEarly) onlyWhitelister {
50+
// trying to save up some gas here
51+
uint _presaleCap;
52+
if (_isEarly) {
53+
_presaleCap = presaleCap;
54+
} else {
55+
_presaleCap = 0;
56+
}
4957
for (uint i=0; i<_addresses.length; i++) {
50-
accept(_addresses[i], _isEarly);
58+
entries[_addresses[i]] = WhitelistInfo(
59+
_presaleCap,
60+
tier1Cap,
61+
tier2Cap,
62+
tier3Cap,
63+
tier4Cap,
64+
true
65+
);
5166
}
67+
NewBatch();
5268
}
5369

54-
function accept(address _address, bool isEarly) onlyWhitelister {
70+
function accept(address _address, bool _isEarly) onlyWhitelister {
5571
require(!entries[_address].isWhitelisted);
5672
uint _presaleCap;
57-
if (isEarly) {
73+
if (_isEarly) {
5874
_presaleCap = presaleCap;
5975
} else {
6076
_presaleCap = 0;

test/0_whitelist.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ contract('GetWhitelist', function(accounts) {
185185
});
186186

187187
it("whitelister can add multiple addresses", async function(){
188-
const n = 37; //37 is the max without out of gas exception
188+
const n = 38; //38 is the max without out of gas exception
189189
var whitelist = await GetWhitelist.deployed();
190190
let randomAccounts = (new Array(n)).fill(true).map(() => {
191191
return VanityEth.getVanityWallet().address

0 commit comments

Comments
 (0)