@@ -128,6 +128,12 @@ func (s *Store) put(
128
128
return err
129
129
}
130
130
131
+ // ensure the blocks hash directory exists
132
+ blocksHashDir := filepath .Join (s .basepath , blocksPath , datahash .String ()[:2 ])
133
+ if err := mkdir (blocksHashDir ); err != nil {
134
+ return fmt .Errorf ("ensuring blocks hash directory: %w" , err )
135
+ }
136
+
131
137
// put to cache before writing to make it accessible while write is happening
132
138
accessor := & eds.Rsmt2D {ExtendedDataSquare : square }
133
139
acc , err := s .cache .GetOrLoad (ctx , height , accessorLoader (accessor ))
@@ -319,6 +325,12 @@ func (s *Store) populateEmptyFile() error {
319
325
return fmt .Errorf ("cleaning old empty EDS file: %w" , err )
320
326
}
321
327
328
+ // ensure the blocks hash directory exists
329
+ blocksHashDir := filepath .Join (s .basepath , blocksPath , share .EmptyEDSDataHash ().String ()[:2 ])
330
+ if err := mkdir (blocksHashDir ); err != nil {
331
+ return fmt .Errorf ("ensuring blocks hash directory: %w" , err )
332
+ }
333
+
322
334
err = file .CreateODSQ4 (pathOds , pathQ4 , share .EmptyEDSRoots (), eds .EmptyAccessor .ExtendedDataSquare )
323
335
if err != nil {
324
336
return fmt .Errorf ("creating fresh empty EDS file: %w" , err )
@@ -514,11 +526,11 @@ func (s *Store) removeQ4(height uint64, datahash share.DataHash) error {
514
526
}
515
527
516
528
func (s * Store ) hashToPath (datahash share.DataHash , ext string ) string {
517
- return filepath .Join (s .basepath , blocksPath , datahash .String ()) + ext
529
+ return filepath .Join (s .basepath , blocksPath , datahash .String ()[: 2 ], datahash . String () ) + ext
518
530
}
519
531
520
532
func (s * Store ) hashToRelativePath (datahash share.DataHash , ext string ) string {
521
- return filepath .Join (".." , datahash .String ()) + ext
533
+ return filepath .Join (".." , datahash .String ()[: 2 ], datahash . String () ) + ext
522
534
}
523
535
524
536
func (s * Store ) heightToPath (height uint64 , ext string ) string {
0 commit comments