mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
remove setupRangeDB
This commit is contained in:
parent
23075fdcac
commit
79d33f3cc5
1 changed files with 0 additions and 38 deletions
|
|
@ -15,41 +15,3 @@
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package rawdb
|
package rawdb
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"crypto/rand"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setupRangeDB(b *testing.B, db ethdb.KeyValueStore, numEntries int) ([]byte, []byte) {
|
|
||||||
b.Helper()
|
|
||||||
var firstKey, lastKey []byte
|
|
||||||
for i := 0; i < numEntries; i++ {
|
|
||||||
key := make([]byte, 32)
|
|
||||||
val := make([]byte, 64)
|
|
||||||
if _, err := rand.Read(key); err != nil {
|
|
||||||
b.Fatalf("Failed to generate random key: %v", err)
|
|
||||||
}
|
|
||||||
if _, err := rand.Read(val); err != nil {
|
|
||||||
b.Fatalf("Failed to generate random value: %v", err)
|
|
||||||
}
|
|
||||||
hashKey := crypto.Keccak256Hash(key)
|
|
||||||
if err := db.Put(hashKey.Bytes(), val); err != nil {
|
|
||||||
b.Fatalf("Failed to put data: %v", err)
|
|
||||||
}
|
|
||||||
if i == 0 {
|
|
||||||
firstKey = hashKey.Bytes()
|
|
||||||
}
|
|
||||||
if i == numEntries-1 {
|
|
||||||
lastKey = hashKey.Bytes()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if bytes.Compare(firstKey, lastKey) > 0 {
|
|
||||||
firstKey, lastKey = lastKey, firstKey
|
|
||||||
}
|
|
||||||
return firstKey, append(lastKey, 0) // append 0 to make range exclusive for lastKey
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue