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")
|
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()) {
|
if !bytes.Equal(fc.SignedHeader.NextValidatorsHash, fc.NextValidators.Hash()) {
|
||||||
return fmt.Errorf("header has next vhash %X but next valset hash is %X",
|
return fmt.Errorf("header has next vhash %X but next valset hash is %X",
|
||||||
fc.SignedHeader.NextValidatorsHash,
|
fc.SignedHeader.NextValidatorsHash,
|
||||||
|
@ -51,7 +51,7 @@ type UpdatingProvider interface {
|
|||||||
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
|
||||||
type concurrentProvider struct {
|
type ConcurrentProvider struct {
|
||||||
UpdatingProvider
|
UpdatingProvider
|
||||||
|
|
||||||
// pending map to synchronize concurrent verification requests
|
// pending map to synchronize concurrent verification requests
|
||||||
@ -71,8 +71,8 @@ type pendingResult struct {
|
|||||||
err error // cached result.
|
err error // cached result.
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConcurrentUpdatingProvider(up UpdatingProvider) concurrentProvider {
|
func NewConcurrentUpdatingProvider(up UpdatingProvider) ConcurrentProvider {
|
||||||
return concurrentProvider{
|
return ConcurrentProvider{
|
||||||
UpdatingProvider: up,
|
UpdatingProvider: up,
|
||||||
pendingVerifications: make(map[pendingKey]*pendingResult),
|
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.
|
// The callback must be called, otherwise there will be memory leaks.
|
||||||
// Other subsequent calls should just return uniq.err.
|
// Other subsequent calls should just return uniq.err.
|
||||||
// NOTE: This is a separate function, primarily to make mtx unlocking more obviously safe via defer.
|
// 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()
|
cp.mtx.Lock()
|
||||||
defer cp.mtx.Unlock()
|
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.
|
// Performs synchronization for multi-threads verification at the same height.
|
||||||
var presult *pendingResult
|
var presult *pendingResult
|
||||||
|
@ -249,7 +249,7 @@ func (vp *Provider) ChainID() string {
|
|||||||
// Implements UpdatingProvider
|
// Implements UpdatingProvider
|
||||||
//
|
//
|
||||||
// On success, it will store the full commit (SignedHeader + Validators) in vp.trusted
|
// 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 {
|
func (vp *Provider) UpdateToHeight(chainID string, height int64) error {
|
||||||
|
|
||||||
// If we alreedy have the commit, just return nil
|
// If we alreedy have the commit, just return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user