Skip to content

Commit

Permalink
fix: update ethereum-adapter, don't die on balance check fail
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Feb 22, 2018
1 parent bb298b8 commit 58de2f1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
38 changes: 24 additions & 14 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions src/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,18 @@ export default class Blockchain {
this.start()
this.logger.debug(`sealing ${link}`)
if (typeof balance === 'undefined') {
balance = await this.balance()
try {
balance = await this.balance()
} catch (err) {
this.logger.error('failed to get balance', err)
}
}

const amount = this.getTxAmount()
if (compareBalance(balance, amount) === -1) {
throw new Errors.LowFunds(`have ${balance}, need at least ${amount}`)
if (typeof balance !== 'undefined') {
if (compareBalance(balance, amount) === -1) {
throw new Errors.LowFunds(`have ${balance}, need at least ${amount}`)
}
}

try {
Expand Down
10 changes: 9 additions & 1 deletion src/seals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,15 @@ export default class Seals {
this.logger.info(`found ${pending.length} pending seals`)
let aborted
// TODO: update balance after every tx
const balance = this.blockchain.balance ? await this.blockchain.balance() : undefined
let balance
if (this.blockchain.balance) {
try {
balance = await this.blockchain.balance()
} catch (err) {
this.logger.error('failed to get balance', err)
}
}

const results = await seriesMap(pending, async (sealInfo: Seal) => {
if (aborted) return

Expand Down

0 comments on commit 58de2f1

Please sign in to comment.