From f367209272faa5afda4f15f94a275ecec31abfed Mon Sep 17 00:00:00 2001 From: Cole Brown Date: Tue, 26 Jun 2018 18:06:34 -0400 Subject: [PATCH] Handle batch Delete error --- addr_manager_ds.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addr_manager_ds.go b/addr_manager_ds.go index c2c75f3..795239d 100644 --- a/addr_manager_ds.go +++ b/addr_manager_ds.go @@ -147,6 +147,7 @@ func (mgr *DatastoreAddrManager) Addrs(p peer.ID) []ma.Multiaddr { addrbytes := result.Value.([]byte) addr, err := ma.NewMultiaddrBytes(addrbytes) if err != nil { + log.Error(err) continue } addrs = append(addrs, addr) @@ -205,7 +206,13 @@ func (mgr *DatastoreAddrManager) ClearAddrs(p peer.ID) { } for result := range results.Next() { - batch.Delete(ds.NewKey(result.Key)) + err := batch.Delete(ds.NewKey(result.Key)) + if err != nil { + // From inspectin badger, errors here signify a problem with + // the transaction as a whole, so we can log and abort. + log.Error(err) + return + } } if err = batch.Commit(); err != nil { log.Errorf("failed to clear addresses for peer %s: %s\n", p.Pretty(), err)