debugging missing order statuses
This commit is contained in:
14
order.js
14
order.js
@@ -13,17 +13,18 @@ export function sendVaultOrders( socket, chainId, vault ) {
|
|||||||
console.log('vault closed orders', closedIndexes)
|
console.log('vault closed orders', closedIndexes)
|
||||||
const statuses = {}
|
const statuses = {}
|
||||||
const indexes = [...JSON.parse(openIndexes), ...JSON.parse(closedIndexes)]
|
const indexes = [...JSON.parse(openIndexes), ...JSON.parse(closedIndexes)]
|
||||||
|
const proms = []
|
||||||
if( openIndexes !== null ) {
|
if( openIndexes !== null ) {
|
||||||
for (const orderIndex of indexes) {
|
for (const orderIndex of indexes) {
|
||||||
// there is a race condition here since we need multiple queries to get the complete order status,
|
// there is a race condition here since we need multiple queries to get the complete order status,
|
||||||
// so we check for nulls and exclude such an order, since it was deleted and no longer active.
|
// so we check for nulls and exclude such an order, since it was deleted and no longer active.
|
||||||
const status = await orderStatus(chainId, vault, orderIndex)
|
proms.push(orderStatus(chainId, vault, orderIndex).then((status)=>{
|
||||||
if (status !== null)
|
if (status !== null)
|
||||||
statuses[orderIndex] = status
|
statuses[orderIndex] = status
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('vault archived orders', recents)
|
console.log('vault archived orders', recents)
|
||||||
const proms = []
|
|
||||||
for( let [orderIndex, status] of recents ) {
|
for( let [orderIndex, status] of recents ) {
|
||||||
if( !(orderIndex in statuses) ) {
|
if( !(orderIndex in statuses) ) {
|
||||||
// only write the database version if there's no open order in the memcache
|
// only write the database version if there's no open order in the memcache
|
||||||
@@ -47,7 +48,10 @@ export function unsubVaultOrders( socket, chainId, vault ) {
|
|||||||
export async function orderStatus( chainId, vault, orderIndex ) {
|
export async function orderStatus( chainId, vault, orderIndex ) {
|
||||||
const orderKey = `${vault}|${orderIndex}`
|
const orderKey = `${vault}|${orderIndex}`
|
||||||
let status = await orderStatuses.get(chainId, orderKey)
|
let status = await orderStatuses.get(chainId, orderKey)
|
||||||
if( status !== null ) {
|
if( status === null ) {
|
||||||
|
console.warn(`Could not find order status for ${chainId}|${vault}|${orderIndex}`)
|
||||||
|
}
|
||||||
|
else {
|
||||||
status = JSON.parse(status)
|
status = JSON.parse(status)
|
||||||
await fillOrderStatus(chainId, orderKey, status)
|
await fillOrderStatus(chainId, orderKey, status)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user