-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrapper storage package #4453
Wrapper storage package #4453
Conversation
Codecov Report
@@ Coverage Diff @@
## feat/elrond-go-storage #4453 +/- ##
=========================================================
Coverage ? 73.04%
=========================================================
Files ? 638
Lines ? 83548
Branches ? 0
=========================================================
Hits ? 61031
Misses ? 17763
Partials ? 4754 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
refactor several dependencies
use latest storage
@@ -98,7 +98,7 @@ func NewDelayedBlockBroadcaster(args *ArgsDelayedBlockBroadcaster) (*delayedBloc | |||
return nil, spos.ErrNilAlarmScheduler | |||
} | |||
|
|||
cacheHeaders, err := lrucache.NewCache(sizeHeadersCache) | |||
cacheHeaders, err := cache.NewLRUCache(sizeHeadersCache) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if errClose != nil { | ||
errMsg = errClose.Error() | ||
} | ||
panic(fmt.Sprintf("cannot close file: %s", errMsg)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this is old code, I think this line needs to be moved on L235, otherwise it will always panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -137,9 +136,9 @@ func createTestBlockChain() data.ChainHandler { | |||
} | |||
|
|||
func createMemUnit() storage.Storer { | |||
cache, _ := storageUnit.NewCache(storageUnit.CacheConfig{Type: storageUnit.LRUCache, Capacity: 10, Shards: 1, SizeInBytes: 0}) | |||
suCache, _ := storageunit.NewCache(storageunit.CacheConfig{Type: storageunit.LRUCache, Capacity: 10, Shards: 1, SizeInBytes: 0}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually I name these variables something like cacheInstance
in order to have a different name with the package
storage/database/db.go
Outdated
|
||
// NewLevelDB is a constructor for the leveldb persister | ||
// It creates the files in the location given as parameter | ||
func NewLevelDB(path string, batchDelaySeconds int, maxBatchSize int, maxOpenFiles int) (s *LevelDB, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case only, where we have method factories we might have had the returning parameter of type leveldb.DB
rather than the alias. Can be left as it is, is just a suggestion to keep the type aliases number as low as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, removed
storage/storageunit/constants.go
Outdated
import "github.com/ElrondNetwork/elrond-go-storage/storageUnit" | ||
|
||
const ( | ||
LRUCache = storageUnit.LRUCache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments on exported items?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
storage/errors.go
Outdated
@@ -77,6 +70,30 @@ var ErrNilNodeTypeProvider = errors.New("nil node type provider") | |||
// ErrNilOldDataCleanerProvider signals that a nil old data cleaner provider has been provided | |||
var ErrNilOldDataCleanerProvider = errors.New("nil old data cleaner provider") | |||
|
|||
// ErrNilCacher is raised when a nil cacher is provided |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used anywhere
storage/pathmanager/errors.go
Outdated
// IsNotFoundInStorageErr returns whether an error is a "not found in storage" error. | ||
// Currently, "item not found" storage errors are untyped (thus not distinguishable from others). E.g. see "pruningStorer.go". | ||
// As a workaround, we test the error message for a match. | ||
func IsNotFoundInStorageErr(err error) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used
storage/constants.go
Outdated
) | ||
|
||
// MaxRetriesToCreateDB represents the maximum number of times to try to create DB if it failed | ||
const MaxRetriesToCreateDB = 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as this is used only in the storage
package and it also exists in elrond-go-storage
, why not use the one from elrond-go-storage
repo? this way we avoid forgetting to update one of them in one of the repos
same for SleepTimeBetweenCreateDBRetries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the constants from elrond-go-storage were removed:
https://github.com/ElrondNetwork/elrond-go-storage/pull/4/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these 2 were moved to storageUnit.go
https://github.com/ElrondNetwork/elrond-go-storage/pull/4/files#diff-63b94d5e561760c6df458775f6a94633b032820bf3cb2360f5cf859cd63d73f3R65
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, forgot I moved these there.
Referenced for now the ones in storageUnit, but this will need to be refactored in a different PR so that we allow the consumer of the storage-repo to give these constants as arguments on creation instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- it looks like some of the interfaces in
storage/interface.go
are not being used likeSerializedStoredData
,LRUCacheHandler
,ForEachItem
, maybe we can remove them - also others like Cacher seems to be duplicated with storage repo, maybe use an alias?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System test passed.
Description of the reasoning behind the pull request
Proposed Changes