add lock to protection storage dump (#2624)

pull/2633/head
Minh Doan 5 years ago committed by GitHub
parent 74a5eda740
commit c5e323b25c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      api/service/explorer/storage.go

@ -31,6 +31,7 @@ var once sync.Once
// Storage dump the block info into leveldb.
type Storage struct {
db *leveldb.DB
lock sync.Mutex
}
// GetStorageInstance returns attack model by using singleton pattern.
@ -72,6 +73,8 @@ func (storage *Storage) GetDB() *leveldb.DB {
// Dump extracts information from block and index them into lvdb for explorer.
func (storage *Storage) Dump(block *types.Block, height uint64) {
storage.lock.Lock()
defer storage.lock.Unlock()
if block == nil {
return
}

Loading…
Cancel
Save