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

Function initShardManager

integration_tests/node_mine_test.go:210–230  ·  view source on GitHub ↗
(storConfig storage.StorageConfig)

Source from the content-addressed store, hash-verified

208}
209
210func initShardManager(storConfig storage.StorageConfig) (*ethstorage.ShardManager, error) {
211 shardManager := ethstorage.NewShardManager(storConfig.L1Contract, storConfig.KvSize, storConfig.KvEntriesPerShard, storConfig.ChunkSize)
212 for _, filename := range storConfig.Filenames {
213 var err error
214 var df *ethstorage.DataFile
215 df, err = ethstorage.OpenDataFile(filename)
216 if err != nil {
217 return nil, fmt.Errorf("open failed: %w", err)
218 }
219 if df.Miner() != storConfig.Miner {
220 lg.Error("Miners mismatch", "fromDataFile", df.Miner(), "fromConfig", storConfig.Miner)
221 return nil, fmt.Errorf("miner mismatches datafile")
222 }
223 shardManager.AddDataFileAndShard(df)
224 }
225
226 if shardManager.IsComplete() != nil {
227 return nil, fmt.Errorf("shard is not completed")
228 }
229 return shardManager, nil
230}
231
232func fillEmpty(storageMgr *ethstorage.StorageManager, shards []uint64) error {
233 start := shards[0] * storageMgr.KvEntries()

Callers 1

TestMiningFunction · 0.70

Calls 6

MinerMethod · 0.95
AddDataFileAndShardMethod · 0.95
IsCompleteMethod · 0.95
NewShardManagerFunction · 0.92
OpenDataFileFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected