@@ -325,15 +325,16 @@ def write_to_file(self):
325325 with open (file_name , "w" , encoding = "utf-8" ) as f : # overwrite existing
326326 f .write (json_str )
327327
328- def read_from_file (self ) -> "Blob" :
329- """Read a .json file and reconstruct object it represents."""
330- # TODO: file_name should match location defined in write_to_file
331- file_name : str = self .name + ".json"
332- with open (file_name , "r" , encoding = "utf-8" ) as f :
333- json_str : str = f .read ()
334328
335- # reconstruct object
336- return Blob .model_validate_json (json_str )
329+ def LoadBlobFromFile (seed : int ) -> Blob :
330+ """Read a .json file and reconstruct object it represents."""
331+ # TODO: file_name should match location defined in write_to_file
332+ file_name : str = "blob_" + str (seed ) + ".json"
333+ with open (file_name , "r" , encoding = "utf-8" ) as f :
334+ json_str : str = f .read ()
335+
336+ # reconstruct object
337+ return Blob .model_validate_json (json_str )
337338
338339
339340def NewBlob (fork : str , seed : int = 0 , timestamp : int = 0 ) -> Blob :
@@ -437,7 +438,7 @@ def get_cells(data: Bytes) -> List[Bytes] | None:
437438assert b .timestamp == restored .timestamp
438439
439440b .write_to_file ()
440- c : Blob = NewBlob ( "prague" , 1337 ). read_from_file ( ) # annoying: have to put dummy value for fork
441+ c : Blob = LoadBlobFromFile ( 1337 ) # annoying: have to put dummy value for fork
441442assert b .data == c .data
442443assert b .commitment == c .commitment
443444assert b .proof == c .proof
0 commit comments