@@ -12,67 +12,81 @@ import scala.concurrent.duration._
12
12
13
13
case class LoggingSettings (level : String )
14
14
15
- case class RESTApiSettings (bindAddress : InetSocketAddress ,
16
- apiKeyHash : Option [String ],
17
- corsAllowedOrigin : Option [String ],
18
- timeout : FiniteDuration ,
19
- publicUrl : Option [URL ])
15
+ case class RESTApiSettings (
16
+ bindAddress : InetSocketAddress ,
17
+ apiKeyHash : Option [String ],
18
+ corsAllowedOrigin : Option [String ],
19
+ timeout : FiniteDuration ,
20
+ publicUrl : Option [URL ]
21
+ )
20
22
21
- case class NetworkSettings (nodeName : String ,
22
- addedMaxDelay : Option [FiniteDuration ],
23
- localOnly : Boolean ,
24
- knownPeers : Seq [InetSocketAddress ],
25
- bindAddress : InetSocketAddress ,
26
- maxConnections : Int ,
27
- connectionTimeout : FiniteDuration ,
28
- upnpEnabled : Boolean ,
29
- upnpGatewayTimeout : Option [FiniteDuration ],
30
- upnpDiscoverTimeout : Option [FiniteDuration ],
31
- declaredAddress : Option [InetSocketAddress ],
32
- handshakeTimeout : FiniteDuration ,
33
- deliveryTimeout : FiniteDuration ,
34
- maxDeliveryChecks : Int ,
35
- appVersion : String ,
36
- agentName : String ,
37
- desiredInvObjects : Int ,
38
- syncInterval : FiniteDuration ,
39
- syncStatusRefresh : FiniteDuration ,
40
- syncIntervalStable : FiniteDuration ,
41
- syncStatusRefreshStable : FiniteDuration ,
42
- inactiveConnectionDeadline : FiniteDuration ,
43
- syncTimeout : Option [FiniteDuration ],
44
- controllerTimeout : Option [FiniteDuration ],
45
- maxModifiersCacheSize : Int ,
46
- magicBytes : Array [Byte ],
47
- getPeersInterval : FiniteDuration ,
48
- maxPeerSpecObjects : Int ,
49
- temporalBanDuration : FiniteDuration ,
50
- penaltySafeInterval : FiniteDuration ,
51
- penaltyScoreThreshold : Int ,
52
- peerEvictionInterval : FiniteDuration ,
53
- peerDiscovery : Boolean )
54
-
55
- case class ScorexSettings (dataDir : File ,
56
- logDir : File ,
57
- logging : LoggingSettings ,
58
- network : NetworkSettings ,
59
- restApi : RESTApiSettings )
23
+ case class NetworkSettings (
24
+ nodeName : String ,
25
+ addedMaxDelay : Option [FiniteDuration ],
26
+ localOnly : Boolean ,
27
+ knownPeers : Seq [InetSocketAddress ],
28
+ bannedPeers : Seq [InetSocketAddress ],
29
+ bindAddress : InetSocketAddress ,
30
+ maxConnections : Int ,
31
+ connectionTimeout : FiniteDuration ,
32
+ upnpEnabled : Boolean ,
33
+ upnpGatewayTimeout : Option [FiniteDuration ],
34
+ upnpDiscoverTimeout : Option [FiniteDuration ],
35
+ declaredAddress : Option [InetSocketAddress ],
36
+ handshakeTimeout : FiniteDuration ,
37
+ deliveryTimeout : FiniteDuration ,
38
+ maxDeliveryChecks : Int ,
39
+ appVersion : String ,
40
+ agentName : String ,
41
+ desiredInvObjects : Int ,
42
+ syncInterval : FiniteDuration ,
43
+ syncStatusRefresh : FiniteDuration ,
44
+ syncIntervalStable : FiniteDuration ,
45
+ syncStatusRefreshStable : FiniteDuration ,
46
+ inactiveConnectionDeadline : FiniteDuration ,
47
+ syncTimeout : Option [FiniteDuration ],
48
+ controllerTimeout : Option [FiniteDuration ],
49
+ maxModifiersCacheSize : Int ,
50
+ magicBytes : Array [Byte ],
51
+ getPeersInterval : FiniteDuration ,
52
+ maxPeerSpecObjects : Int ,
53
+ temporalBanDuration : FiniteDuration ,
54
+ penaltySafeInterval : FiniteDuration ,
55
+ penaltyScoreThreshold : Int ,
56
+ peerEvictionInterval : FiniteDuration ,
57
+ peerDiscovery : Boolean
58
+ )
60
59
60
+ case class ScorexSettings (
61
+ dataDir : File ,
62
+ logDir : File ,
63
+ logging : LoggingSettings ,
64
+ network : NetworkSettings ,
65
+ restApi : RESTApiSettings
66
+ )
61
67
62
68
object ScorexSettings extends ScorexLogging with SettingsReaders {
63
69
64
70
protected val configPath : String = " scorex"
65
71
66
72
def readConfigFromPath (userConfigPath : Option [String ], configPath : String ): Config = {
67
73
68
- val maybeConfigFile : Option [File ] = userConfigPath.map(filename => new File (filename)).filter(_.exists())
69
- .orElse(userConfigPath.flatMap(filename => Option (getClass.getClassLoader.getResource(filename))).
70
- map(r => new File (r.toURI)).filter(_.exists()))
74
+ val maybeConfigFile : Option [File ] = userConfigPath
75
+ .map(filename => new File (filename))
76
+ .filter(_.exists())
77
+ .orElse(
78
+ userConfigPath
79
+ .flatMap(filename => Option (getClass.getClassLoader.getResource(filename)))
80
+ .map(r => new File (r.toURI))
81
+ .filter(_.exists())
82
+ )
71
83
72
84
val config = maybeConfigFile match {
73
85
// if no user config is supplied, the library will handle overrides/application/reference automatically
74
86
case None =>
75
- log.warn(" NO CONFIGURATION FILE WAS PROVIDED. STARTING WITH DEFAULT SETTINGS FOR TESTNET!" )
87
+ log.warn(
88
+ " NO CONFIGURATION FILE WAS PROVIDED. STARTING WITH DEFAULT SETTINGS FOR TESTNET!"
89
+ )
76
90
ConfigFactory .load()
77
91
// application config needs to be resolved wrt both system properties *and* user-supplied config.
78
92
case Some (file) =>
@@ -96,7 +110,8 @@ object ScorexSettings extends ScorexLogging with SettingsReaders {
96
110
}
97
111
98
112
def fromConfig (config : Config ): ScorexSettings = {
99
- config.as[ScorexSettings ](configPath)
113
+ config
114
+ .as[ScorexSettings ](configPath)
100
115
.ensuring(_.network.magicBytes.length == MagicLength )
101
116
}
102
117
}
0 commit comments