mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
* Vulnerability in light client proxy When calling GetCertifiedCommit the light client proxy would call Certify and even on error return the Commit as if it had been correctly certified. Now it returns the error correctly and returns an empty Commit on error. * Improve names for clarity The lite package now contains StaticCertifier, DynamicCertifier and InqueringCertifier. This also changes the method receivers from one letter to two letter names, which will make future refactoring easier and follows the coding standards. * Fix test failures * Rename files * remove dead code
36 lines
865 B
Go
36 lines
865 B
Go
package proxy
|
|
|
|
import (
|
|
"github.com/tendermint/tendermint/lite"
|
|
certclient "github.com/tendermint/tendermint/lite/client"
|
|
"github.com/tendermint/tendermint/lite/files"
|
|
)
|
|
|
|
func GetCertifier(chainID, rootDir, nodeAddr string) (*lite.InquiringCertifier, error) {
|
|
trust := lite.NewCacheProvider(
|
|
lite.NewMemStoreProvider(),
|
|
files.NewProvider(rootDir),
|
|
)
|
|
|
|
source := certclient.NewHTTPProvider(nodeAddr)
|
|
|
|
// XXX: total insecure hack to avoid `init`
|
|
fc, err := source.LatestCommit()
|
|
/* XXX
|
|
// this gets the most recent verified commit
|
|
fc, err := trust.LatestCommit()
|
|
if certerr.IsCommitNotFoundErr(err) {
|
|
return nil, errors.New("Please run init first to establish a root of trust")
|
|
}*/
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
cert, err := lite.NewInquiringCertifier(chainID, fc, trust, source)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return cert, nil
|
|
}
|