Commit 17d72d8d authored by gpestana's avatar gpestana

Adds more and better logging

parent 0073e120
...@@ -6,4 +6,7 @@ gx: ...@@ -6,4 +6,7 @@ gx:
deps: gx deps: gx
gx --verbose install --global gx --verbose install --global
gx-go rewrite gx-go rewrite
\ No newline at end of file
publish:
gx-go rewrite --undo
...@@ -150,15 +150,15 @@ func (dht *IpfsDHT) putValueToPeer(ctx context.Context, p peer.ID, ...@@ -150,15 +150,15 @@ func (dht *IpfsDHT) putValueToPeer(ctx context.Context, p peer.ID,
pmes.Record = rec pmes.Record = rec
rpmes, err := dht.sendRequest(ctx, p, pmes) rpmes, err := dht.sendRequest(ctx, p, pmes)
if err != nil { if err != nil {
if err == ErrReadTimeout { log.Warningf("putValueToPeer: %s. (peer: %s, key: %s)", err.Error(), p.Pretty(), key)
log.Warningf("read timeout: %s %s", p.Pretty(), key)
}
return err return err
} }
if !bytes.Equal(rpmes.GetRecord().Value, pmes.GetRecord().Value) { if !bytes.Equal(rpmes.GetRecord().Value, pmes.GetRecord().Value) {
log.Warningf("putValueToPeer: value not put correctly. (%v != %v)", pmes, rpmes)
return errors.New("value not put correctly") return errors.New("value not put correctly")
} }
return nil return nil
} }
...@@ -218,7 +218,7 @@ func (dht *IpfsDHT) getValueSingle(ctx context.Context, p peer.ID, key string) ( ...@@ -218,7 +218,7 @@ func (dht *IpfsDHT) getValueSingle(ctx context.Context, p peer.ID, key string) (
case nil: case nil:
return resp, nil return resp, nil
case ErrReadTimeout: case ErrReadTimeout:
log.Warningf("read timeout: %s %s", p.Pretty(), key) log.Warningf("getValueSingle: read timeout %s %s", p.Pretty(), key)
fallthrough fallthrough
default: default:
eip.SetError(err) eip.SetError(err)
...@@ -231,12 +231,13 @@ func (dht *IpfsDHT) getLocal(key string) (*recpb.Record, error) { ...@@ -231,12 +231,13 @@ func (dht *IpfsDHT) getLocal(key string) (*recpb.Record, error) {
log.Debugf("getLocal %s", key) log.Debugf("getLocal %s", key)
rec, err := dht.getRecordFromDatastore(mkDsKey(key)) rec, err := dht.getRecordFromDatastore(mkDsKey(key))
if err != nil { if err != nil {
log.Warningf("getLocal: %v", err.Error())
return nil, err return nil, err
} }
// Double check the key. Can't hurt. // Double check the key. Can't hurt.
if rec != nil && rec.GetKey() != key { if rec != nil && rec.GetKey() != key {
log.Errorf("BUG: found a DHT record that didn't match it's key: %s != %s", rec.GetKey(), key) log.Errorf("BUG getLocal: found a DHT record that didn't match it's key: %s != %s", rec.GetKey(), key)
return nil, nil return nil, nil
} }
...@@ -256,8 +257,10 @@ func (dht *IpfsDHT) getOwnPrivateKey() (ci.PrivKey, error) { ...@@ -256,8 +257,10 @@ func (dht *IpfsDHT) getOwnPrivateKey() (ci.PrivKey, error) {
// putLocal stores the key value pair in the datastore // putLocal stores the key value pair in the datastore
func (dht *IpfsDHT) putLocal(key string, rec *recpb.Record) error { func (dht *IpfsDHT) putLocal(key string, rec *recpb.Record) error {
log.Debugf("putLocal: %v %v", key, rec)
data, err := proto.Marshal(rec) data, err := proto.Marshal(rec)
if err != nil { if err != nil {
log.Warningf("putLocal: %v", err.Error())
return err return err
} }
...@@ -334,7 +337,7 @@ func (dht *IpfsDHT) betterPeersToQuery(pmes *pb.Message, p peer.ID, count int) [ ...@@ -334,7 +337,7 @@ func (dht *IpfsDHT) betterPeersToQuery(pmes *pb.Message, p peer.ID, count int) [
// no node? nil // no node? nil
if closer == nil { if closer == nil {
log.Warning("no closer peers to send:", p) log.Warning("betterPeersToQuery: no closer peers to send:", p)
return nil return nil
} }
...@@ -343,7 +346,7 @@ func (dht *IpfsDHT) betterPeersToQuery(pmes *pb.Message, p peer.ID, count int) [ ...@@ -343,7 +346,7 @@ func (dht *IpfsDHT) betterPeersToQuery(pmes *pb.Message, p peer.ID, count int) [
// == to self? thats bad // == to self? thats bad
if clp == dht.self { if clp == dht.self {
log.Warning("attempted to return self! this shouldn't happen...") log.Error("BUG betterPeersToQuery: attempted to return self! this shouldn't happen...")
return nil return nil
} }
// Dont send a peer back themselves // Dont send a peer back themselves
......
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