Skip to content

Commit

Permalink
Issue #446 Adding peername to PinInfo
Browse files Browse the repository at this point in the history
Fixing errors and better code placement

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
  • Loading branch information
kishansagathiya committed Sep 24, 2018
1 parent 61c03e2 commit 0580fd5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,21 @@ func (gpis GlobalPinInfoSerial) ToGlobalPinInfo() GlobalPinInfo {
type PinInfo struct {
Cid cid.Cid
Peer peer.ID
PeerName string
Status TrackerStatus
TS time.Time
Error string
PeerName string
}

// PinInfoSerial is a serializable version of PinInfo.
// information is marked as
type PinInfoSerial struct {
Cid string `json:"cid"`
Peer string `json:"peer"`
PeerName string `json:"peername"`
Status string `json:"status"`
TS string `json:"timestamp"`
Error string `json:"error"`
PeerName string `json:"peername"`
}

// ToSerial converts a PinInfo to its serializable version.
Expand Down
2 changes: 1 addition & 1 deletion cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ func (c *Cluster) globalPinInfoCid(method string, h cid.Cid) (api.GlobalPinInfo,
Status: api.TrackerStatusClusterError,
TS: time.Now(),
Error: e.Error(),
PeerName: c.config.Peername,
PeerName: string(members[i]),
}
} else { // there was an rpc error, but got a valid response :S
r.Error = e.Error()
Expand Down
6 changes: 5 additions & 1 deletion ipfs-cluster-ctl/formatters.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ func textFormatPrintGPInfo(obj *api.GlobalPinInfoSerial) {

for _, k := range peers {
v := obj.PeerMap[k]
fmt.Printf(" > Peer %-10s : %s", v.PeerName, strings.ToUpper(v.Status))
if len(v.PeerName) > 0 {
fmt.Printf(" > %-15s : %s", v.PeerName, strings.ToUpper(v.Status))
} else {
fmt.Printf(" > %-15s : %s", k, strings.ToUpper(v.Status))
}
if v.Error != "" {
fmt.Printf(": %s", v.Error)
}
Expand Down
4 changes: 2 additions & 2 deletions pintracker/optracker/operationtracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ func (opt *OperationTracker) unsafePinInfo(op *Operation) api.PinInfo {
return api.PinInfo{
Cid: cid.Undef,
Peer: opt.pid,
PeerName: opt.peerName,
Status: api.TrackerStatusUnpinned,
TS: time.Now(),
Error: "",
PeerName: opt.peerName,
}
}
return api.PinInfo{
Cid: op.Cid(),
Peer: opt.pid,
PeerName: opt.peerName,
Status: op.ToTrackerStatus(),
TS: op.Timestamp(),
Error: op.Error(),
PeerName: opt.peerName,
}
}

Expand Down

0 comments on commit 0580fd5

Please sign in to comment.