From 5316c3bb4c008c98d129221e6a2a635eb8e55253 Mon Sep 17 00:00:00 2001 From: Adrian Lanzafame Date: Mon, 9 Apr 2018 12:19:47 +1000 Subject: [PATCH] typos and style nitpicks License: MIT Signed-off-by: Adrian Lanzafame --- allocate.go | 7 +++--- allocator/descendalloc/descendalloc.go | 2 +- ipfscluster.go | 6 +++--- pintracker/maptracker/maptracker.go | 30 ++++++++++++++++---------- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/allocate.go b/allocate.go index 3c4b0f12..eab8a2ed 100644 --- a/allocate.go +++ b/allocate.go @@ -12,11 +12,10 @@ import ( // This file gathers allocation logic used when pinning or re-pinning // to find which peers should be allocated to a Cid. Allocation is constrained -// by ReplicationFactorMin and ReplicationFactorMax parametres obtained +// by ReplicationFactorMin and ReplicationFactorMax parameters obtained // from the Pin object. -//The allocation -// process has several steps: +// The allocation process has several steps: // // * Find which peers are pinning a CID // * Obtain the last values for the configured informer metrics from the @@ -164,7 +163,7 @@ func (c *Cluster) obtainAllocations( // Reminder: rplMin <= rplMax AND >0 - if wanted < 0 { // alocations above maximum threshold: drop some + if wanted < 0 { // allocations above maximum threshold: drop some // This could be done more intelligently by dropping them // according to the allocator order (i.e. free-ing peers // with most used space first). diff --git a/allocator/descendalloc/descendalloc.go b/allocator/descendalloc/descendalloc.go index ef4ed28b..a329a539 100644 --- a/allocator/descendalloc/descendalloc.go +++ b/allocator/descendalloc/descendalloc.go @@ -1,4 +1,4 @@ -// Package descendalloc implements an ipfscluster.util.Allocator returns +// Package descendalloc implements an ipfscluster.PinAllocator returns // allocations based on sorting the metrics in descending order. Thus, peers // with largest metrics are first in the list. This allocator can be used with a // number of informers, as long as they provide a numeric metric value. diff --git a/ipfscluster.go b/ipfscluster.go index 32f5cde7..da2982cf 100644 --- a/ipfscluster.go +++ b/ipfscluster.go @@ -119,10 +119,10 @@ type PinTracker interface { // Sync makes sure that the Cid status reflect the real IPFS status. // It returns the local status of the Cid. Sync(*cid.Cid) (api.PinInfo, error) - // Recover retriggers a Pin/Unpin operation in a Cids with error status. - Recover(*cid.Cid) (api.PinInfo, error) // RecoverAll calls Recover() for all pins tracked. RecoverAll() ([]api.PinInfo, error) + // Recover retriggers a Pin/Unpin operation in a Cids with error status. + Recover(*cid.Cid) (api.PinInfo, error) } // Informer provides Metric information from a peer. The metrics produced by @@ -142,7 +142,7 @@ type Informer interface { type PinAllocator interface { Component // Allocate returns the list of peers that should be assigned to - // Pin content in oder of preference (from the most preferred to the + // Pin content in order of preference (from the most preferred to the // least). The "current" map contains valid metrics for peers // which are currently pinning the content. The candidates map // contains the metrics for all peers which are eligible for pinning diff --git a/pintracker/maptracker/maptracker.go b/pintracker/maptracker/maptracker.go index 03c377f9..d471d457 100644 --- a/pintracker/maptracker/maptracker.go +++ b/pintracker/maptracker/maptracker.go @@ -74,6 +74,7 @@ func (mpt *MapPinTracker) pinWorker() { for { select { case p := <-mpt.pinCh: + //TODO(ajl): mpt.pin(p) case <-mpt.ctx.Done(): return @@ -201,12 +202,13 @@ func (mpt *MapPinTracker) isRemote(c api.Pin) bool { func (mpt *MapPinTracker) pin(c api.Pin) error { logger.Debugf("issuing pin call for %s", c.Cid) mpt.set(c.Cid, api.TrackerStatusPinning) - err := mpt.rpcClient.Call("", + err := mpt.rpcClient.Call( + "", "Cluster", "IPFSPin", c.ToSerial(), - &struct{}{}) - + &struct{}{}, + ) if err != nil { mpt.setError(c.Cid, err) return err @@ -219,22 +221,24 @@ func (mpt *MapPinTracker) pin(c api.Pin) error { func (mpt *MapPinTracker) unpin(c api.Pin) error { logger.Debugf("issuing unpin call for %s", c.Cid) mpt.set(c.Cid, api.TrackerStatusUnpinning) - err := mpt.rpcClient.Call("", + err := mpt.rpcClient.Call( + "", "Cluster", "IPFSUnpin", c.ToSerial(), - &struct{}{}) - + &struct{}{}, + ) if err != nil { mpt.setError(c.Cid, err) return err } + mpt.set(c.Cid, api.TrackerStatusUnpinned) return nil } // Track tells the MapPinTracker to start managing a Cid, -// possibly trigerring Pin operations on the IPFS daemon. +// possibly triggering Pin operations on the IPFS daemon. func (mpt *MapPinTracker) Track(c api.Pin) error { logger.Debugf("tracking %s", c.Cid) if mpt.isRemote(c) { @@ -301,11 +305,13 @@ func (mpt *MapPinTracker) StatusAll() []api.PinInfo { // the IPFS daemon. func (mpt *MapPinTracker) Sync(c *cid.Cid) (api.PinInfo, error) { var ips api.IPFSPinStatus - err := mpt.rpcClient.Call("", + err := mpt.rpcClient.Call( + "", "Cluster", "IPFSPinLsCid", api.PinCid(c).ToSerial(), - &ips) + &ips, + ) if err != nil { mpt.setError(c, err) return mpt.get(c), err @@ -324,11 +330,13 @@ func (mpt *MapPinTracker) Sync(c *cid.Cid) (api.PinInfo, error) { func (mpt *MapPinTracker) SyncAll() ([]api.PinInfo, error) { var ipsMap map[string]api.IPFSPinStatus var pInfos []api.PinInfo - err := mpt.rpcClient.Call("", + err := mpt.rpcClient.Call( + "", "Cluster", "IPFSPinLs", "recursive", - &ipsMap) + &ipsMap, + ) if err != nil { mpt.mux.Lock() for k := range mpt.status {