Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
refactor(lnd): promisify lnd peers methods
Browse files Browse the repository at this point in the history
  • Loading branch information
korhaliv committed Jan 17, 2019
1 parent c55ef33 commit 0a0a5ed
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions app/lib/lnd/methods/peersController.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { promisifiedCall } from '../../utils'
/**
* Attempts to establish a connection to a remote peer
* @param {[type]} lnd [description]
Expand All @@ -6,15 +7,7 @@
* @return {[type]} [description]
*/
export function connectPeer(lnd, { pubkey, host }) {
return new Promise((resolve, reject) => {
lnd.connectPeer({ addr: { pubkey, host } }, (err, data) => {
if (err) {
return reject(err)
}

resolve(data)
})
})
return promisifiedCall(lnd, lnd.connectPeer, { addr: { pubkey, host } })
}

/**
Expand All @@ -24,15 +17,7 @@ export function connectPeer(lnd, { pubkey, host }) {
* @return {[type]} [description]
*/
export function disconnectPeer(lnd, { pubkey }) {
return new Promise((resolve, reject) => {
lnd.disconnectPeer({ pub_key: pubkey }, (err, data) => {
if (err) {
return reject(err)
}

resolve(data)
})
})
return promisifiedCall(lnd, lnd.disconnectPeer, { pub_key: pubkey })
}

/**
Expand All @@ -41,13 +26,5 @@ export function disconnectPeer(lnd, { pubkey }) {
* @return {[type]} [description]
*/
export function listPeers(lnd) {
return new Promise((resolve, reject) => {
lnd.listPeers({}, (err, data) => {
if (err) {
return reject(err)
}

resolve(data)
})
})
return promisifiedCall(lnd, lnd.listPeers, {})
}

0 comments on commit 0a0a5ed

Please sign in to comment.