From 623d67234d579797d0b72a6968bf2007c70e57d3 Mon Sep 17 00:00:00 2001 From: Tadge Dryja Date: Fri, 26 Feb 2016 12:30:15 -0800 Subject: [PATCH] was requesting an already known block, fixed that --- uspv/eight333.go | 10 +++++----- uspv/hardmode.go | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/uspv/eight333.go b/uspv/eight333.go index 5a6478a3..4eb525ac 100644 --- a/uspv/eight333.go +++ b/uspv/eight333.go @@ -349,7 +349,7 @@ func (s *SPVCon) AskForBlocks() error { return nil } - fmt.Printf("will request blocks %d to %d\n", dbTip, headerTip) + fmt.Printf("will request blocks %d to %d\n", dbTip+1, headerTip) if !s.HardMode { // don't send this in hardmode! that's the whole point // create initial filter @@ -362,9 +362,10 @@ func (s *SPVCon) AskForBlocks() error { fmt.Printf("sent filter %x\n", filt.MsgFilterLoad().Filter) } // loop through all heights where we want merkleblocks. - for dbTip <= headerTip { - // load header from file + for dbTip < headerTip { + dbTip++ // we're requesting the next header + // load header from file s.headerMutex.Lock() // seek to header we need _, err = s.headerFile.Seek(int64((dbTip)*80), os.SEEK_SET) if err != nil { @@ -392,6 +393,7 @@ func (s *SPVCon) AskForBlocks() error { if err != nil { return err } + hah := NewRootAndHeight(hdr.BlockSha(), dbTip) if dbTip == headerTip { // if this is the last block, indicate finality hah.final = true @@ -399,8 +401,6 @@ func (s *SPVCon) AskForBlocks() error { // waits here most of the time for the queue to empty out s.blockQueue <- hah // push height and mroot of requested block on queue s.outMsgQueue <- gdataMsg - - dbTip++ } return nil } diff --git a/uspv/hardmode.go b/uspv/hardmode.go index 445d1029..bc40e2c8 100644 --- a/uspv/hardmode.go +++ b/uspv/hardmode.go @@ -179,7 +179,7 @@ func (s *SPVCon) IngestBlock(m *wire.MsgBlock) { // iterate through all txs in the block, looking for matches. // use a local bloom filter to ignore txs that don't affect us - for i, tx := range m.Transactions { + for _, tx := range m.Transactions { utilTx := btcutil.NewTx(tx) if s.TS.localFilter.MatchTxAndUpdate(utilTx) { hits, err := s.TS.Ingest(tx, hah.height) @@ -188,8 +188,8 @@ func (s *SPVCon) IngestBlock(m *wire.MsgBlock) { return } if hits > 0 { - log.Printf("block %d tx %d %s ingested and matches %d utxo/adrs.", - hah.height, i, tx.TxSha().String(), hits) + // log.Printf("block %d tx %d %s ingested and matches %d utxo/adrs.", + // hah.height, i, tx.TxSha().String(), hits) } else { fPositive++ // matched filter but no hits }