routing: add quit channel to mockChainView
This commit is contained in:
parent
4f32ee94ea
commit
fea8cbf920
@ -213,6 +213,8 @@ type mockChainView struct {
|
|||||||
staleBlocks chan *chainview.FilteredBlock
|
staleBlocks chan *chainview.FilteredBlock
|
||||||
|
|
||||||
filter map[wire.OutPoint]struct{}
|
filter map[wire.OutPoint]struct{}
|
||||||
|
|
||||||
|
quit chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A compile time check to ensure mockChainView implements the
|
// A compile time check to ensure mockChainView implements the
|
||||||
@ -224,6 +226,7 @@ func newMockChainView() *mockChainView {
|
|||||||
newBlocks: make(chan *chainview.FilteredBlock, 10),
|
newBlocks: make(chan *chainview.FilteredBlock, 10),
|
||||||
staleBlocks: make(chan *chainview.FilteredBlock, 10),
|
staleBlocks: make(chan *chainview.FilteredBlock, 10),
|
||||||
filter: make(map[wire.OutPoint]struct{}),
|
filter: make(map[wire.OutPoint]struct{}),
|
||||||
|
quit: make(chan struct{}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,10 +247,14 @@ func (m *mockChainView) notifyBlock(hash chainhash.Hash, height uint32,
|
|||||||
m.RLock()
|
m.RLock()
|
||||||
defer m.RUnlock()
|
defer m.RUnlock()
|
||||||
|
|
||||||
m.newBlocks <- &chainview.FilteredBlock{
|
select {
|
||||||
|
case m.newBlocks <- &chainview.FilteredBlock{
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Height: height,
|
Height: height,
|
||||||
Transactions: txns,
|
Transactions: txns,
|
||||||
|
}:
|
||||||
|
case <-m.quit:
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,10 +264,14 @@ func (m *mockChainView) notifyStaleBlock(hash chainhash.Hash, height uint32,
|
|||||||
m.RLock()
|
m.RLock()
|
||||||
defer m.RUnlock()
|
defer m.RUnlock()
|
||||||
|
|
||||||
m.staleBlocks <- &chainview.FilteredBlock{
|
select {
|
||||||
|
case m.staleBlocks <- &chainview.FilteredBlock{
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Height: height,
|
Height: height,
|
||||||
Transactions: txns,
|
Transactions: txns,
|
||||||
|
}:
|
||||||
|
case <-m.quit:
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user