makeChainForBench writes a given number of headers or empty blocks/receipts into a database.
(db database.Database, full bool, count uint64)
| 213 | // makeChainForBench writes a given number of headers or empty blocks/receipts |
| 214 | // into a database. |
| 215 | func makeChainForBench(db database.Database, full bool, count uint64) { |
| 216 | var hash common.Hash |
| 217 | for n := uint64(0); n < count; n++ { |
| 218 | header := &types.Header{ |
| 219 | Coinbase: common.Address{}, |
| 220 | Number: big.NewInt(int64(n)), |
| 221 | ParentHash: hash, |
| 222 | TxsRoot: types.EmptyRootHash, |
| 223 | ReceiptsRoot: types.EmptyRootHash, |
| 224 | } |
| 225 | hash = header.Hash() |
| 226 | |
| 227 | rawdb.WriteHeader(db, header) |
| 228 | rawdb.WriteCanonicalHash(db, hash, n) |
| 229 | |
| 230 | if full || n == 0 { |
| 231 | block := types.NewBlockWithHeader(header) |
| 232 | rawdb.WriteBody(db, hash, n, block.Body()) |
| 233 | rawdb.WriteReceipts(db, hash, n, nil) |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | func benchWriteChain(b *testing.B, full bool, count uint64) { |
| 239 | for i := 0; i < b.N; i++ { |
no test coverage detected