2017-12-11 16:37:48 -05:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/tendermint/tendermint/lite"
|
2018-06-09 04:25:48 -07:00
|
|
|
lclient "github.com/tendermint/tendermint/lite/client"
|
|
|
|
dbm "github.com/tendermint/tmlibs/db"
|
2017-12-11 16:37:48 -05:00
|
|
|
)
|
|
|
|
|
2018-06-20 01:42:37 -07:00
|
|
|
func GetCertifier(chainID, rootDir string, client lclient.SignStatusClient) (*lite.InquiringCertifier, error) {
|
2018-06-09 04:25:48 -07:00
|
|
|
trust := lite.NewMultiProvider(
|
2018-06-20 01:42:37 -07:00
|
|
|
lite.NewDBProvider(dbm.NewMemDB()).SetLimit(10),
|
2018-06-09 04:25:48 -07:00
|
|
|
lite.NewDBProvider(dbm.NewDB("trust-base", dbm.LevelDBBackend, rootDir)),
|
2017-12-11 16:37:48 -05:00
|
|
|
)
|
2018-06-20 01:42:37 -07:00
|
|
|
source := lclient.NewProvider(chainID, client)
|
2017-12-11 16:37:48 -05:00
|
|
|
|
2018-06-20 01:42:37 -07:00
|
|
|
// TODO: Make this more secure, e.g. make it interactive in the console?
|
|
|
|
_, err := trust.LatestFullCommit(chainID, 1, 1<<63-1)
|
2018-06-09 04:25:48 -07:00
|
|
|
if err != nil {
|
2018-06-20 01:42:37 -07:00
|
|
|
fc, err := source.LatestFullCommit(chainID, 1, 1)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = trust.SaveFullCommit(fc)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-12-11 16:37:48 -05:00
|
|
|
}
|
2018-01-05 13:24:16 +01:00
|
|
|
|
2018-06-09 04:25:48 -07:00
|
|
|
cert, err := lite.NewInquiringCertifier(chainID, trust, source)
|
2018-01-05 13:24:16 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2017-12-11 16:37:48 -05:00
|
|
|
return cert, nil
|
|
|
|
}
|