Fix light-client imports
This commit is contained in:
parent
b5320748e6
commit
1f897cabde
|
@ -5,8 +5,11 @@ import (
|
|||
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
certclient "github.com/tendermint/light-client/certifiers/client"
|
||||
certerr "github.com/tendermint/light-client/certifiers/errors"
|
||||
"github.com/tendermint/light-client/certifiers/files"
|
||||
|
||||
"github.com/tendermint/light-client/proofs"
|
||||
|
||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||
)
|
||||
|
||||
|
@ -18,7 +21,7 @@ func GetNode(url string) rpcclient.Client {
|
|||
// GetRPCProvider retuns a certifier compatible data source using
|
||||
// tendermint RPC
|
||||
func GetRPCProvider(url string) certifiers.Provider {
|
||||
return certclient.NewHTTP(url)
|
||||
return certclient.NewHTTPProvider(url)
|
||||
}
|
||||
|
||||
// GetLocalProvider returns a reference to a file store of headers
|
||||
|
@ -33,11 +36,11 @@ func GetLocalProvider(dir string) certifiers.Provider {
|
|||
// GetCertifier initializes an inquiring certifier given a fixed chainID
|
||||
// and a local source of trusted data with at least one seed
|
||||
func GetCertifier(chainID string, trust certifiers.Provider,
|
||||
source certifiers.Provider) (*certifiers.InquiringCertifier, error) {
|
||||
source certifiers.Provider) (*certifiers.Inquiring, error) {
|
||||
|
||||
// this gets the most recent verified seed
|
||||
seed, err := certifiers.LatestSeed(trust)
|
||||
if certifiers.IsSeedNotFoundErr(err) {
|
||||
seed, err := trust.LatestCommit()
|
||||
if certerr.IsCommitNotFoundErr(err) {
|
||||
return nil, errors.New("Please run init first to establish a root of trust")
|
||||
}
|
||||
if err != nil {
|
||||
|
@ -49,6 +52,6 @@ func GetCertifier(chainID string, trust certifiers.Provider,
|
|||
|
||||
// SecureClient uses a given certifier to wrap an connection to an untrusted
|
||||
// host and return a cryptographically secure rpc client.
|
||||
func SecureClient(c rpcclient.Client, cert *certifiers.InquiringCertifier) rpcclient.Client {
|
||||
return certclient.Wrap(c, cert)
|
||||
func SecureClient(c rpcclient.Client, cert *certifiers.Inquiring) rpcclient.Client {
|
||||
return proofs.Wrap(c, cert)
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
|
||||
"github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/iavl"
|
||||
lc "github.com/tendermint/light-client"
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
certerr "github.com/tendermint/light-client/certifiers/errors"
|
||||
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
)
|
||||
|
@ -47,7 +47,7 @@ func GetWithProof(key []byte, reqHeight int, node client.Client,
|
|||
}
|
||||
|
||||
// AppHash for height H is in header H+1
|
||||
var check lc.Checkpoint
|
||||
var check *certifiers.Commit
|
||||
check, err = GetCertifiedCheckpoint(int(resp.Height+1), node, cert)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -95,25 +95,22 @@ func GetWithProof(key []byte, reqHeight int, node client.Client,
|
|||
// GetCertifiedCheckpoint gets the signed header for a given height
|
||||
// and certifies it. Returns error if unable to get a proven header.
|
||||
func GetCertifiedCheckpoint(h int, node client.Client,
|
||||
cert certifiers.Certifier) (empty lc.Checkpoint, err error) {
|
||||
cert certifiers.Certifier) (empty *certifiers.Commit, err error) {
|
||||
|
||||
// FIXME: cannot use cert.GetByHeight for now, as it also requires
|
||||
// Validators and will fail on querying tendermint for non-current height.
|
||||
// When this is supported, we should use it instead...
|
||||
client.WaitForHeight(node, h, nil)
|
||||
commit, err := node.Commit(&h)
|
||||
cresp, err := node.Commit(&h)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
check := lc.Checkpoint{
|
||||
Header: commit.Header,
|
||||
Commit: commit.Commit,
|
||||
}
|
||||
commit := certifiers.CommitFromResult(cresp)
|
||||
|
||||
// validate downloaded checkpoint with our request and trust store.
|
||||
if check.Height() != h {
|
||||
return empty, lc.ErrHeightMismatch(h, check.Height())
|
||||
if commit.Height() != h {
|
||||
return empty, certerr.ErrHeightMismatch(h, commit.Height())
|
||||
}
|
||||
err = cert.Certify(check)
|
||||
return check, nil
|
||||
err = cert.Certify(commit)
|
||||
return commit, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue