|
|
@ -34,7 +34,7 @@ EthereumStore.prototype.addAccount = function(address){ |
|
|
|
self._currentState.accounts[address] = {} |
|
|
|
self._currentState.accounts[address] = {} |
|
|
|
self._didUpdate() |
|
|
|
self._didUpdate() |
|
|
|
if (!self.currentBlockNumber) return |
|
|
|
if (!self.currentBlockNumber) return |
|
|
|
self._updateAccountForBlock(self.currentBlockNumber, address, noop) |
|
|
|
self._updateAccount(self.currentBlockNumber, address, noop) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
EthereumStore.prototype.removeAccount = function(address){ |
|
|
|
EthereumStore.prototype.removeAccount = function(address){ |
|
|
@ -73,7 +73,7 @@ EthereumStore.prototype._updateForBlock = function(block) { |
|
|
|
var blockNumber = '0x'+block.number.toString('hex') |
|
|
|
var blockNumber = '0x'+block.number.toString('hex') |
|
|
|
self.currentBlockNumber = blockNumber |
|
|
|
self.currentBlockNumber = blockNumber |
|
|
|
async.parallel([ |
|
|
|
async.parallel([ |
|
|
|
self._updateAccountsForBlock.bind(self, blockNumber), |
|
|
|
self._updateAccounts.bind(self), |
|
|
|
self._updateTransactions.bind(self, blockNumber), |
|
|
|
self._updateTransactions.bind(self, blockNumber), |
|
|
|
], function(err){ |
|
|
|
], function(err){ |
|
|
|
if (err) return console.error(err) |
|
|
|
if (err) return console.error(err) |
|
|
@ -81,17 +81,17 @@ EthereumStore.prototype._updateForBlock = function(block) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
EthereumStore.prototype._updateAccountsForBlock = function(block, cb) { |
|
|
|
EthereumStore.prototype._updateAccounts = function(cb) { |
|
|
|
const self = this |
|
|
|
const self = this |
|
|
|
var accountsState = self._currentState.accounts |
|
|
|
var accountsState = self._currentState.accounts |
|
|
|
var addresses = Object.keys(accountsState) |
|
|
|
var addresses = Object.keys(accountsState) |
|
|
|
async.each(addresses, self._updateAccountForBlock.bind(self, block), cb) |
|
|
|
async.each(addresses, self._updateAccount.bind(self), cb) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
EthereumStore.prototype._updateAccountForBlock = function(block, address, cb) { |
|
|
|
EthereumStore.prototype._updateAccount = function(address, cb) { |
|
|
|
const self = this |
|
|
|
const self = this |
|
|
|
var accountsState = self._currentState.accounts |
|
|
|
var accountsState = self._currentState.accounts |
|
|
|
self._query.getAccount(address, block, function(err, result){ |
|
|
|
self._query.getAccount(address, function(err, result){ |
|
|
|
if (err) return cb(err) |
|
|
|
if (err) return cb(err) |
|
|
|
result.address = address |
|
|
|
result.address = address |
|
|
|
// only populate if the entry is still present
|
|
|
|
// only populate if the entry is still present
|
|
|
@ -103,6 +103,15 @@ EthereumStore.prototype._updateAccountForBlock = function(block, address, cb) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EthereumStore.prototype.getAccount = function(address, cb){ |
|
|
|
|
|
|
|
const block = 'latest' |
|
|
|
|
|
|
|
async.parallel({ |
|
|
|
|
|
|
|
balance: this._query.getBalance.bind(this, address, block), |
|
|
|
|
|
|
|
nonce: this._query.getNonce.bind(this, address, block), |
|
|
|
|
|
|
|
code: this._query.getCode.bind(this, address, block), |
|
|
|
|
|
|
|
}, cb) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
EthereumStore.prototype._updateTransactions = function(block, cb) { |
|
|
|
EthereumStore.prototype._updateTransactions = function(block, cb) { |
|
|
|
const self = this |
|
|
|
const self = this |
|
|
|
var transactionsState = self._currentState.transactions |
|
|
|
var transactionsState = self._currentState.transactions |
|
|
|