Skip to content

Commit 7adc312

Browse files
committed
small fixes
1 parent e281f2d commit 7adc312

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/components/core/handler/p2p.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,14 @@ export class GetP2PNetworkStatsHandler extends CommandHandler {
132132
const node = this.getOceanNode()
133133
const config = node.getConfig()
134134
if (config.p2pConfig.enableNetworkStats) {
135-
const stats = node.getP2PNode().getNetworkingStats()
135+
const p2pNode = node.getP2PNode()
136+
if (!p2pNode) {
137+
return {
138+
stream: null,
139+
status: { httpStatus: 503, error: 'P2P Interface is disabled' }
140+
}
141+
}
142+
const stats = p2pNode.getNetworkingStats()
136143
return {
137144
stream: Readable.from(JSON.stringify(stats)),
138145
status: { httpStatus: 200 }

src/utils/cronjobs/p2pAnnounceDDOS.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export async function p2pAnnounceDDOS(node: OceanNode) {
88
try {
99
const db = await node.getDatabase()
1010
const p2pNode = node.getP2PNode()
11-
if (!db || !db.ddo) {
11+
if (!db || !db.ddo || !p2pNode) {
1212
P2P_LOGGER.info(
13-
`republishStoredDDOS() attempt aborted because there is no database!`
13+
`republishStoredDDOS() attempt aborted because there is no database or P2P is not available!`
1414
)
1515
return
1616
}

0 commit comments

Comments
 (0)