@@ -19,19 +19,21 @@ use std::fmt;
1919use cjson;
2020use ckey:: Address ;
2121use cstate:: ShardMetadata ;
22- use ctypes:: ShardId ;
2322use rlp:: { Encodable , RlpStream } ;
2423
24+ use super :: pod_world:: PodWorld ;
25+
2526#[ derive( Clone , Debug , Eq , PartialEq ) ]
2627pub struct PodShardMetadata {
2728 pub owner : Address ,
28- pub number_of_worlds : ShardId ,
2929 pub nonce : u64 ,
30+ pub worlds : Vec < PodWorld > ,
3031}
3132
3233impl < ' a > Into < ShardMetadata > for & ' a PodShardMetadata {
3334 fn into ( self ) -> ShardMetadata {
34- ShardMetadata :: new_with_nonce ( self . number_of_worlds , self . nonce )
35+ assert ! ( self . worlds. len( ) <= :: std:: u16 :: MAX as usize ) ;
36+ ShardMetadata :: new_with_nonce ( self . worlds . len ( ) as u16 , self . nonce )
3537 }
3638}
3739
@@ -45,15 +47,15 @@ impl Encodable for PodShardMetadata {
4547impl From < cjson:: spec:: Shard > for PodShardMetadata {
4648 fn from ( s : cjson:: spec:: Shard ) -> Self {
4749 Self {
48- number_of_worlds : 0 ,
4950 nonce : s. nonce . map ( Into :: into) . unwrap_or ( 0 ) ,
5051 owner : s. owner ,
52+ worlds : s. worlds . unwrap_or_else ( Vec :: new) . into_iter ( ) . map ( Into :: into) . collect ( ) ,
5153 }
5254 }
5355}
5456
5557impl fmt:: Display for PodShardMetadata {
5658 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
57- write ! ( f, "(#wordls ={}; nonce ={}; owner={ })" , self . number_of_worlds , self . nonce , self . owner )
59+ write ! ( f, "(#nonce ={}; owner ={}; worlds={:#? })" , self . nonce , self . owner , self . worlds )
5860 }
5961}
0 commit comments