@@ -70,6 +70,21 @@ pub struct BootstrapNode {
70
70
addr : String ,
71
71
}
72
72
73
+ impl BootstrapNode {
74
+ /// Resolve string address of the node to possible multiple `SocketAddr`s.
75
+ pub fn resolve ( & self ) -> impl Iterator < Item = PackedNode > {
76
+ let pk = self . pk ;
77
+ let addrs = match self . addr . to_socket_addrs ( ) {
78
+ Ok ( addrs) => addrs,
79
+ Err ( e) => {
80
+ warn ! ( "Failed to resolve bootstrap node address '{}': {}" , self . addr, e) ;
81
+ Vec :: new ( ) . into_iter ( )
82
+ } ,
83
+ } ;
84
+ addrs. map ( move |addr| PackedNode :: new ( addr, & pk) )
85
+ }
86
+ }
87
+
73
88
fn de_from_hex < ' de , D > ( deserializer : D ) -> Result < PublicKey , D :: Error > where D : Deserializer < ' de > {
74
89
let s = String :: deserialize ( deserializer) ?;
75
90
@@ -79,43 +94,13 @@ fn de_from_hex<'de, D>(deserializer: D) -> Result<PublicKey, D::Error> where D:
79
94
. ok_or_else ( || de:: Error :: custom ( "Can't make PublicKey" ) )
80
95
}
81
96
82
- // TODO: Remove this function. Use default String type after bug fix released.
83
- // Bug is here `https://github.com/mehcode/config-rs/issues/74`
84
- fn de_log_type < ' de , D > ( deserializer : D ) -> Result < LogType , D :: Error > where D : Deserializer < ' de > {
85
- let s = String :: deserialize ( deserializer) ?;
86
-
87
- match & s[ ..] {
88
- "Stderr" => Ok ( LogType :: Stderr ) ,
89
- "Stdout" => Ok ( LogType :: Stdout ) ,
90
- #[ cfg( unix) ]
91
- "Syslog" => Ok ( LogType :: Syslog ) ,
92
- "None" => Ok ( LogType :: None ) ,
93
- other => Err ( de:: Error :: custom ( format ! ( "log-type: invalid value '{}'" , other) ) ) ,
94
- }
95
- }
96
-
97
97
fn de_threads < ' de , D > ( deserializer : D ) -> Result < Threads , D :: Error > where D : Deserializer < ' de > {
98
98
let s = String :: deserialize ( deserializer) ?;
99
99
100
100
Threads :: from_str ( & s)
101
101
. map_err ( |e| de:: Error :: custom ( format ! ( "threads: {:?}" , e) ) )
102
102
}
103
103
104
- impl BootstrapNode {
105
- /// Resolve string address of the node to possible multiple `SocketAddr`s.
106
- pub fn resolve ( & self ) -> impl Iterator < Item = PackedNode > {
107
- let pk = self . pk ;
108
- let addrs = match self . addr . to_socket_addrs ( ) {
109
- Ok ( addrs) => addrs,
110
- Err ( e) => {
111
- warn ! ( "Failed to resolve bootstrap node address '{}': {}" , self . addr, e) ;
112
- Vec :: new ( ) . into_iter ( )
113
- } ,
114
- } ;
115
- addrs. map ( move |addr| PackedNode :: new ( addr, & pk) )
116
- }
117
- }
118
-
119
104
/// Config parsed from command line arguments.
120
105
#[ derive( Clone , PartialEq , Eq , Debug , Deserialize ) ]
121
106
pub struct NodeConfig {
@@ -147,7 +132,6 @@ pub struct NodeConfig {
147
132
#[ serde( deserialize_with = "de_threads" ) ]
148
133
pub threads : Threads ,
149
134
/// Specifies where to write logs.
150
- #[ serde( deserialize_with = "de_log_type" ) ]
151
135
#[ serde( rename = "log-type" ) ]
152
136
pub log_type : LogType ,
153
137
/// Message of the day
0 commit comments