11import Common from '@ethereumjs/common'
22import { Logger } from 'winston'
33import { defaultLogger } from './logging'
4+ import { Libp2pServer , RlpxServer } from './net/server'
45
56export interface Options {
67 /**
@@ -11,31 +12,37 @@ export interface Options {
1112 common ?: Common
1213 /**
1314 * The logger instance with the log level set (winston)
14- *
15+ *
1516 * Default: Logger with loglevel 'debug'
1617 */
1718 logger ?: Logger
19+ /**
20+ * Transport servers (RLPx or Libp2p)
21+ *
22+ * Default: []
23+ */
24+ servers ?: ( RlpxServer | Libp2pServer ) [ ]
1825 /**
1926 * Synchronization mode ('fast' or 'light')
20- *
27+ *
2128 * Default: 'fast'
2229 */
2330 syncmode ?: string
2431 /**
2532 * Serve light peer requests
26- *
33+ *
2734 * Default: false
2835 */
2936 lightserv ?: boolean
3037 /**
3138 * Number of peers needed before syncing
32- *
39+ *
3340 * Default: 2
3441 */
3542 minPeers ?: number
3643 /**
3744 * Maximum peers allowed
38- *
45+ *
3946 * Default: 25
4047 */
4148 maxPeers ?: number
@@ -44,19 +51,20 @@ export interface Options {
4451export class Config {
4552 public common : Common
4653 public logger : Logger
54+ public servers : ( RlpxServer | Libp2pServer ) [ ]
4755 public syncmode : string
4856 public lightserv : boolean
4957 public minPeers : number
5058 public maxPeers : number
5159
5260 public static readonly COMMON_DEFAULT = new Common ( { chain : 'mainnet' , hardfork : 'chainstart' } )
5361 public static readonly LOGGER_DEFAULT = defaultLogger
62+ public static readonly SERVERS_DEFAULT = [ ]
5463 public static readonly SYNCMODE_DEFAULT = 'fast'
5564 public static readonly LIGHTSERV_DEFAULT = false
5665 public static readonly MINPEERS_DEFAULT = 2
5766 public static readonly MAXPEERS_DEFAULT = 25
5867
59-
6068 constructor ( options : Options = { } ) {
6169 // Initialize Common with an explicit 'chainstart' HF set until
6270 // hardfork awareness is implemented within the library
@@ -65,6 +73,7 @@ export class Config {
6573 // TODO: map chainParams (and lib/util.parseParams) to new Common format
6674 this . common = options . common ? options . common : Config . COMMON_DEFAULT
6775 this . logger = options . logger ? options . logger : Config . LOGGER_DEFAULT
76+ this . servers = options . servers ? options . servers : Config . SERVERS_DEFAULT
6877 this . syncmode = options . syncmode ? options . syncmode : Config . SYNCMODE_DEFAULT
6978 this . lightserv = options . lightserv ? options . lightserv : Config . LIGHTSERV_DEFAULT
7079 this . minPeers = options . minPeers ? options . minPeers : Config . MINPEERS_DEFAULT
0 commit comments