Added measurment logs
This commit is contained in:
parent
a1b55ff65c
commit
c5e4de1619
1 changed files with 36 additions and 0 deletions
|
|
@ -85,6 +85,8 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
|||
return
|
||||
}
|
||||
|
||||
const listenerStartTime = Date.now()
|
||||
|
||||
ordersProcessed.add(orderID)
|
||||
|
||||
logger.info(
|
||||
|
|
@ -93,6 +95,8 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
|||
)} -- addr: ${addr}`
|
||||
)
|
||||
|
||||
const orderAnswerStartTime = Date.now()
|
||||
|
||||
const alreadyAnswered = await getUser()
|
||||
.get(Key.ORDER_TO_RESPONSE)
|
||||
.get(orderID)
|
||||
|
|
@ -103,6 +107,12 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
|||
return
|
||||
}
|
||||
|
||||
const orderAnswerEndTime = Date.now() - orderAnswerStartTime
|
||||
|
||||
logger.info(`[PERF] Order Already Answered: ${orderAnswerEndTime}ms`)
|
||||
|
||||
const decryptStartTime = Date.now()
|
||||
|
||||
const senderEpub = await Utils.pubToEpub(order.from)
|
||||
const secret = await SEA.secret(senderEpub, getUser()._.sea)
|
||||
|
||||
|
|
@ -111,6 +121,10 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
|||
SEA.decrypt(order.memo, secret)
|
||||
])
|
||||
|
||||
const decryptEndTime = Date.now() - decryptStartTime
|
||||
|
||||
logger.info(`[PERF] Decrypt invoice info: ${decryptEndTime}ms`)
|
||||
|
||||
const amount = Number(decryptedAmount)
|
||||
|
||||
if (!isNumber(amount)) {
|
||||
|
|
@ -142,17 +156,29 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
|||
`onOrders() -> Will now create an invoice : ${JSON.stringify(invoiceReq)}`
|
||||
)
|
||||
|
||||
const invoiceStartTime = Date.now()
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
const invoice = await _addInvoice(invoiceReq)
|
||||
|
||||
const invoiceEndTime = Date.now() - invoiceStartTime
|
||||
|
||||
logger.info(`[PERF] LND Invoice created in ${invoiceEndTime}ms`)
|
||||
|
||||
logger.info(
|
||||
'onOrders() -> Successfully created the invoice, will now encrypt it'
|
||||
)
|
||||
|
||||
const invoiceEncryptStartTime = Date.now()
|
||||
|
||||
const encInvoice = await SEA.encrypt(invoice, secret)
|
||||
|
||||
const invoiceEncryptEndTime = Date.now() - invoiceEncryptStartTime
|
||||
|
||||
logger.info(`[PERF] Invoice encrypted in ${invoiceEncryptEndTime}ms`)
|
||||
|
||||
logger.info(
|
||||
`onOrders() -> Will now place the encrypted invoice in order to response usergraph: ${addr}`
|
||||
)
|
||||
|
|
@ -163,6 +189,8 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
|||
type: 'invoice'
|
||||
}
|
||||
|
||||
const invoicePutStartTime = Date.now()
|
||||
|
||||
await new Promise((res, rej) => {
|
||||
getUser()
|
||||
.get(Key.ORDER_TO_RESPONSE)
|
||||
|
|
@ -179,6 +207,14 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
|||
}
|
||||
})
|
||||
})
|
||||
|
||||
const invoicePutEndTime = Date.now() - invoicePutStartTime
|
||||
|
||||
logger.info(`[PERF] Added invoice to GunDB in ${invoicePutEndTime}ms`)
|
||||
|
||||
const listenerEndTime = Date.now() - listenerStartTime
|
||||
|
||||
logger.info(`[PERF] Invoice generation completed in ${listenerEndTime}ms`)
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
`error inside onOrders, orderAddr: ${addr}, orderID: ${orderID}, order: ${JSON.stringify(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue