@@ -37,7 +37,7 @@ func (r *RedundantStorageService) GetByHash(ctx context.Context, key common.Hash
3737 log .Trace ("das.RedundantStorageService.GetByHash" , "key" , pretty .PrettyHash (key ), "this" , r )
3838 subCtx , cancel := context .WithCancel (ctx )
3939 defer cancel ()
40- var anyError error
40+ var errs [] error
4141 responsesExpected := len (r .innerServices )
4242 resultChan := make (chan readResponse , responsesExpected )
4343 for _ , serv := range r .innerServices {
@@ -52,74 +52,74 @@ func (r *RedundantStorageService) GetByHash(ctx context.Context, key common.Hash
5252 if resp .err == nil {
5353 return resp .data , nil
5454 }
55- anyError = resp .err
55+ errs = append ( errs , resp .err )
5656 responsesExpected --
5757 case <- ctx .Done ():
5858 return nil , ctx .Err ()
5959 }
6060 }
61- return nil , anyError
61+ return nil , errors . Join ( errs ... )
6262}
6363
6464func (r * RedundantStorageService ) Put (ctx context.Context , data []byte , expirationTime uint64 ) error {
6565 logPut ("das.RedundantStorageService.Store" , data , expirationTime , r )
6666 var wg sync.WaitGroup
6767 var errorMutex sync.Mutex
68- var anyError error
68+ var errs [] error
6969 wg .Add (len (r .innerServices ))
7070 for _ , serv := range r .innerServices {
7171 go func (s StorageService ) {
7272 err := s .Put (ctx , data , expirationTime )
7373 if err != nil {
7474 errorMutex .Lock ()
75- anyError = err
75+ errs = append ( errs , err )
7676 errorMutex .Unlock ()
7777 }
7878 wg .Done ()
7979 }(serv )
8080 }
8181 wg .Wait ()
82- return anyError
82+ return errors . Join ( errs ... )
8383}
8484
8585func (r * RedundantStorageService ) Sync (ctx context.Context ) error {
8686 var wg sync.WaitGroup
8787 var errorMutex sync.Mutex
88- var anyError error
88+ var errs [] error
8989 wg .Add (len (r .innerServices ))
9090 for _ , serv := range r .innerServices {
9191 go func (s StorageService ) {
9292 err := s .Sync (ctx )
9393 if err != nil {
9494 errorMutex .Lock ()
95- anyError = err
95+ errs = append ( errs , err )
9696 errorMutex .Unlock ()
9797 }
9898 wg .Done ()
9999 }(serv )
100100 }
101101 wg .Wait ()
102- return anyError
102+ return errors . Join ( errs ... )
103103}
104104
105105func (r * RedundantStorageService ) Close (ctx context.Context ) error {
106106 var wg sync.WaitGroup
107107 var errorMutex sync.Mutex
108- var anyError error
108+ var errs [] error
109109 wg .Add (len (r .innerServices ))
110110 for _ , serv := range r .innerServices {
111111 go func (s StorageService ) {
112112 err := s .Close (ctx )
113113 if err != nil {
114114 errorMutex .Lock ()
115- anyError = err
115+ errs = append ( errs , err )
116116 errorMutex .Unlock ()
117117 }
118118 wg .Done ()
119119 }(serv )
120120 }
121121 wg .Wait ()
122- return anyError
122+ return errors . Join ( errs ... )
123123}
124124
125125func (r * RedundantStorageService ) ExpirationPolicy (ctx context.Context ) (dasutil.ExpirationPolicy , error ) {
0 commit comments