Skip to content

Instantly share code, notes, and snippets.

@kvhnuke
Last active August 29, 2015 14:22
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 kvhnuke/4ef6d2412c949ea1ccab to your computer and use it in GitHub Desktop.
Save kvhnuke/4ef6d2412c949ea1ccab to your computer and use it in GitHub Desktop.
huge Storage ethereum contract
contract hugeStorage {
address owner;
uint counter;
uint maxLoop = 10;
mapping(uint => bytes32) storage;
mapping(uint => bytes) dataStorage;
event Logger(uint cntr, uint cntr2, bytes32 data, uint gas);
function hugeStorage(){
owner = msg.sender;
counter = 0;
}
function addData(bytes32 data){
uint counts = 0;
for(uint i=0; i<maxLoop;i++){
storage[counter]=data;
dataStorage[counter] = msg.data;
counter++;
counts++;
}
Logger(counter,counts,data,msg.gas);
}
function epicLoop(bytes32 data){
uint counts = 0;
while(msg.gas>10000){
storage[counter]=data;
dataStorage[counter] = msg.data;
counter++;
counts++;
}
Logger(counter,counts,data,msg.gas);
}
function getCounter() returns (uint){
return counter;
}
function setMaxLoop(uint mloop) {
maxLoop = mloop;
}
function getByteLength(uint id) returns (uint){
return dataStorage[id].length;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment