mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-25 09:24:30 +00:00
lite: Add synchronization in lite verify (#2396)
* Implement issues 2386: add synchronization in lite verify and change all Certify to Verify
* Replace make(chan struct{}, 0) with make(chan struct{})
* Parameterize memroy cache size and add concurrent test
* Refactor import order
This commit is contained in:
committed by
Ethan Buchman
parent
5173fe9414
commit
8dda3c3b28
+1
-1
@@ -146,7 +146,7 @@ func GetCertifiedCommit(h int64, client rpcclient.Client, cert lite.Verifier) (t
|
||||
h, sh.Height)
|
||||
}
|
||||
|
||||
if err = cert.Certify(sh); err != nil {
|
||||
if err = cert.Verify(sh); err != nil {
|
||||
return types.SignedHeader{}, err
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ import (
|
||||
lclient "github.com/tendermint/tendermint/lite/client"
|
||||
)
|
||||
|
||||
func NewVerifier(chainID, rootDir string, client lclient.SignStatusClient, logger log.Logger) (*lite.DynamicVerifier, error) {
|
||||
func NewVerifier(chainID, rootDir string, client lclient.SignStatusClient, logger log.Logger, cacheSize int) (*lite.DynamicVerifier, error) {
|
||||
|
||||
logger = logger.With("module", "lite/proxy")
|
||||
logger.Info("lite/proxy/NewVerifier()...", "chainID", chainID, "rootDir", rootDir, "client", client)
|
||||
|
||||
memProvider := lite.NewDBProvider("trusted.mem", dbm.NewMemDB()).SetLimit(10)
|
||||
memProvider := lite.NewDBProvider("trusted.mem", dbm.NewMemDB()).SetLimit(cacheSize)
|
||||
lvlProvider := lite.NewDBProvider("trusted.lvl", dbm.NewDB("trust-base", dbm.LevelDBBackend, rootDir))
|
||||
trust := lite.NewMultiProvider(
|
||||
memProvider,
|
||||
|
||||
@@ -134,10 +134,10 @@ func (w Wrapper) Commit(height *int64) (*ctypes.ResultCommit, error) {
|
||||
}
|
||||
rpcclient.WaitForHeight(w.Client, *height, nil)
|
||||
res, err := w.Client.Commit(height)
|
||||
// if we got it, then certify it
|
||||
// if we got it, then verify it
|
||||
if err == nil {
|
||||
sh := res.SignedHeader
|
||||
err = w.cert.Certify(sh)
|
||||
err = w.cert.Verify(sh)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user