Skip to content

Commit

Permalink
rollback to use normal mutex in nodeDB (cosmos#432)
Browse files Browse the repository at this point in the history
(cherry picked from commit 89f6b77)
  • Loading branch information
yun-yeo authored and lizhi committed Jan 21, 2022
1 parent 343c4fa commit 61a58ce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
)

type nodeDB struct {
mtx sync.RWMutex // Read/write lock.
mtx sync.Mutex // Read/write lock.
db dbm.DB // Persistent node storage.
batch dbm.Batch // Batched writing buffer.
opts Options // Options to customize for pruning/writing
Expand Down Expand Up @@ -67,8 +67,8 @@ func newNodeDB(db dbm.DB, cacheSize int, opts *Options) *nodeDB {
// GetNode gets a node from memory or disk. If it is an inner node, it does not
// load its children.
func (ndb *nodeDB) GetNode(hash []byte) *Node {
ndb.mtx.RLock()
defer ndb.mtx.RUnlock()
ndb.mtx.Lock()
defer ndb.mtx.Unlock()

if len(hash) == 0 {
panic("nodeDB.GetNode() requires hash")
Expand Down

0 comments on commit 61a58ce

Please sign in to comment.