mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
fix: lint error
This commit is contained in:
parent
cb91f65056
commit
ad2fd55e7a
2 changed files with 13 additions and 13 deletions
|
|
@ -21,7 +21,7 @@ type PeppleStorageConfig struct {
|
|||
}
|
||||
|
||||
func NewPeppleDB(dataDir string, cache, handles int, namespace string) (ethdb.KeyValueStore, error) {
|
||||
db, err := pebble.New(dataDir + "/" + namespace, cache, handles, namespace, false)
|
||||
db, err := pebble.New(dataDir+"/"+namespace, cache, handles, namespace, false)
|
||||
return db, err
|
||||
}
|
||||
|
||||
|
|
@ -30,19 +30,19 @@ type ContentStorage struct {
|
|||
storageCapacityInBytes uint64
|
||||
radius atomic.Value
|
||||
// size uint64
|
||||
log log.Logger
|
||||
db ethdb.KeyValueStore
|
||||
log log.Logger
|
||||
db ethdb.KeyValueStore
|
||||
}
|
||||
|
||||
func NewPeppleStorage(config PeppleStorageConfig) (storage.ContentStorage, error) {
|
||||
cs := &ContentStorage{
|
||||
nodeId: config.NodeId,
|
||||
db: config.DB,
|
||||
db: config.DB,
|
||||
storageCapacityInBytes: config.StorageCapacityMB * 1000_000,
|
||||
log: log.New("storage", config.NetworkName),
|
||||
}
|
||||
cs.radius.Store(storage.MaxDistance)
|
||||
exist, err := cs.db.Has(storage.RadisuKey);
|
||||
exist, err := cs.db.Has(storage.RadisuKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -72,8 +72,8 @@ func (c *ContentStorage) Put(contentKey []byte, contentId []byte, content []byte
|
|||
}
|
||||
|
||||
// Radius implements storage.ContentStorage.
|
||||
func (p *ContentStorage) Radius() *uint256.Int {
|
||||
radius := p.radius.Load()
|
||||
func (c *ContentStorage) Radius() *uint256.Int {
|
||||
radius := c.radius.Load()
|
||||
val := radius.(*uint256.Int)
|
||||
return val
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
)
|
||||
|
||||
const dataDir = "./node1"
|
||||
|
||||
var testRadius = uint256.NewInt(100000)
|
||||
|
||||
func clearNodeData() {
|
||||
|
|
@ -23,10 +24,10 @@ func getTestDb() (storage.ContentStorage, error) {
|
|||
return nil, err
|
||||
}
|
||||
config := PeppleStorageConfig{
|
||||
DB: db,
|
||||
DB: db,
|
||||
StorageCapacityMB: 100,
|
||||
NodeId: enode.ID{},
|
||||
NetworkName: "history",
|
||||
NodeId: enode.ID{},
|
||||
NetworkName: "history",
|
||||
}
|
||||
return NewPeppleStorage(config)
|
||||
}
|
||||
|
|
@ -35,7 +36,7 @@ func TestReadRadius(t *testing.T) {
|
|||
db, err := getTestDb()
|
||||
assert.NoError(t, err)
|
||||
defer clearNodeData()
|
||||
assert.True(t, db.Radius().Eq(storage.MaxDistance))
|
||||
assert.True(t, db.Radius().Eq(storage.MaxDistance))
|
||||
|
||||
data, err := testRadius.MarshalSSZ()
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -70,5 +71,4 @@ func TestStorage(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, value, val)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue