(storConfig storage.StorageConfig)
| 208 | } |
| 209 | |
| 210 | func 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 | |
| 232 | func fillEmpty(storageMgr *ethstorage.StorageManager, shards []uint64) error { |
| 233 | start := shards[0] * storageMgr.KvEntries() |
no test coverage detected