mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
core/rawdb: move type
This commit is contained in:
parent
fb3e577060
commit
c84e977ce2
1 changed files with 10 additions and 11 deletions
|
|
@ -34,15 +34,6 @@ const openFileLimit = 64
|
|||
|
||||
var errClosed = errors.New("era store is closed")
|
||||
|
||||
type fileCacheStat byte
|
||||
|
||||
const (
|
||||
storeClosing fileCacheStat = iota
|
||||
fileIsNew
|
||||
fileIsOpening
|
||||
fileIsCached
|
||||
)
|
||||
|
||||
// Store manages read access to a directory of era1 files.
|
||||
// The getter methods are thread-safe.
|
||||
type Store struct {
|
||||
|
|
@ -63,6 +54,15 @@ type fileCacheEntry struct {
|
|||
err error // error from opening the file
|
||||
}
|
||||
|
||||
type fileCacheStatus byte
|
||||
|
||||
const (
|
||||
storeClosing fileCacheStatus = iota
|
||||
fileIsNew
|
||||
fileIsOpening
|
||||
fileIsCached
|
||||
)
|
||||
|
||||
// New opens the store directory.
|
||||
func New(datadir string) (*Store, error) {
|
||||
// Ensure the datadir is not a symbolic link if it exists.
|
||||
|
|
@ -144,7 +144,6 @@ func (db *Store) GetRawReceipts(number uint64) ([]byte, error) {
|
|||
// The caller can freely access the returned entry's .file and .err
|
||||
// db.doneWithFile must be called when it is done reading the file.
|
||||
func (db *Store) getEraByEpoch(epoch uint64) *fileCacheEntry {
|
||||
// Add the requested epoch to the cache.
|
||||
stat, entry := db.getCacheEntry(epoch)
|
||||
|
||||
switch stat {
|
||||
|
|
@ -175,7 +174,7 @@ func (db *Store) getEraByEpoch(epoch uint64) *fileCacheEntry {
|
|||
}
|
||||
|
||||
// getCacheEntry gets an open era file from the cache.
|
||||
func (db *Store) getCacheEntry(epoch uint64) (stat fileCacheStat, entry *fileCacheEntry) {
|
||||
func (db *Store) getCacheEntry(epoch uint64) (stat fileCacheStatus, entry *fileCacheEntry) {
|
||||
db.mu.Lock()
|
||||
defer db.mu.Unlock()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue