remove unnecessary dep; gofmt
This commit is contained in:
parent
bf0186095f
commit
70133f0605
3
batch.go
3
batch.go
@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/hashicorp/golang-lru"
|
"github.com/hashicorp/golang-lru"
|
||||||
"github.com/ipfs/go-block-format"
|
"github.com/ipfs/go-block-format"
|
||||||
"github.com/ipfs/go-blockservice"
|
"github.com/ipfs/go-blockservice"
|
||||||
"github.com/ipfs/go-cid/_rsrch/cidiface"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -107,7 +106,7 @@ func (b *Batch) Write() error {
|
|||||||
}
|
}
|
||||||
for _, key := range b.deleteCache.Keys() {
|
for _, key := range b.deleteCache.Keys() {
|
||||||
// we are using state codec because we don't know the codec and at this level the codec doesn't matter, the datastore key is multihash-only derived
|
// we are using state codec because we don't know the codec and at this level the codec doesn't matter, the datastore key is multihash-only derived
|
||||||
c, err := Keccak256ToCid(common.Hex2Bytes(key.(string)), cid.EthStateTrie)
|
c, err := Keccak256ToCid(common.Hex2Bytes(key.(string)), stateTrieCodec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/ipfs/go-cid/_rsrch/cidiface"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -29,6 +28,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
stateTrieCodec uint64 = 0x96
|
||||||
defaultBatchCapacity = 1024
|
defaultBatchCapacity = 1024
|
||||||
errNotSupported = errors.New("this operation is not supported")
|
errNotSupported = errors.New("this operation is not supported")
|
||||||
)
|
)
|
||||||
@ -59,7 +59,7 @@ func NewDatabase(bs blockservice.BlockService) ethdb.Database {
|
|||||||
// This only operates on the local blockstore not through the exchange
|
// This only operates on the local blockstore not through the exchange
|
||||||
func (d *Database) Has(key []byte) (bool, error) {
|
func (d *Database) Has(key []byte) (bool, error) {
|
||||||
// we are using state codec because we don't know the codec and at this level the codec doesn't matter, the datastore key is multihash-only derived
|
// we are using state codec because we don't know the codec and at this level the codec doesn't matter, the datastore key is multihash-only derived
|
||||||
c, err := Keccak256ToCid(key, cid.EthStateTrie)
|
c, err := Keccak256ToCid(key, stateTrieCodec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ func (d *Database) Has(key []byte) (bool, error) {
|
|||||||
// Get retrieves the given key if it's present in the key-value data store
|
// Get retrieves the given key if it's present in the key-value data store
|
||||||
func (d *Database) Get(key []byte) ([]byte, error) {
|
func (d *Database) Get(key []byte) ([]byte, error) {
|
||||||
// we are using state codec because we don't know the codec and at this level the codec doesn't matter, the datastore key is multihash-only derived
|
// we are using state codec because we don't know the codec and at this level the codec doesn't matter, the datastore key is multihash-only derived
|
||||||
c, err := Keccak256ToCid(key, cid.EthStateTrie)
|
c, err := Keccak256ToCid(key, stateTrieCodec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ func (d *Database) Put(key []byte, value []byte) error {
|
|||||||
// Delete removes the key from the key-value data store
|
// Delete removes the key from the key-value data store
|
||||||
func (d *Database) Delete(key []byte) error {
|
func (d *Database) Delete(key []byte) error {
|
||||||
// we are using state codec because we don't know the codec and at this level the codec doesn't matter, the datastore key is multihash-only derived
|
// we are using state codec because we don't know the codec and at this level the codec doesn't matter, the datastore key is multihash-only derived
|
||||||
c, err := Keccak256ToCid(key, cid.EthStateTrie)
|
c, err := Keccak256ToCid(key, stateTrieCodec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package ipfsethdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/ipfs/go-cid/_rsrch/cidiface"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
"github.com/ipfs/go-blockservice"
|
"github.com/ipfs/go-blockservice"
|
||||||
@ -74,7 +73,7 @@ func (i *Iterator) Key() []byte {
|
|||||||
// and its contents may change on the next call to Next
|
// and its contents may change on the next call to Next
|
||||||
func (i *Iterator) Value() []byte {
|
func (i *Iterator) Value() []byte {
|
||||||
// we are using state codec because we don't know the codec and at this level the codec doesn't matter, the datastore key is multihash-only derived
|
// we are using state codec because we don't know the codec and at this level the codec doesn't matter, the datastore key is multihash-only derived
|
||||||
c, err := Keccak256ToCid(i.currentKey, cid.EthStateTrie)
|
c, err := Keccak256ToCid(i.currentKey, stateTrieCodec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.err = err
|
i.err = err
|
||||||
return nil
|
return nil
|
||||||
|
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, multihash.Multihash(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