routing: implement FilterBlock for mockChainView

This commit is contained in:
Olaoluwa Osuntokun 2017-11-06 15:56:23 -08:00
parent 5f915280bc
commit 4f32ee94ea
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -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 {