metrics fixes
This commit is contained in:
parent
bdee3426ae
commit
de91573f2e
8 changed files with 83 additions and 5 deletions
|
|
@ -983,6 +983,9 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
|
||||
### LndGetInfoResponse
|
||||
- __alias__: _string_
|
||||
- __synced_to_chain__: _boolean_
|
||||
- __synced_to_graph__: _boolean_
|
||||
- __watchdog_barking__: _boolean_
|
||||
|
||||
### LndMetrics
|
||||
- __nodes__: ARRAY of: _[LndNodeMetrics](#LndNodeMetrics)_
|
||||
|
|
|
|||
|
|
@ -305,7 +305,10 @@ type LndGetInfoRequest struct {
|
|||
Nodeid int64 `json:"nodeId"`
|
||||
}
|
||||
type LndGetInfoResponse struct {
|
||||
Alias string `json:"alias"`
|
||||
Alias string `json:"alias"`
|
||||
Synced_to_chain bool `json:"synced_to_chain"`
|
||||
Synced_to_graph bool `json:"synced_to_graph"`
|
||||
Watchdog_barking bool `json:"watchdog_barking"`
|
||||
}
|
||||
type LndMetrics struct {
|
||||
Nodes []LndNodeMetrics `json:"nodes"`
|
||||
|
|
|
|||
|
|
@ -1730,11 +1730,17 @@ export const LndGetInfoRequestValidate = (o?: LndGetInfoRequest, opts: LndGetInf
|
|||
|
||||
export type LndGetInfoResponse = {
|
||||
alias: string
|
||||
synced_to_chain: boolean
|
||||
synced_to_graph: boolean
|
||||
watchdog_barking: boolean
|
||||
}
|
||||
export const LndGetInfoResponseOptionalFields: [] = []
|
||||
export type LndGetInfoResponseOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
alias_CustomCheck?: (v: string) => boolean
|
||||
synced_to_chain_CustomCheck?: (v: boolean) => boolean
|
||||
synced_to_graph_CustomCheck?: (v: boolean) => boolean
|
||||
watchdog_barking_CustomCheck?: (v: boolean) => boolean
|
||||
}
|
||||
export const LndGetInfoResponseValidate = (o?: LndGetInfoResponse, opts: LndGetInfoResponseOptions = {}, path: string = 'LndGetInfoResponse::root.'): Error | null => {
|
||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||
|
|
@ -1743,6 +1749,15 @@ export const LndGetInfoResponseValidate = (o?: LndGetInfoResponse, opts: LndGetI
|
|||
if (typeof o.alias !== 'string') return new Error(`${path}.alias: is not a string`)
|
||||
if (opts.alias_CustomCheck && !opts.alias_CustomCheck(o.alias)) return new Error(`${path}.alias: custom check failed`)
|
||||
|
||||
if (typeof o.synced_to_chain !== 'boolean') return new Error(`${path}.synced_to_chain: is not a boolean`)
|
||||
if (opts.synced_to_chain_CustomCheck && !opts.synced_to_chain_CustomCheck(o.synced_to_chain)) return new Error(`${path}.synced_to_chain: custom check failed`)
|
||||
|
||||
if (typeof o.synced_to_graph !== 'boolean') return new Error(`${path}.synced_to_graph: is not a boolean`)
|
||||
if (opts.synced_to_graph_CustomCheck && !opts.synced_to_graph_CustomCheck(o.synced_to_graph)) return new Error(`${path}.synced_to_graph: custom check failed`)
|
||||
|
||||
if (typeof o.watchdog_barking !== 'boolean') return new Error(`${path}.watchdog_barking: is not a boolean`)
|
||||
if (opts.watchdog_barking_CustomCheck && !opts.watchdog_barking_CustomCheck(o.watchdog_barking)) return new Error(`${path}.watchdog_barking: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,6 +191,9 @@ message SetMockInvoiceAsPaidRequest {
|
|||
|
||||
message LndGetInfoResponse {
|
||||
string alias = 1;
|
||||
bool synced_to_chain = 2;
|
||||
bool synced_to_graph = 3;
|
||||
bool watchdog_barking = 4;
|
||||
}
|
||||
|
||||
message BanUserRequest {
|
||||
|
|
|
|||
42
src/e2e.ts
Normal file
42
src/e2e.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import 'dotenv/config'
|
||||
import NewServer from '../proto/autogenerated/ts/express_server.js'
|
||||
import GetServerMethods from './services/serverMethods/index.js'
|
||||
import serverOptions from './auth.js';
|
||||
import { LoadNosrtSettingsFromEnv } from './services/nostr/index.js'
|
||||
import nostrMiddleware from './nostrMiddleware.js'
|
||||
import { getLogger } from './services/helpers/logger.js';
|
||||
import { initMainHandler } from './services/main/init.js';
|
||||
import { LoadMainSettingsFromEnv } from './services/main/settings.js';
|
||||
import { nip19 } from 'nostr-tools'
|
||||
//@ts-ignore
|
||||
const { nprofileEncode } = nip19
|
||||
|
||||
const start = async () => {
|
||||
const log = getLogger({})
|
||||
const mainSettings = LoadMainSettingsFromEnv()
|
||||
const keepOn = await initMainHandler(log, mainSettings)
|
||||
if (!keepOn) {
|
||||
log("manual process ended")
|
||||
return
|
||||
}
|
||||
|
||||
const { apps, mainHandler, liquidityProviderInfo, wizard, adminManager } = keepOn
|
||||
const serverMethods = GetServerMethods(mainHandler)
|
||||
const nostrSettings = LoadNosrtSettingsFromEnv()
|
||||
log("initializing nostr middleware")
|
||||
const { Send } = nostrMiddleware(serverMethods, mainHandler,
|
||||
{ ...nostrSettings, apps, clients: [liquidityProviderInfo] },
|
||||
(e, p) => mainHandler.liquidityProvider.onEvent(e, p)
|
||||
)
|
||||
log("starting server")
|
||||
mainHandler.attachNostrSend(Send)
|
||||
mainHandler.StartBeacons()
|
||||
const appNprofile = nprofileEncode({ pubkey: liquidityProviderInfo.publicKey, relays: nostrSettings.relays })
|
||||
if (wizard) {
|
||||
wizard.AddConnectInfo(appNprofile, nostrSettings.relays)
|
||||
}
|
||||
adminManager.setAppNprofile(appNprofile)
|
||||
const Server = NewServer(serverMethods, serverOptions(mainHandler))
|
||||
Server.Listen(mainSettings.servicePort)
|
||||
}
|
||||
start()
|
||||
|
|
@ -10,6 +10,7 @@ export class AdminManager {
|
|||
|
||||
|
||||
|
||||
|
||||
storage: Storage
|
||||
log = getLogger({ component: "adminManager" })
|
||||
adminNpub = ""
|
||||
|
|
@ -25,8 +26,8 @@ export class AdminManager {
|
|||
this.storage = storage
|
||||
this.dataDir = mainSettings.storageSettings.dataDir
|
||||
this.adminNpubPath = getDataPath(this.dataDir, 'admin.npub')
|
||||
this.adminEnrollTokenPath = getDataPath(this.dataDir, '.admin_enroll')
|
||||
this.adminConnectPath = getDataPath(this.dataDir, '.admin_connect')
|
||||
this.adminEnrollTokenPath = getDataPath(this.dataDir, 'admin.enroll')
|
||||
this.adminConnectPath = getDataPath(this.dataDir, 'admin.connect')
|
||||
this.appNprofilePath = getDataPath(this.dataDir, 'app.nprofile')
|
||||
this.start()
|
||||
}
|
||||
|
|
@ -145,6 +146,17 @@ export class AdminManager {
|
|||
}
|
||||
}
|
||||
|
||||
async LndGetInfo(): Promise<Types.LndGetInfoResponse> {
|
||||
const info = await this.lnd.GetInfo()
|
||||
return {
|
||||
alias: info.alias,
|
||||
synced_to_chain: info.syncedToChain,
|
||||
synced_to_graph: info.syncedToGraph,
|
||||
watchdog_barking: this.lnd.outgoingOpsLocked
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ListChannels = async (): Promise<Types.LndChannels> => {
|
||||
const { channels } = await this.lnd.ListChannels(true)
|
||||
const { identityPubkey } = await this.lnd.GetInfo()
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export default class Handler {
|
|||
const providers = await this.storage.liquidityStorage.GetTrackedProviders()
|
||||
let lndTotal = 0
|
||||
let providerTotal = 0
|
||||
console.log({ providers })
|
||||
providers.forEach(p => {
|
||||
if (p.provider_type === 'lnd') {
|
||||
lndTotal += p.latest_balance
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ export default (mainHandler: Main): Types.ServerMethods => {
|
|||
EncryptionExchange: async () => { },
|
||||
Health: async () => { await mainHandler.lnd.Health() },
|
||||
LndGetInfo: async ({ ctx }) => {
|
||||
const info = await mainHandler.lnd.GetInfo()
|
||||
return { alias: info.alias }
|
||||
return await mainHandler.adminManager.LndGetInfo()
|
||||
},
|
||||
BanUser: async ({ ctx, req }) => {
|
||||
const err = Types.BanUserRequestValidate(req, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue