mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 14:33:52 +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) {
|
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
|
return db, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,19 +30,19 @@ type ContentStorage struct {
|
||||||
storageCapacityInBytes uint64
|
storageCapacityInBytes uint64
|
||||||
radius atomic.Value
|
radius atomic.Value
|
||||||
// size uint64
|
// size uint64
|
||||||
log log.Logger
|
log log.Logger
|
||||||
db ethdb.KeyValueStore
|
db ethdb.KeyValueStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPeppleStorage(config PeppleStorageConfig) (storage.ContentStorage, error) {
|
func NewPeppleStorage(config PeppleStorageConfig) (storage.ContentStorage, error) {
|
||||||
cs := &ContentStorage{
|
cs := &ContentStorage{
|
||||||
nodeId: config.NodeId,
|
nodeId: config.NodeId,
|
||||||
db: config.DB,
|
db: config.DB,
|
||||||
storageCapacityInBytes: config.StorageCapacityMB * 1000_000,
|
storageCapacityInBytes: config.StorageCapacityMB * 1000_000,
|
||||||
log: log.New("storage", config.NetworkName),
|
log: log.New("storage", config.NetworkName),
|
||||||
}
|
}
|
||||||
cs.radius.Store(storage.MaxDistance)
|
cs.radius.Store(storage.MaxDistance)
|
||||||
exist, err := cs.db.Has(storage.RadisuKey);
|
exist, err := cs.db.Has(storage.RadisuKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -72,8 +72,8 @@ func (c *ContentStorage) Put(contentKey []byte, contentId []byte, content []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// Radius implements storage.ContentStorage.
|
// Radius implements storage.ContentStorage.
|
||||||
func (p *ContentStorage) Radius() *uint256.Int {
|
func (c *ContentStorage) Radius() *uint256.Int {
|
||||||
radius := p.radius.Load()
|
radius := c.radius.Load()
|
||||||
val := radius.(*uint256.Int)
|
val := radius.(*uint256.Int)
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const dataDir = "./node1"
|
const dataDir = "./node1"
|
||||||
|
|
||||||
var testRadius = uint256.NewInt(100000)
|
var testRadius = uint256.NewInt(100000)
|
||||||
|
|
||||||
func clearNodeData() {
|
func clearNodeData() {
|
||||||
|
|
@ -23,10 +24,10 @@ func getTestDb() (storage.ContentStorage, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
config := PeppleStorageConfig{
|
config := PeppleStorageConfig{
|
||||||
DB: db,
|
DB: db,
|
||||||
StorageCapacityMB: 100,
|
StorageCapacityMB: 100,
|
||||||
NodeId: enode.ID{},
|
NodeId: enode.ID{},
|
||||||
NetworkName: "history",
|
NetworkName: "history",
|
||||||
}
|
}
|
||||||
return NewPeppleStorage(config)
|
return NewPeppleStorage(config)
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +36,7 @@ func TestReadRadius(t *testing.T) {
|
||||||
db, err := getTestDb()
|
db, err := getTestDb()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
defer clearNodeData()
|
defer clearNodeData()
|
||||||
assert.True(t, db.Radius().Eq(storage.MaxDistance))
|
assert.True(t, db.Radius().Eq(storage.MaxDistance))
|
||||||
|
|
||||||
data, err := testRadius.MarshalSSZ()
|
data, err := testRadius.MarshalSSZ()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
@ -70,5 +71,4 @@ func TestStorage(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, value, val)
|
assert.Equal(t, value, val)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue