Convert the chainstore lock to RW
High read-API concurrency facilitates multiple calls to GetHeaviestTipSet which in turn could slow down chainsync.
This commit is contained in:
parent
79194ccad1
commit
7bced1532b
@ -113,7 +113,7 @@ type ChainStore struct {
|
|||||||
|
|
||||||
chainLocalBlockstore bstore.Blockstore
|
chainLocalBlockstore bstore.Blockstore
|
||||||
|
|
||||||
heaviestLk sync.Mutex
|
heaviestLk sync.RWMutex
|
||||||
heaviest *types.TipSet
|
heaviest *types.TipSet
|
||||||
|
|
||||||
bestTips *pubsub.PubSub
|
bestTips *pubsub.PubSub
|
||||||
@ -775,10 +775,11 @@ func ReorgOps(lts func(types.TipSetKey) (*types.TipSet, error), a, b *types.TipS
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetHeaviestTipSet returns the current heaviest tipset known (i.e. our head).
|
// GetHeaviestTipSet returns the current heaviest tipset known (i.e. our head).
|
||||||
func (cs *ChainStore) GetHeaviestTipSet() *types.TipSet {
|
func (cs *ChainStore) GetHeaviestTipSet() (ts *types.TipSet) {
|
||||||
cs.heaviestLk.Lock()
|
cs.heaviestLk.RLock()
|
||||||
defer cs.heaviestLk.Unlock()
|
ts = cs.heaviest
|
||||||
return cs.heaviest
|
cs.heaviestLk.RUnlock()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *ChainStore) AddToTipSetTracker(b *types.BlockHeader) error {
|
func (cs *ChainStore) AddToTipSetTracker(b *types.BlockHeader) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user