Skip to content

Commit

Permalink
fix: node interface parsing and bump 2.9.0-rc7
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanVerstraete committed Feb 27, 2023
1 parent 2e571cf commit 47d2d60
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion indexer/chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: tfchainindexer
description: Helm Chart for the tfchain hydra indexer
version: 2.7.7
apiVersion: v2
appVersion: '2.9.0-rc6'
appVersion: '2.9.0-rc7'
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "graphql_tfgrid",
"private": "true",
"version": "2.9.0-rc6",
"version": "2.9.0-rc7",
"description": "GraphQL server and Substrate indexer. Generated with ♥ by Hydra-CLI",
"author": "",
"license": "ISC",
Expand Down
2 changes: 1 addition & 1 deletion processor-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v2
name: tfchain-processor
description: A chart for the tfchain graphql processor and query node
version: 1.0.5
appVersion: '2.9.0-rc6'
appVersion: '2.9.0-rc7'
33 changes: 12 additions & 21 deletions src/mappings/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PublicConfig as V105PublicConfig } from '../types/v105'

import { Ctx } from '../processor'
import assert from "assert";
import { allowedNodeEnvironmentFlags } from "process";

export async function nodeStored(
ctx: Ctx,
Expand Down Expand Up @@ -139,11 +140,9 @@ export async function nodeStored(
newInterface.mac = intf.mac.toString()
newInterface.ips = intf.ips.map(ip => ip.toString()).join(',')
await ctx.store.save<Interfaces>(newInterface)
newNode.interfaces.push(newInterface)
})

await Promise.all(interfacesPromisses)
await ctx.store.save<Node>(newNode)
}

export async function nodeUpdated(
Expand Down Expand Up @@ -319,31 +318,23 @@ export async function nodeUpdated(
}
}

const interfacesPromisses = nodeEvent.interfaces.map(async intf => {
let newInterface

if (savedNode.interfaces) {
// if an interface with same name exists
const found = savedNode.interfaces.findIndex(interf => interf.name === intf.name.toString())
if (found > 0) {
newInterface = savedNode.interfaces[found]
} else {
newInterface = new Interfaces()
newInterface.id = item.event.id
newInterface.node = savedNode
}
}

if (!newInterface) return
// First remove all ifs
const nodeIfs = await ctx.store.find(Interfaces, { where: { node: { nodeID: savedNode.nodeID } } })
await ctx.store.remove(nodeIfs)

// Save ones from update event
await Promise.all(nodeEvent.interfaces.map(async intf => {
const newInterface = new Interfaces()
newInterface.id = item.event.id + intf.name.toString()
newInterface.name = intf.name.toString()
newInterface.mac = intf.mac.toString()
newInterface.ips = intf.ips.map(ip => ip.toString()).join(',')

newInterface.node = savedNode
await ctx.store.save<Interfaces>(newInterface)

savedNode.interfaces.push(newInterface)
})
await Promise.all(interfacesPromisses)
}))

await ctx.store.save<Node>(savedNode)
}

Expand Down

0 comments on commit 47d2d60

Please sign in to comment.