From 4f32ee94ea60f1ea30902d98ae67a8836b581175 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 6 Nov 2017 15:56:23 -0800 Subject: [PATCH] routing: implement FilterBlock for mockChainView --- routing/notifications_test.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/routing/notifications_test.go b/routing/notifications_test.go index 1f24c398..961d097f 100644 --- a/routing/notifications_test.go +++ b/routing/notifications_test.go @@ -273,7 +273,31 @@ func (m *mockChainView) DisconnectedBlocks() <-chan *chainview.FilteredBlock { } func (m *mockChainView) FilterBlock(blockHash *chainhash.Hash) (*chainview.FilteredBlock, error) { - return &chainview.FilteredBlock{}, nil + + block, err := m.chain.GetBlock(blockHash) + if err != nil { + return nil, err + } + + filteredBlock := &chainview.FilteredBlock{} + for _, tx := range block.Transactions { + for _, txIn := range tx.TxIn { + prevOp := txIn.PreviousOutPoint + if _, ok := m.filter[prevOp]; ok { + filteredBlock.Transactions = append( + filteredBlock.Transactions, tx, + ) + + m.Lock() + delete(m.filter, prevOp) + m.Unlock() + + break + } + } + } + + return filteredBlock, nil } func (m *mockChainView) Start() error {