add in dag removal
Jeromy committed
Oct 25, 2014 at 03:36 UTC
e1f2fe75f8420e122580135fc6b523a6f8cbb159
4 files changed
+23
-2
blockservice/blockservice.go
+4
@@ -76,3 +76,7 @@ func (s *BlockService) GetBlock(ctx context.Context, k u.Key) (*blocks.Block, er
76
return nil, u.ErrNotFound
77
}
78
}
79
+
80
+func (s *BlockService) DeleteBlock(k u.Key) error {
81
+ return s.Datastore.Delete(k.DsKey())
82
+}
exchange/bitswap/bitswap.go
+1
-1
@@ -94,7 +94,7 @@ func (bs *bitswap) Block(parent context.Context, k u.Key) (*blocks.Block, error)
94
95
response, err := bs.sender.SendRequest(ctx, p, message)
96
if err != nil {
97
- log.Errorf("Error sender.SendRequest(%s)", p)
97
+ log.Error("Error sender.SendRequest(%s) = %s", p, err)
98
return
99
}
100
// FIXME ensure accounting is handled correctly when
merkledag/merkledag.go
+13
@@ -215,3 +215,16 @@ func (n *DAGService) Get(k u.Key) (*Node, error) {
215
216
return Decoded(b.Data)
217
}
218
+
219
+func (n *DAGService) Remove(nd *Node) error {
220
+ for _, l := range nd.Links {
221
+ if l.Node != nil {
222
+ n.Remove(l.Node)
223
+ }
224
+ }
225
+ k, err := nd.Key()
226
+ if err != nil {
227
+ return err
228
+ }
229
+ return n.Blocks.DeleteBlock(k)
230
+}
routing/dht/dht.go
+5
-1
@@ -540,7 +540,11 @@ func (dht *IpfsDHT) PingRoutine(t time.Duration) {
540
func (dht *IpfsDHT) Bootstrap(ctx context.Context) {
541
id := make([]byte, 16)
542
rand.Read(id)
543
- _, err := dht.FindPeer(ctx, peer.ID(id))
543
+ p, err := dht.FindPeer(ctx, peer.ID(id))
544
+ if err != nil {
545
+ log.Error("Bootstrap peer error: %s", err)
546
+ }
547
+ err = dht.dialer.DialPeer(p)
548
if err != nil {
549
log.Errorf("Bootstrap peer error: %s", err)
550
}