@@ -80,7 +80,7 @@ impl<'a, G: RuntimeGenesis, E> BuildStorage for &'a ChainSpec<G, E> {
8080 let child_info = ChildInfo :: resolve_child_info (
8181 child_content. child_type ,
8282 child_content. child_info . as_slice ( ) ,
83- ) . expect ( "chainspec contains correct content" ) . to_owned ( ) ;
83+ ) . expect ( "chain spec contains correct content" ) . to_owned ( ) ;
8484 (
8585 sk. 0 ,
8686 StorageChild {
@@ -129,10 +129,11 @@ enum Genesis<G> {
129129 Raw ( RawGenesis ) ,
130130}
131131
132+ /// A configuration of a client. Does not include runtime storage initialization.
132133#[ derive( Serialize , Deserialize , Clone , Debug ) ]
133134#[ serde( rename_all = "camelCase" ) ]
134135#[ serde( deny_unknown_fields) ]
135- struct ChainSpecFile < E > {
136+ struct ClientSpec < E > {
136137 pub name : String ,
137138 pub id : String ,
138139 pub boot_nodes : Vec < String > ,
@@ -157,14 +158,14 @@ pub type NoExtension = Option<()>;
157158
158159/// A configuration of a chain. Can be used to build a genesis block.
159160pub struct ChainSpec < G , E = NoExtension > {
160- spec : ChainSpecFile < E > ,
161+ client_spec : ClientSpec < E > ,
161162 genesis : GenesisSource < G > ,
162163}
163164
164165impl < G , E : Clone > Clone for ChainSpec < G , E > {
165166 fn clone ( & self ) -> Self {
166167 ChainSpec {
167- spec : self . spec . clone ( ) ,
168+ client_spec : self . client_spec . clone ( ) ,
168169 genesis : self . genesis . clone ( ) ,
169170 }
170171 }
@@ -173,44 +174,44 @@ impl<G, E: Clone> Clone for ChainSpec<G, E> {
173174impl < G , E > ChainSpec < G , E > {
174175 /// A list of bootnode addresses.
175176 pub fn boot_nodes ( & self ) -> & [ String ] {
176- & self . spec . boot_nodes
177+ & self . client_spec . boot_nodes
177178 }
178179
179180 /// Spec name.
180181 pub fn name ( & self ) -> & str {
181- & self . spec . name
182+ & self . client_spec . name
182183 }
183184
184185 /// Spec id.
185186 pub fn id ( & self ) -> & str {
186- & self . spec . id
187+ & self . client_spec . id
187188 }
188189
189190 /// Telemetry endpoints (if any)
190191 pub fn telemetry_endpoints ( & self ) -> & Option < TelemetryEndpoints > {
191- & self . spec . telemetry_endpoints
192+ & self . client_spec . telemetry_endpoints
192193 }
193194
194195 /// Network protocol id.
195196 pub fn protocol_id ( & self ) -> Option < & str > {
196- self . spec . protocol_id . as_ref ( ) . map ( String :: as_str)
197+ self . client_spec . protocol_id . as_ref ( ) . map ( String :: as_str)
197198 }
198199
199200 /// Additional loosly-typed properties of the chain.
200201 ///
201202 /// Returns an empty JSON object if 'properties' not defined in config
202203 pub fn properties ( & self ) -> Properties {
203- self . spec . properties . as_ref ( ) . unwrap_or ( & json:: map:: Map :: new ( ) ) . clone ( )
204+ self . client_spec . properties . as_ref ( ) . unwrap_or ( & json:: map:: Map :: new ( ) ) . clone ( )
204205 }
205206
206207 /// Add a bootnode to the list.
207208 pub fn add_boot_node ( & mut self , addr : Multiaddr ) {
208- self . spec . boot_nodes . push ( addr. to_string ( ) )
209+ self . client_spec . boot_nodes . push ( addr. to_string ( ) )
209210 }
210211
211212 /// Returns a reference to defined chain spec extensions.
212213 pub fn extensions ( & self ) -> & E {
213- & self . spec . extensions
214+ & self . client_spec . extensions
214215 }
215216
216217 /// Create hardcoded spec.
@@ -224,7 +225,7 @@ impl<G, E> ChainSpec<G, E> {
224225 properties : Option < Properties > ,
225226 extensions : E ,
226227 ) -> Self {
227- let spec = ChainSpecFile {
228+ let client_spec = ClientSpec {
228229 name : name. to_owned ( ) ,
229230 id : id. to_owned ( ) ,
230231 boot_nodes : boot_nodes,
@@ -237,7 +238,7 @@ impl<G, E> ChainSpec<G, E> {
237238 } ;
238239
239240 ChainSpec {
240- spec ,
241+ client_spec ,
241242 genesis : GenesisSource :: Factory ( Rc :: new ( constructor) ) ,
242243 }
243244 }
@@ -247,10 +248,10 @@ impl<G, E: serde::de::DeserializeOwned> ChainSpec<G, E> {
247248 /// Parse json content into a `ChainSpec`
248249 pub fn from_json_bytes ( json : impl Into < Cow < ' static , [ u8 ] > > ) -> Result < Self , String > {
249250 let json = json. into ( ) ;
250- let spec = json:: from_slice ( json. as_ref ( ) )
251+ let client_spec = json:: from_slice ( json. as_ref ( ) )
251252 . map_err ( |e| format ! ( "Error parsing spec file: {}" , e) ) ?;
252253 Ok ( ChainSpec {
253- spec ,
254+ client_spec ,
254255 genesis : GenesisSource :: Binary ( json) ,
255256 } )
256257 }
@@ -259,10 +260,10 @@ impl<G, E: serde::de::DeserializeOwned> ChainSpec<G, E> {
259260 pub fn from_json_file ( path : PathBuf ) -> Result < Self , String > {
260261 let file = File :: open ( & path)
261262 . map_err ( |e| format ! ( "Error opening spec file: {}" , e) ) ?;
262- let spec = json:: from_reader ( file)
263+ let client_spec = json:: from_reader ( file)
263264 . map_err ( |e| format ! ( "Error parsing spec file: {}" , e) ) ?;
264265 Ok ( ChainSpec {
265- spec ,
266+ client_spec ,
266267 genesis : GenesisSource :: File ( path) ,
267268 } )
268269 }
@@ -274,7 +275,7 @@ impl<G: RuntimeGenesis, E: serde::Serialize> ChainSpec<G, E> {
274275 #[ derive( Serialize , Deserialize ) ]
275276 struct Container < G , E > {
276277 #[ serde( flatten) ]
277- spec : ChainSpecFile < E > ,
278+ client_spec : ClientSpec < E > ,
278279 genesis : Genesis < G > ,
279280
280281 } ;
@@ -304,11 +305,11 @@ impl<G: RuntimeGenesis, E: serde::Serialize> ChainSpec<G, E> {
304305 } ,
305306 ( _, genesis) => genesis,
306307 } ;
307- let spec = Container {
308- spec : self . spec ,
308+ let container = Container {
309+ client_spec : self . client_spec ,
309310 genesis,
310311 } ;
311- json:: to_string_pretty ( & spec )
312+ json:: to_string_pretty ( & container )
312313 . map_err ( |e| format ! ( "Error generating spec json: {}" , e) )
313314 }
314315}
0 commit comments