makeKVStorage generate a range of storage Data and its metadata
(contract common.Address, shards []uint64, chunkSize, kvSize, kvCount, lastKvIndex uint64, miner common.Address, encodeType uint64, metafile *os.File)
| 215 | |
| 216 | // makeKVStorage generate a range of storage Data and its metadata |
| 217 | func makeKVStorage(contract common.Address, shards []uint64, chunkSize, kvSize, kvCount, lastKvIndex uint64, |
| 218 | miner common.Address, encodeType uint64, metafile *os.File) map[common.Address]map[uint64]*BlobPayloadWithRowData { |
| 219 | shardData := make(map[common.Address]map[uint64]*BlobPayloadWithRowData) |
| 220 | smData := make(map[uint64]*BlobPayloadWithRowData) |
| 221 | shardData[contract] = smData |
| 222 | sm := ethstorage.ContractToShardManager[contract] |
| 223 | |
| 224 | for _, sidx := range shards { |
| 225 | for i := sidx * kvCount; i < (sidx+1)*kvCount; i++ { |
| 226 | val := make([]byte, kvSize) |
| 227 | root := common.Hash{} |
| 228 | if i < lastKvIndex { |
| 229 | copy(val[:20], contract.Bytes()) |
| 230 | binary.BigEndian.PutUint64(val[20:28], i) |
| 231 | root, _ = prover.GetRoot(val, kvSize/chunkSize, chunkSize) |
| 232 | } |
| 233 | |
| 234 | commit := generateMetadata(root) |
| 235 | encodeData, _, _ := sm.EncodeKV(i, val, commit, miner, encodeType) |
| 236 | smData[i] = &BlobPayloadWithRowData{ |
| 237 | MinerAddress: miner, |
| 238 | BlobIndex: i, |
| 239 | BlobCommit: commit, |
| 240 | EncodeType: encodeType, |
| 241 | EncodedBlob: encodeData, |
| 242 | RowData: val, |
| 243 | } |
| 244 | meta := GenerateMetadata(i, kvSize, root[:]) |
| 245 | metafile.WriteAt(meta.Bytes(), int64(i*32)) |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | return shardData |
| 250 | } |
| 251 | |
| 252 | func fillEmpty(sm *ethstorage.ShardManager, list map[uint64]struct{}) { |
| 253 | commit := common.Hash{} |
no test coverage detected