use statediff indexer config; other nits
This commit is contained in:
parent
4695984e1d
commit
4a4ae2f2ea
@ -16,22 +16,28 @@
|
|||||||
|
|
||||||
package shared
|
package shared
|
||||||
|
|
||||||
import "github.com/jmoiron/sqlx"
|
import (
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
|
||||||
/*
|
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
||||||
Hostname: "localhost",
|
)
|
||||||
Port: 8077,
|
|
||||||
DatabaseName: "cerc_testing",
|
var (
|
||||||
Username: "vdbm",
|
testDBConfig, _ = postgres.Config{
|
||||||
Password: "password",
|
Hostname: "localhost",
|
||||||
*/
|
DatabaseName: "cerc_testing",
|
||||||
|
Username: "vdbm",
|
||||||
|
Password: "password",
|
||||||
|
Port: 8077,
|
||||||
|
Driver: "SQLX",
|
||||||
|
}.WithEnv()
|
||||||
|
)
|
||||||
|
|
||||||
// TestDB connect to the testing database
|
// TestDB connect to the testing database
|
||||||
// it assumes the database has the IPFS ipld.blocks table present
|
// it assumes the database has the IPFS ipld.blocks table present
|
||||||
// DO NOT use a production db for the test db, as it will remove all contents of the ipld.blocks table
|
// DO NOT use a production db for the test db, as it will remove all contents of the ipld.blocks table
|
||||||
func TestDB() (*sqlx.DB, error) {
|
func TestDB() (*sqlx.DB, error) {
|
||||||
connectStr := "postgresql://vdbm:password@localhost:8077/cerc_testing?sslmode=disable"
|
return sqlx.Connect("postgres", testDBConfig.DbConnectionString())
|
||||||
return sqlx.Connect("postgres", connectStr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetTestDB drops all rows in the test db ipld.blocks table
|
// ResetTestDB drops all rows in the test db ipld.blocks table
|
||||||
|
@ -119,7 +119,7 @@ func (d *Database) dbGet(key string) ([]byte, error) {
|
|||||||
var data []byte
|
var data []byte
|
||||||
err := d.db.Get(&data, getPgStr, key)
|
err := d.db.Get(&data, getPgStr, key)
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
log.Warn("Database miss for key", key)
|
log.Warn("Database miss for key ", key)
|
||||||
}
|
}
|
||||||
|
|
||||||
return data, err
|
return data, err
|
||||||
|
@ -40,6 +40,12 @@ var (
|
|||||||
putPgStr = "INSERT INTO ipld.blocks (key, data, block_number) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING"
|
putPgStr = "INSERT INTO ipld.blocks (key, data, block_number) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING"
|
||||||
deletePgStr = "DELETE FROM ipld.blocks WHERE key = $1"
|
deletePgStr = "DELETE FROM ipld.blocks WHERE key = $1"
|
||||||
dbSizePgStr = "SELECT pg_database_size(current_database())"
|
dbSizePgStr = "SELECT pg_database_size(current_database())"
|
||||||
|
|
||||||
|
DefaultCacheConfig = CacheConfig{
|
||||||
|
Name: "db",
|
||||||
|
Size: 3000000, // 3MB
|
||||||
|
ExpiryDuration: time.Hour,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ ethdb.Database = &Database{}
|
var _ ethdb.Database = &Database{}
|
||||||
|
2
util.go
2
util.go
@ -29,7 +29,7 @@ func Keccak256ToCid(h []byte, codec uint64) (cid.Cid, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Cid{}, err
|
return cid.Cid{}, err
|
||||||
}
|
}
|
||||||
return cid.NewCidV1(codec, multihash.Multihash(buf)), nil
|
return cid.NewCidV1(codec, buf), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBlock takes a keccak256 hash key and the rlp []byte value it was derived from and creates an ipfs block object
|
// NewBlock takes a keccak256 hash key and the rlp []byte value it was derived from and creates an ipfs block object
|
||||||
|
Loading…
Reference in New Issue
Block a user