Merge pull request #273 from shocknet/tip-counter-procedure
tip order procedure
This commit is contained in:
commit
dac47a6b28
1 changed files with 9 additions and 5 deletions
|
|
@ -227,19 +227,20 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
|
|
||||||
const invoicePutEndTime = performance.now() - invoicePutStartTime
|
const invoicePutEndTime = performance.now() - invoicePutStartTime
|
||||||
|
|
||||||
const hash = invoice.r_hash.toString('base64')
|
|
||||||
|
|
||||||
// invoices should be settled right away so we can rely on this single
|
// invoices should be settled right away so we can rely on this single
|
||||||
// subscription instead of life-long all invoices subscription
|
// subscription instead of life-long all invoices subscription
|
||||||
if (order.targetType === 'post') {
|
if (order.targetType === 'post') {
|
||||||
const { subscribeSingleInvoice } = LightningServices.invoices
|
|
||||||
const { postID } = order
|
const { postID } = order
|
||||||
|
|
||||||
if (!Common.isPopulatedString(postID)) {
|
if (!Common.isPopulatedString(postID)) {
|
||||||
throw new TypeError(`postID not a a populated string`)
|
throw new TypeError(`postID not a a populated string`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const stream = subscribeSingleInvoice({ r_hash: hash })
|
const { r_hash } = invoice
|
||||||
|
|
||||||
|
// A post tip order lifecycle is short enough that we can do it like this.
|
||||||
|
const stream = LightningServices.invoices.subsribeSingleInvoice({
|
||||||
|
r_hash
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Common.Invoice} invoice
|
* @param {Common.Invoice} invoice
|
||||||
|
|
@ -263,6 +264,9 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
stream.on('end', () => {
|
stream.on('end', () => {
|
||||||
logger.warn(`Post tip, post: ${postID}, invoice stream ended`)
|
logger.warn(`Post tip, post: ${postID}, invoice stream ended`)
|
||||||
})
|
})
|
||||||
|
stream.on('error', (/** @type {any} */ e) => {
|
||||||
|
logger.warn(`Post tip, post: ${postID}, error:`, e)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`[PERF] Added invoice to GunDB in ${invoicePutEndTime}ms`)
|
logger.info(`[PERF] Added invoice to GunDB in ${invoicePutEndTime}ms`)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue