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

Function createDataFiles

integration_tests/node_mine_test.go:330–357  ·  view source on GitHub ↗
(cfg *storage.StorageConfig, shardIds []uint64)

Source from the content-addressed store, hash-verified

328}
329
330func createDataFiles(cfg *storage.StorageConfig, shardIds []uint64) ([]string, error) {
331 var files []string
332 for _, shardIdx := range shardIds {
333 fileName := filepath.Join(datadir, fmt.Sprintf(dataFileName, shardIdx))
334 if _, err := os.Stat(fileName); err == nil {
335 lg.Warn("Creating data file: file already exists, will be overwritten", "file", fileName)
336 }
337 if cfg.ChunkSize == 0 {
338 lg.Crit("Creating data file", "error", "chunk size should not be 0")
339 }
340 if cfg.KvSize%cfg.ChunkSize != 0 {
341 lg.Crit("Creating data file", "error", "max kv size %% chunk size should be 0")
342 }
343 chunkPerKv := cfg.KvSize / cfg.ChunkSize
344 startChunkId := shardIdx * cfg.KvEntriesPerShard * chunkPerKv
345 chunkIdxLen := chunkPerKv * cfg.KvEntriesPerShard
346 lg.Info("Creating data file", "chunkIdxStart", startChunkId, "chunkIdxLen", chunkIdxLen, "chunkSize", cfg.ChunkSize, "miner", cfg.Miner, "encodeType", ethstorage.ENCODE_BLOB_POSEIDON)
347
348 df, err := ethstorage.Create(fileName, startChunkId, chunkPerKv*cfg.KvEntriesPerShard, 0, cfg.KvSize, ethstorage.ENCODE_BLOB_POSEIDON, cfg.Miner, cfg.ChunkSize)
349 if err != nil {
350 lg.Crit("Creating data file", "error", err)
351 }
352
353 lg.Info("Data file created", "shard", shardIdx, "file", fileName, "datafile", fmt.Sprintf("%+v", df))
354 files = append(files, fileName)
355 }
356 return files, nil
357}
358
359func initMiningConfig(t *testing.T, client *eth.PollingClient) *miner.Config {
360 miningConfig := &miner.Config{}

Callers 1

TestMiningFunction · 0.85

Calls 1

CreateFunction · 0.92

Tested by

no test coverage detected