Skip to content

Commit

Permalink
bubble light client events
Browse files Browse the repository at this point in the history
  • Loading branch information
keppel committed Feb 8, 2019
1 parent 00ce01f commit 9de8562
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
26 changes: 16 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ let getPeerGCI = require('./lib/gci-get-peer.js')
let Proxmise = require('proxmise')
let jpfs = require('jpfs')
let { parse, stringify } = require('deterministic-json')
let { EventEmitter } = require('events')

function connect(GCI, opts = {}) {
return new Promise(async (resolve, reject) => {
Expand Down Expand Up @@ -34,16 +35,21 @@ function connect(GCI, opts = {}) {
let getState = GetState(lc)
let sendTx = SendTx(lc)
await delay()
resolve({
getState,
send: sendTx,
state: Proxmise(path => {
return getState(path.join('.'))
}),
get validators () {
return lc._state.validators
}
})
let bus = new EventEmitter()
lc.on('error', e => bus.emit('error', e))
resolve(
Object.assign(bus, {
getState,
send: sendTx,
lightClient: lc,
state: Proxmise(path => {
return getState(path.join('.'))
}),
get validators() {
return lc._state.validators
}
})
)
})
}

Expand Down
2 changes: 0 additions & 2 deletions lib/connect-by-address-from-genesis.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ function startLightClientFromGenesis(genesis, nodeAddress) {
header: { height: 1, chain_id: genesis.chain_id }
}
let lc = tendermint(nodeAddress, clientState)
lc.on('update', function(header) {})
lc.on('error', function(err) {})
resolve(lc)
})
}
Expand Down

0 comments on commit 9de8562

Please sign in to comment.