Commit ed450992 authored by Jeromy's avatar Jeromy

tracking down a bug dhthell found, added asserts and better logging.

parent 15d4f829
......@@ -101,7 +101,6 @@ func (s *BlockService) GetBlock(ctx context.Context, k u.Key) (*blocks.Block, er
func (s *BlockService) GetBlocks(ctx context.Context, ks []u.Key) <-chan *blocks.Block {
out := make(chan *blocks.Block, 32)
go func() {
defer close(out)
var toFetch []u.Key
for _, k := range ks {
block, err := s.Blockstore.Get(k)
......@@ -121,6 +120,7 @@ func (s *BlockService) GetBlocks(ctx context.Context, ks []u.Key) <-chan *blocks
for blk := range nblocks {
out <- blk
}
close(out)
}()
return out
}
......
......@@ -197,13 +197,19 @@ func (bs *bitswap) loop(parent context.Context) {
}
}
case ks := <-bs.batchRequests:
// TODO: implement batching on len(ks) > X for some X
if len(ks) == 0 {
log.Warning("Received batch request for zero blocks")
continue
}
for _, k := range ks {
bs.wantlist.Add(k)
providers := bs.routing.FindProvidersAsync(ctx, k, maxProvidersPerRequest)
err := bs.sendWantListTo(ctx, providers)
if err != nil {
log.Errorf("error sending wantlist: %s", err)
}
}
providers := bs.routing.FindProvidersAsync(ctx, ks[0], maxProvidersPerRequest)
err := bs.sendWantListTo(ctx, providers)
if err != nil {
log.Errorf("error sending wantlist: %s", err)
}
case <-parent.Done():
return
......
......@@ -182,7 +182,7 @@ func (s *Swarm) fanOut() {
return
}
if len(msg.Data()) >= conn.MaxMessageSize {
log.Critical("Attempted to send message bigger than max size.")
log.Criticalf("Attempted to send message bigger than max size. (%d)", len(msg.Data()))
}
s.connsLock.RLock()
......
......@@ -68,6 +68,7 @@ func (dr *DagReader) precalcNextBuf() error {
// TODO: this logic is hard to follow, do it better.
// NOTE: the only time this code is used, is during the
// importer tests, consider just changing those tests
log.Warning("Running DAGReader with nil DAGService!")
if dr.linkPosition >= len(dr.node.Links) {
return io.EOF
}
......@@ -78,6 +79,9 @@ func (dr *DagReader) precalcNextBuf() error {
dr.linkPosition++
} else {
if dr.fetchChan == nil {
panic("this is wrong.")
}
select {
case nxt, ok = <-dr.fetchChan:
if !ok {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment