GetBlockRange: don't pass mutex in channel (linter warning)

This commit is contained in:
Larry Ruane 2020-05-09 11:45:50 -06:00 committed by Larry Ruane
parent 22d5c97e7f
commit 9371f984ae
3 changed files with 5 additions and 5 deletions

View File

@ -253,7 +253,7 @@ func GetBlock(cache *BlockCache, height int) (*walletrpc.CompactBlock, error) {
}
// GetBlockRange returns a sequence of consecutive blocks in the given range.
func GetBlockRange(cache *BlockCache, blockOut chan<- walletrpc.CompactBlock, errOut chan<- error, start, end int) {
func GetBlockRange(cache *BlockCache, blockOut chan<- *walletrpc.CompactBlock, errOut chan<- error, start, end int) {
// Go over [start, end] inclusive
for i := start; i <= end; i++ {
block, err := GetBlock(cache, i)
@ -261,7 +261,7 @@ func GetBlockRange(cache *BlockCache, blockOut chan<- walletrpc.CompactBlock, er
errOut <- err
return
}
blockOut <- *block
blockOut <- block
}
errOut <- nil
}

View File

@ -282,7 +282,7 @@ func TestGetBlockRange(t *testing.T) {
RawRequest = getblockStub
os.RemoveAll(unitTestPath)
testcache := NewBlockCache(unitTestPath, unitTestChain, 380640, true)
blockChan := make(chan walletrpc.CompactBlock)
blockChan := make(chan *walletrpc.CompactBlock)
errChan := make(chan error)
go GetBlockRange(testcache, blockChan, errChan, 380640, 380642)

View File

@ -129,7 +129,7 @@ func (s *LwdStreamer) GetBlock(ctx context.Context, id *walletrpc.BlockID) (*wal
// (as also returned by GetBlock) from the block height 'start' to height
// 'end' inclusively.
func (s *LwdStreamer) GetBlockRange(span *walletrpc.BlockRange, resp walletrpc.CompactTxStreamer_GetBlockRangeServer) error {
blockChan := make(chan walletrpc.CompactBlock)
blockChan := make(chan *walletrpc.CompactBlock)
errChan := make(chan error)
go common.GetBlockRange(s.cache, blockChan, errChan, int(span.Start.Height), int(span.End.Height))
@ -140,7 +140,7 @@ func (s *LwdStreamer) GetBlockRange(span *walletrpc.BlockRange, resp walletrpc.C
// this will also catch context.DeadlineExceeded from the timeout
return err
case cBlock := <-blockChan:
err := resp.Send(&cBlock)
err := resp.Send(cBlock)
if err != nil {
return err
}