GetBlockRange: don't pass mutex in channel (linter warning)
This commit is contained in:
parent
22d5c97e7f
commit
9371f984ae
|
@ -253,7 +253,7 @@ func GetBlock(cache *BlockCache, height int) (*walletrpc.CompactBlock, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockRange returns a sequence of consecutive blocks in the given range.
|
// 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
|
// Go over [start, end] inclusive
|
||||||
for i := start; i <= end; i++ {
|
for i := start; i <= end; i++ {
|
||||||
block, err := GetBlock(cache, i)
|
block, err := GetBlock(cache, i)
|
||||||
|
@ -261,7 +261,7 @@ func GetBlockRange(cache *BlockCache, blockOut chan<- walletrpc.CompactBlock, er
|
||||||
errOut <- err
|
errOut <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
blockOut <- *block
|
blockOut <- block
|
||||||
}
|
}
|
||||||
errOut <- nil
|
errOut <- nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,7 +282,7 @@ func TestGetBlockRange(t *testing.T) {
|
||||||
RawRequest = getblockStub
|
RawRequest = getblockStub
|
||||||
os.RemoveAll(unitTestPath)
|
os.RemoveAll(unitTestPath)
|
||||||
testcache := NewBlockCache(unitTestPath, unitTestChain, 380640, true)
|
testcache := NewBlockCache(unitTestPath, unitTestChain, 380640, true)
|
||||||
blockChan := make(chan walletrpc.CompactBlock)
|
blockChan := make(chan *walletrpc.CompactBlock)
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
go GetBlockRange(testcache, blockChan, errChan, 380640, 380642)
|
go GetBlockRange(testcache, blockChan, errChan, 380640, 380642)
|
||||||
|
|
||||||
|
|
|
@ -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
|
// (as also returned by GetBlock) from the block height 'start' to height
|
||||||
// 'end' inclusively.
|
// 'end' inclusively.
|
||||||
func (s *LwdStreamer) GetBlockRange(span *walletrpc.BlockRange, resp walletrpc.CompactTxStreamer_GetBlockRangeServer) error {
|
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)
|
errChan := make(chan error)
|
||||||
|
|
||||||
go common.GetBlockRange(s.cache, blockChan, errChan, int(span.Start.Height), int(span.End.Height))
|
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
|
// this will also catch context.DeadlineExceeded from the timeout
|
||||||
return err
|
return err
|
||||||
case cBlock := <-blockChan:
|
case cBlock := <-blockChan:
|
||||||
err := resp.Send(&cBlock)
|
err := resp.Send(cBlock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue