Skip to content

Commit

Permalink
Linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdean-digicatapult committed Jul 12, 2018
1 parent 3a34cfe commit 0711147
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function VM (opts = {}) {
this.stateManager = opts.stateManager
} else {
var trie = opts.state || new Trie()
if(opts.activatePrecompiles) {
if (opts.activatePrecompiles) {
trie = new Trie()
for (var i = 1; i <= 8; i++) {
trie.put(new BN(i).toArrayLike(Buffer, 'be', 20), new Account().serialize())
Expand Down
5 changes: 2 additions & 3 deletions lib/opFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ module.exports = {
stateManager.putContractStorage(address, key, value, function (err) {
if (err) return cb(err)
stateManager.getAccount(address, function (err, account) {
if(err) return cb(err)
if (err) return cb(err)
runState.contract = account
cb(null)
})
Expand Down Expand Up @@ -642,7 +642,6 @@ module.exports = {
})
},
STATICCALL: function (gasLimit, toAddress, inOffset, inLength, outOffset, outLength, runState, done) {
var stateManager = runState.stateManager
var value = new BN(0)
toAddress = addressToBuffer(toAddress)

Expand Down Expand Up @@ -926,7 +925,7 @@ function makeCall (runState, callOptions, localOpts, cb) {
}

runState.stateManager.putAccount(runState.address, runState.contract, function (err) {
if(err) return cb(err)
if (err) return cb(err)
runState._vm.runCall(callOptions, parseCallResults)
})
}
Expand Down
11 changes: 5 additions & 6 deletions lib/runBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ module.exports = function (opts, cb) {
const receiptTrie = new Trie()
// the total amount of gas used processing this block
var gasUsed = new BN(0)
// miner account
var minerAccount
var receipts = []
var txResults = []
var result
Expand Down Expand Up @@ -70,7 +68,7 @@ module.exports = function (opts, cb) {
// run the tx through the VM
self.runTx({
tx: tx,
block: block,
block: block
}, parseTxResult)

function parseTxResult (err, result) {
Expand Down Expand Up @@ -149,7 +147,8 @@ module.exports = function (opts, cb) {

function rewardAccount (address, reward, done) {
self.stateManager.getAccount(address, function (err, account) {
//give miner the block reward
if (err) return done(err)
// give miner the block reward
account.balance = new BN(account.balance).add(reward)
self.stateManager.putAccount(address, account, done)
})
Expand All @@ -164,10 +163,10 @@ module.exports = function (opts, cb) {
}

self.stateManager.commit(function (err) {
if(err) return cb(err)
if (err) return cb(err)

self.stateManager.getStateRoot(function (err, stateRoot) {
if(err) return cb(err)
if (err) return cb(err)

// credit all block rewards
if (generateStateRoot) {
Expand Down
4 changes: 2 additions & 2 deletions lib/runBlockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ module.exports = function (blockchain, cb) {
// if we are just starting or if a chain re-org has happened
if (!headBlock || reorg) {
self.blockchain.getBlock(block.header.parentHash, function (err, parentBlock) {
if(err) return cb(err)
if (err) return cb(err)

self.stateManager.getStateRoot(function (err, stateManagerRoot) {
if(err) return cb(err)
if (err) return cb(err)

var parentState = parentBlock.header.stateRoot
// generate genesis state if we are at the genesis block
Expand Down
4 changes: 2 additions & 2 deletions lib/runCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ module.exports = function (opts, cb) {
if (err) {
results.logs = []
stateManager.revert(function (revertErr) {
if(revertErr || !isCompiled) cb(revertErr)
if (revertErr || !isCompiled) cb(revertErr)
else {
if (err === ERROR.OUT_OF_GAS || err.error === ERROR.OUT_OF_GAS) {
self.stateManager.getAccount(toAddress, (getErr, acc) => {
if(getErr) cb(getErr)
if (getErr) cb(getErr)
else self.stateManager.putAccount(toAddress, acc, cb)
})
} else {
Expand Down
5 changes: 2 additions & 3 deletions lib/runTx.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = function (opts, cb) {
runCall,
runAfterTxHook
], function (err) {
if(err) self.stateManager.revert(() => cb(err, results))
if (err) self.stateManager.revert(() => cb(err, results))
else self.stateManager.commit((err) => cb(err, results))
})

Expand All @@ -59,7 +59,7 @@ module.exports = function (opts, cb) {

function updateFromAccount (cb) {
self.stateManager.getAccount(tx.from, function (err, fromAccount) {
if(err) {
if (err) {
cb(err)
return
}
Expand Down Expand Up @@ -92,7 +92,6 @@ module.exports = function (opts, cb) {

// sets up the environment and runs a `call`
function runCall (cb) {

var options = {
caller: tx.from,
gasLimit: gasLimit,
Expand Down
4 changes: 2 additions & 2 deletions lib/stateManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ proto.commit = function (cb) {
self._cache.commit()
self._touchedStack.pop()

if(self._touchedStack.length === 0) self._cache.flush(cb)
if (self._touchedStack.length === 0) self._cache.flush(cb)
else cb()
})
}
Expand All @@ -190,7 +190,7 @@ proto.revert = function (cb) {
self._storageTries = {}
self._touched = self._touchedStack.pop()

if(self._touchedStack.length === 0) self._cache.flush(cb)
if (self._touchedStack.length === 0) self._cache.flush(cb)
else cb()
}

Expand Down
7 changes: 5 additions & 2 deletions tests/genesishashes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ tape('[Common]: genesis hashes tests', function (t) {
t.test('should generate the genesis state correctly', function (st) {
vm.stateManager.generateCanonicalGenesis(function () {
vm.stateManager.getStateRoot(function (err, stateRoot) {
st.equal(stateRoot.toString('hex'), genesisData.genesis_state_root)
st.end()
if (err) st.fail(err)
else {
st.equal(stateRoot.toString('hex'), genesisData.genesis_state_root)
st.end()
}
})
})
})
Expand Down

0 comments on commit 0711147

Please sign in to comment.