Skip to content

Commit 518eaea

Browse files
client: ensure dataDir exists before writing nodeKey
1 parent a098920 commit 518eaea

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/client/lib/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ export class Config {
282282
if (option !== undefined) return option
283283
return this.chainCommon.chainName() === 'mainnet'
284284
}
285-
285+
286286
getNetworkDir(): string {
287287
const networkDirName = this.common.chainName()
288288
const dataDir = `${this.datadir}/${networkDirName}`

packages/client/lib/net/server/rlpxserver.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { randomBytes } from 'crypto'
22
import { RLPx as Devp2pRLPx, Peer as Devp2pRLPxPeer, DPT as Devp2pDPT } from '@ethereumjs/devp2p'
33
import { RlpxPeer } from '../peer/rlpxpeer'
44
import { Server, ServerOptions } from './server'
5-
import fs from 'fs'
5+
const fs = require('fs-extra')
66

77
export interface RlpxServerOptions extends ServerOptions {
88
/* Local port to listen on (default: 30303) */
@@ -73,6 +73,7 @@ export class RlpxServer extends Server {
7373
} else {
7474
const key = randomBytes(32)
7575
this.key = key
76+
fs.ensureDirSync(dataDir)
7677
fs.writeFileSync(fileName, key.toString('binary'), {
7778
encoding: 'binary',
7879
})

0 commit comments

Comments
 (0)