Skip to content

Instantly share code, notes, and snippets.

@ethers
Created November 12, 2014 20:19
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 ethers/10f27a44c3ab5e2997a0 to your computer and use it in GitHub Desktop.
Save ethers/10f27a44c3ab5e2997a0 to your computer and use it in GitHub Desktop.
SSTORE logic
storageTrie.get(key, function(err, found) {
if (found || (!found && val.toString('hex') === '00')) {
gasLeft = gasLeft.add(100);
} else if (!found && val.toString('hex') !== '00') {
gasLeft = gasLeft.sub(100);
} else if (found && val.toString('hex') === '00') {
gasLeft = gasLeft.add(200);
}
if (val.toString('hex') === '00') {
val = '';
} else {
val = rlp.encode(val);
}
storageTrie.put(key, val, function(){
//update the stateRoot on the account
opts.account.stateRoot = storageTrie.root;
done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment