Compare commits
30
Commits
v4.0.0-alpha
..
v4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91aaa89cf8 | ||
|
|
04ab6b6cfd | ||
|
|
288210a68c | ||
|
|
92f55b9712 | ||
|
|
f25575e5cb | ||
|
|
6c59c0d1f1 | ||
|
|
86e51e9518 | ||
|
|
68a24ab952 | ||
|
|
806f5bbe26 | ||
|
|
99cbb3b0c1 | ||
|
|
e3e8b2fbc1 | ||
|
|
13c752b90e | ||
|
|
f62c828c86 | ||
|
|
b34f7e0564 | ||
|
|
32edf85e5d | ||
|
|
fd19af396d | ||
|
|
b706c596c5 | ||
|
|
845d37cacf | ||
|
|
963053f23e | ||
|
|
f1c3dfccd3 | ||
|
|
4a40d2b14e | ||
|
|
77cc282a82 | ||
|
|
f3de4233b7 | ||
|
|
23177c8dff | ||
|
|
1c90257717 | ||
|
|
86b530c3a3 | ||
|
|
0069033d39 | ||
|
|
d22e0f70e2 | ||
|
|
b220685662 | ||
|
|
950fb0802d |
@@ -17,6 +17,7 @@
|
||||
package ipfsethdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@@ -103,7 +104,7 @@ func (b *Batch) Write() error {
|
||||
}
|
||||
puts[i] = b
|
||||
}
|
||||
if err := b.blockService.AddBlocks(puts); err != nil {
|
||||
if err := b.blockService.AddBlocks(context.Background(), puts); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, key := range b.deleteCache.Keys() {
|
||||
@@ -112,7 +113,7 @@ func (b *Batch) Write() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := b.blockService.DeleteBlock(c); err != nil {
|
||||
if err := b.blockService.DeleteBlock(context.Background(), c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
ipfsethdb "github.com/vulcanize/ipfs-ethdb/v4"
|
||||
ipfsethdb "github.com/cerc-io/ipfs-ethdb/v4"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
+9
-8
@@ -20,7 +20,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
@@ -69,7 +68,7 @@ func (d *Database) Has(key []byte) (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return d.blockService.Blockstore().Has(c)
|
||||
return d.blockService.Blockstore().Has(context.Background(), c)
|
||||
}
|
||||
|
||||
// Get satisfies the ethdb.KeyValueReader interface
|
||||
@@ -95,7 +94,7 @@ func (d *Database) Put(key []byte, value []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return d.blockService.AddBlock(b)
|
||||
return d.blockService.AddBlock(context.Background(), b)
|
||||
}
|
||||
|
||||
// Delete satisfies the ethdb.KeyValueWriter interface
|
||||
@@ -106,7 +105,7 @@ func (d *Database) Delete(key []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return d.blockService.DeleteBlock(c)
|
||||
return d.blockService.DeleteBlock(context.Background(), c)
|
||||
}
|
||||
|
||||
// DatabaseProperty enum type
|
||||
@@ -135,9 +134,6 @@ func (d *Database) Stat(property string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
switch prop {
|
||||
case ExchangeOnline:
|
||||
online := d.blockService.Exchange().IsOnline()
|
||||
return strconv.FormatBool(online), nil
|
||||
default:
|
||||
return "", fmt.Errorf("unhandled database property")
|
||||
}
|
||||
@@ -227,7 +223,7 @@ func (d *Database) AncientRange(kind string, start, count, maxBytes uint64) ([][
|
||||
}
|
||||
|
||||
// ReadAncients applies the provided AncientReader function
|
||||
func (d *Database) ReadAncients(fn func(ethdb.AncientReader) error) (err error) {
|
||||
func (d *Database) ReadAncients(fn func(ethdb.AncientReaderOp) error) (err error) {
|
||||
return errNotSupported
|
||||
}
|
||||
|
||||
@@ -260,3 +256,8 @@ func (d *Database) MigrateTable(string, func([]byte) ([]byte, error)) error {
|
||||
func (d *Database) NewSnapshot() (ethdb.Snapshot, error) {
|
||||
return nil, errNotSupported
|
||||
}
|
||||
|
||||
// AncientDatadir returns an error as we don't have a backing chain freezer.
|
||||
func (d *Database) AncientDatadir() (string, error) {
|
||||
return "", errNotSupported
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
ipfsethdb "github.com/vulcanize/ipfs-ethdb/v4"
|
||||
ipfsethdb "github.com/cerc-io/ipfs-ethdb/v4"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -1,22 +1,71 @@
|
||||
module github.com/vulcanize/ipfs-ethdb/v4
|
||||
module github.com/cerc-io/ipfs-ethdb/v4
|
||||
|
||||
go 1.15
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/btcsuite/btcd v0.22.1 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
|
||||
github.com/ethereum/go-ethereum v1.10.17
|
||||
github.com/ethereum/go-ethereum v1.11.5
|
||||
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
|
||||
github.com/ipfs/go-block-format v0.0.3
|
||||
github.com/ipfs/go-blockservice v0.1.3
|
||||
github.com/ipfs/go-cid v0.0.7
|
||||
github.com/ipfs/go-ipfs-blockstore v1.0.1
|
||||
github.com/ipfs/go-ipfs-ds-help v1.0.0
|
||||
github.com/ipfs/go-ipfs-exchange-interface v0.0.1
|
||||
github.com/ipfs/go-blockservice v0.4.0
|
||||
github.com/ipfs/go-cid v0.2.0
|
||||
github.com/ipfs/go-ipfs-blockstore v1.2.0
|
||||
github.com/ipfs/go-ipfs-ds-help v1.1.0
|
||||
github.com/ipfs/go-ipfs-exchange-interface v0.2.0
|
||||
github.com/jmoiron/sqlx v1.3.5
|
||||
github.com/lib/pq v1.10.5
|
||||
github.com/lib/pq v1.10.7
|
||||
github.com/mailgun/groupcache/v2 v2.3.0
|
||||
github.com/multiformats/go-multihash v0.1.0
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
github.com/onsi/gomega v1.19.0
|
||||
github.com/sirupsen/logrus v1.6.0
|
||||
)
|
||||
|
||||
require github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
|
||||
|
||||
require (
|
||||
github.com/btcsuite/btcd v0.22.0-beta // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/holiman/uint256 v1.2.0 // indirect
|
||||
github.com/ipfs/bbloom v0.0.4 // indirect
|
||||
github.com/ipfs/go-datastore v0.5.0 // indirect
|
||||
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
|
||||
github.com/ipfs/go-ipld-format v0.4.0 // indirect
|
||||
github.com/ipfs/go-log v1.0.5 // indirect
|
||||
github.com/ipfs/go-log/v2 v2.3.0 // indirect
|
||||
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
|
||||
github.com/ipfs/go-verifcid v0.0.1 // indirect
|
||||
github.com/jbenet/goprocess v0.1.4 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
|
||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||
github.com/multiformats/go-base32 v0.0.3 // indirect
|
||||
github.com/multiformats/go-base36 v0.1.0 // indirect
|
||||
github.com/multiformats/go-multibase v0.0.3 // indirect
|
||||
github.com/multiformats/go-varint v0.0.6 // indirect
|
||||
github.com/nxadm/tail v1.4.8 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/segmentio/fasthash v1.0.3 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
go.opentelemetry.io/otel v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.7.0 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
go.uber.org/zap v1.16.0 // indirect
|
||||
golang.org/x/crypto v0.6.0 // indirect
|
||||
golang.org/x/net v0.6.0 // indirect
|
||||
golang.org/x/sys v0.5.0 // indirect
|
||||
golang.org/x/text v0.7.0 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
lukechampine.com/blake3 v1.1.6 // indirect
|
||||
)
|
||||
|
||||
+14
-14
@@ -52,27 +52,27 @@ func (mbs *MockBlockservice) Exchange() exchange.Interface {
|
||||
panic("Exchange: implement me")
|
||||
}
|
||||
|
||||
func (mbs *MockBlockservice) AddBlock(b blocks.Block) error {
|
||||
return mbs.blockStore.Put(b)
|
||||
func (mbs *MockBlockservice) AddBlock(ctx context.Context, b blocks.Block) error {
|
||||
return mbs.blockStore.Put(ctx, b)
|
||||
}
|
||||
|
||||
func (mbs *MockBlockservice) AddBlocks(bs []blocks.Block) error {
|
||||
return mbs.blockStore.PutMany(bs)
|
||||
func (mbs *MockBlockservice) AddBlocks(ctx context.Context, bs []blocks.Block) error {
|
||||
return mbs.blockStore.PutMany(ctx, bs)
|
||||
}
|
||||
|
||||
func (mbs *MockBlockservice) DeleteBlock(c cid.Cid) error {
|
||||
return mbs.blockStore.DeleteBlock(c)
|
||||
func (mbs *MockBlockservice) DeleteBlock(ctx context.Context, c cid.Cid) error {
|
||||
return mbs.blockStore.DeleteBlock(ctx, c)
|
||||
}
|
||||
|
||||
func (mbs *MockBlockservice) GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error) {
|
||||
return mbs.blockStore.Get(c)
|
||||
return mbs.blockStore.Get(ctx, c)
|
||||
}
|
||||
|
||||
func (mbs *MockBlockservice) GetBlocks(ctx context.Context, cs []cid.Cid) <-chan blocks.Block {
|
||||
blockChan := make(chan blocks.Block)
|
||||
go func() {
|
||||
for _, c := range cs {
|
||||
if b, err := mbs.blockStore.Get(c); err == nil {
|
||||
if b, err := mbs.blockStore.Get(ctx, c); err == nil {
|
||||
blockChan <- b
|
||||
}
|
||||
}
|
||||
@@ -93,17 +93,17 @@ type MockBlockstore struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (mbs *MockBlockstore) DeleteBlock(c cid.Cid) error {
|
||||
func (mbs *MockBlockstore) DeleteBlock(ctx context.Context, c cid.Cid) error {
|
||||
delete(mbs.blocks, c.String())
|
||||
return mbs.err
|
||||
}
|
||||
|
||||
func (mbs *MockBlockstore) Has(c cid.Cid) (bool, error) {
|
||||
func (mbs *MockBlockstore) Has(ctx context.Context, c cid.Cid) (bool, error) {
|
||||
_, ok := mbs.blocks[c.String()]
|
||||
return ok, mbs.err
|
||||
}
|
||||
|
||||
func (mbs *MockBlockstore) Get(c cid.Cid) (blocks.Block, error) {
|
||||
func (mbs *MockBlockstore) Get(ctx context.Context, c cid.Cid) (blocks.Block, error) {
|
||||
obj, ok := mbs.blocks[c.String()]
|
||||
if !ok {
|
||||
return nil, blockNotFoundErr
|
||||
@@ -111,7 +111,7 @@ func (mbs *MockBlockstore) Get(c cid.Cid) (blocks.Block, error) {
|
||||
return obj, mbs.err
|
||||
}
|
||||
|
||||
func (mbs *MockBlockstore) GetSize(c cid.Cid) (int, error) {
|
||||
func (mbs *MockBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
|
||||
obj, ok := mbs.blocks[c.String()]
|
||||
if !ok {
|
||||
return 0, blockNotFoundErr
|
||||
@@ -119,12 +119,12 @@ func (mbs *MockBlockstore) GetSize(c cid.Cid) (int, error) {
|
||||
return len(obj.RawData()), mbs.err
|
||||
}
|
||||
|
||||
func (mbs *MockBlockstore) Put(b blocks.Block) error {
|
||||
func (mbs *MockBlockstore) Put(ctx context.Context, b blocks.Block) error {
|
||||
mbs.blocks[b.Cid().String()] = b
|
||||
return mbs.err
|
||||
}
|
||||
|
||||
func (mbs *MockBlockstore) PutMany(bs []blocks.Block) error {
|
||||
func (mbs *MockBlockstore) PutMany(ctx context.Context, bs []blocks.Block) error {
|
||||
for _, b := range bs {
|
||||
mbs.blocks[b.Cid().String()] = b
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
pgipfsethdb "github.com/vulcanize/ipfs-ethdb/v4/postgres"
|
||||
pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v4/postgres"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
+14
-2
@@ -18,6 +18,7 @@ package pgipfsethdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
@@ -28,6 +29,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/mailgun/groupcache/v2"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var errNotSupported = errors.New("this operation is not supported")
|
||||
@@ -113,7 +115,12 @@ func (d *Database) Has(key []byte) (bool, error) {
|
||||
// Get retrieves the given key if it's present in the key-value data store
|
||||
func (d *Database) dbGet(key string) ([]byte, error) {
|
||||
var data []byte
|
||||
return data, d.db.Get(&data, getPgStr, key)
|
||||
err := d.db.Get(&data, getPgStr, key)
|
||||
if err == sql.ErrNoRows {
|
||||
log.Warn("Database miss for key", key)
|
||||
}
|
||||
|
||||
return data, err
|
||||
}
|
||||
|
||||
// Get satisfies the ethdb.KeyValueReader interface
|
||||
@@ -314,7 +321,7 @@ func (d *Database) AncientRange(kind string, start, count, maxBytes uint64) ([][
|
||||
}
|
||||
|
||||
// ReadAncients applies the provided AncientReader function
|
||||
func (d *Database) ReadAncients(fn func(ethdb.AncientReader) error) (err error) {
|
||||
func (d *Database) ReadAncients(fn func(ethdb.AncientReaderOp) error) (err error) {
|
||||
return errNotSupported
|
||||
}
|
||||
|
||||
@@ -347,3 +354,8 @@ func (d *Database) MigrateTable(string, func([]byte) ([]byte, error)) error {
|
||||
func (d *Database) NewSnapshot() (ethdb.Snapshot, error) {
|
||||
return nil, errNotSupported
|
||||
}
|
||||
|
||||
// AncientDatadir returns an error as we don't have a backing chain freezer.
|
||||
func (d *Database) AncientDatadir() (string, error) {
|
||||
return "", errNotSupported
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
pgipfsethdb "github.com/vulcanize/ipfs-ethdb/v4/postgres"
|
||||
pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v4/postgres"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user