mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-13 15:21:20 +00:00
Make ConcurrentProvider public
This commit is contained in:
parent
39e589e3c7
commit
b441a71221
@ -52,7 +52,7 @@ func (fc FullCommit) ValidateFull(chainID string) error {
|
||||
return errors.New("need FullCommit.NextValidators")
|
||||
}
|
||||
|
||||
// If the commit ValidatorHash doesn't match the block ValidatorHash return an error
|
||||
// If the commit NextValidatorHash doesn't match the block Next ValidatorHash return an error
|
||||
if !bytes.Equal(fc.SignedHeader.NextValidatorsHash, fc.NextValidators.Hash()) {
|
||||
return fmt.Errorf("header has next vhash %X but next valset hash is %X",
|
||||
fc.SignedHeader.NextValidatorsHash,
|
||||
|
@ -51,7 +51,7 @@ type UpdatingProvider interface {
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
type concurrentProvider struct {
|
||||
type ConcurrentProvider struct {
|
||||
UpdatingProvider
|
||||
|
||||
// pending map to synchronize concurrent verification requests
|
||||
@ -71,8 +71,8 @@ type pendingResult struct {
|
||||
err error // cached result.
|
||||
}
|
||||
|
||||
func NewConcurrentUpdatingProvider(up UpdatingProvider) concurrentProvider {
|
||||
return concurrentProvider{
|
||||
func NewConcurrentUpdatingProvider(up UpdatingProvider) ConcurrentProvider {
|
||||
return ConcurrentProvider{
|
||||
UpdatingProvider: up,
|
||||
pendingVerifications: make(map[pendingKey]*pendingResult),
|
||||
}
|
||||
@ -84,7 +84,7 @@ func NewConcurrentUpdatingProvider(up UpdatingProvider) concurrentProvider {
|
||||
// The callback must be called, otherwise there will be memory leaks.
|
||||
// Other subsequent calls should just return uniq.err.
|
||||
// NOTE: This is a separate function, primarily to make mtx unlocking more obviously safe via defer.
|
||||
func (cp concurrentProvider) joinConcurrency(chainID string, height int64) (uniq *pendingResult, isFirstCall bool, callback func(error)) {
|
||||
func (cp ConcurrentProvider) joinConcurrency(chainID string, height int64) (uniq *pendingResult, isFirstCall bool, callback func(error)) {
|
||||
cp.mtx.Lock()
|
||||
defer cp.mtx.Unlock()
|
||||
|
||||
@ -111,7 +111,7 @@ func (cp concurrentProvider) joinConcurrency(chainID string, height int64) (uniq
|
||||
}
|
||||
}
|
||||
|
||||
func (cp *concurrentProvider) UpdateToHeight(chainID string, height int64) error {
|
||||
func (cp *ConcurrentProvider) UpdateToHeight(chainID string, height int64) error {
|
||||
|
||||
// Performs synchronization for multi-threads verification at the same height.
|
||||
var presult *pendingResult
|
||||
|
@ -249,7 +249,7 @@ func (vp *Provider) ChainID() string {
|
||||
// Implements UpdatingProvider
|
||||
//
|
||||
// On success, it will store the full commit (SignedHeader + Validators) in vp.trusted
|
||||
// NOTE: For concurrent usage, use concurrentProvider
|
||||
// NOTE: For concurrent usage, use ConcurrentProvider
|
||||
func (vp *Provider) UpdateToHeight(chainID string, height int64) error {
|
||||
|
||||
// If we alreedy have the commit, just return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user