MCPcopy Create free account
hub / github.com/ethstorage/es-node / DownloadAllMetas

Method DownloadAllMetas

ethstorage/storage_manager.go:383–412  ·  view source on GitHub ↗

DownloadAllMetas This function download the blob hashes of all the local storage shards from the smart contract

(ctx context.Context, batchSize uint64)

Source from the content-addressed store, hash-verified

381
382// DownloadAllMetas This function download the blob hashes of all the local storage shards from the smart contract
383func (s *StorageManager) DownloadAllMetas(ctx context.Context, batchSize uint64) error {
384 s.mu.Lock()
385 kvEntryCount := s.kvEntryCount
386 s.mu.Unlock()
387
388 for _, sid := range s.Shards() {
389 first, limit := s.KvEntries()*sid, s.KvEntries()*(sid+1)
390
391 // batch request metas until the kvEntryCount
392 end := min(limit, kvEntryCount)
393
394 // Additional check to ensure end is not less than first
395 // E.g. There are more than one shard, and kvEntryCount is even less than the first of the current shard
396 if end < first {
397 continue
398 }
399
400 s.lg.Info("Begin to download metas", "shard", sid, "first", first, "end", end, "limit", limit, "kvEntryCount", kvEntryCount)
401 ts := time.Now()
402
403 err := s.downloadMetaInParallel(ctx, first, end, batchSize)
404 if err != nil {
405 return err
406 }
407
408 s.lg.Info("All the metas has been downloaded", "first", first, "end", end, "time", time.Since(ts).Seconds())
409 }
410
411 return nil
412}
413
414func (s *StorageManager) downloadMetaInParallel(ctx context.Context, from, to, batchSize uint64) error {
415 var wg sync.WaitGroup

Callers

nothing calls this directly

Calls 3

ShardsMethod · 0.95
KvEntriesMethod · 0.95

Tested by

no test coverage detected