Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vote/vote_pool: use TryRLock in FetchVoteByBlockHash (#311)
The FetchVoteByBlockHash is called by the consensus engine and we don't want this function to block the consensus engine's operations. Currently, FetchVoteByBlockHash uses RLock to wait to acquire the read lock but as the writers are uncontrolled, it can be blocked when there are a lot of spamming writers. This commit makes FetchVoteByBlockHash to use TryRLock to keep polling for the lock n times and returns nil in case it cannot acquire the lock. This helps to bound the max duration a caller must wait on this function.
- Loading branch information