Increase block cache size to 400k for faster wallet sync
- Increase default cache-size from 40,000 to 400,000 blocks - Add Python gRPC protobuf bindings for testing
This commit is contained in:
@@ -42,6 +42,9 @@ func (s *SqlStreamer) GetCache() *common.BlockCache {
|
||||
|
||||
func (s *SqlStreamer) GetLatestBlock(ctx context.Context, placeholder *walletrpc.ChainSpec) (*walletrpc.BlockID, error) {
|
||||
latestBlock := s.cache.GetLatestBlock()
|
||||
s.log.WithFields(logrus.Fields{
|
||||
"latestBlock": latestBlock,
|
||||
}).Info("GetLatestBlock called")
|
||||
|
||||
if latestBlock == -1 {
|
||||
return nil, errors.New("Cache is empty. Server is probably not yet ready.")
|
||||
@@ -136,21 +139,47 @@ func (s *SqlStreamer) GetBlock(ctx context.Context, id *walletrpc.BlockID) (*wal
|
||||
}
|
||||
|
||||
func (s *SqlStreamer) GetBlockRange(span *walletrpc.BlockRange, resp walletrpc.CompactTxStreamer_GetBlockRangeServer) error {
|
||||
s.log.WithFields(logrus.Fields{
|
||||
"start": span.Start.Height,
|
||||
"end": span.End.Height,
|
||||
}).Info("GetBlockRange called")
|
||||
|
||||
blockChan := make(chan walletrpc.CompactBlock)
|
||||
errChan := make(chan error)
|
||||
|
||||
go common.GetBlockRange(s.client, s.cache, blockChan, errChan, int(span.Start.Height), int(span.End.Height))
|
||||
|
||||
blockCount := 0
|
||||
for {
|
||||
select {
|
||||
case err := <-errChan:
|
||||
// this will also catch context.DeadlineExceeded from the timeout
|
||||
if err != nil {
|
||||
s.log.WithFields(logrus.Fields{
|
||||
"start": span.Start.Height,
|
||||
"end": span.End.Height,
|
||||
"blocksSent": blockCount,
|
||||
"error": err,
|
||||
}).Error("GetBlockRange error")
|
||||
} else {
|
||||
s.log.WithFields(logrus.Fields{
|
||||
"start": span.Start.Height,
|
||||
"end": span.End.Height,
|
||||
"blocksSent": blockCount,
|
||||
}).Info("GetBlockRange completed")
|
||||
}
|
||||
return err
|
||||
case cBlock := <-blockChan:
|
||||
err := resp.Send(&cBlock)
|
||||
if err != nil {
|
||||
s.log.WithFields(logrus.Fields{
|
||||
"start": span.Start.Height,
|
||||
"end": span.End.Height,
|
||||
"blocksSent": blockCount,
|
||||
"error": err,
|
||||
}).Error("GetBlockRange send error")
|
||||
return err
|
||||
}
|
||||
blockCount++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +268,13 @@ func (s *SqlStreamer) GetTransaction(ctx context.Context, txf *walletrpc.TxFilte
|
||||
func (s *SqlStreamer) GetLightdInfo(ctx context.Context, in *walletrpc.Empty) (*walletrpc.LightdInfo, error) {
|
||||
saplingHeight, blockHeight, chainName, consensusBranchId, difficulty, longestchain, notarized, err := common.GetSaplingInfo(s.client)
|
||||
|
||||
s.log.WithFields(logrus.Fields{
|
||||
"saplingHeight": saplingHeight,
|
||||
"blockHeight": blockHeight,
|
||||
"chainName": chainName,
|
||||
"consensusBranchId": consensusBranchId,
|
||||
}).Info("GetLightdInfo called")
|
||||
|
||||
if err != nil {
|
||||
s.log.WithFields(logrus.Fields{
|
||||
"error": err,
|
||||
|
||||
Reference in New Issue
Block a user