Fix #202: Fix informers and allocators for 32-bit architectures

This commit is contained in:
Hector Sanjuan 2017-10-26 11:45:33 +00:00 committed by Hector Sanjuan
parent 3c48c35920
commit 00e871ddec
5 changed files with 13 additions and 13 deletions

View File

@ -17,13 +17,13 @@ import (
// is false (true), peers will be sorted from smallest to largest (largest to
// smallest) metric
func SortNumeric(candidates map[peer.ID]api.Metric, reverse bool) []peer.ID {
vMap := make(map[peer.ID]int)
vMap := make(map[peer.ID]uint64)
peers := make([]peer.ID, 0, len(candidates))
for k, v := range candidates {
if v.Discard() {
continue
}
val, err := strconv.Atoi(v.Value)
val, err := strconv.ParseUint(v.Value, 10, 64)
if err != nil {
continue
}
@ -43,7 +43,7 @@ func SortNumeric(candidates map[peer.ID]api.Metric, reverse bool) []peer.ID {
// metricSorter implements the sort.Sort interface
type metricSorter struct {
peers []peer.ID
m map[peer.ID]int
m map[peer.ID]uint64
reverse bool
}

View File

@ -76,7 +76,7 @@ func (disk *Informer) GetMetric() api.Metric {
}
}
var metric int
var metric uint64
valid := true
err := disk.rpcClient.Call("",
"Cluster",

View File

@ -79,10 +79,10 @@ type IPFSConnector interface {
ConfigKey(keypath string) (interface{}, error)
// FreeSpace returns the amount of remaining space on the repo, calculated from
//"repo stat"
FreeSpace() (int, error)
FreeSpace() (uint64, error)
// RepoSize returns the current repository size as expressed
// by "repo stat".
RepoSize() (int, error)
RepoSize() (uint64, error)
}
// Peered represents a component which needs to be aware of the peers

View File

@ -81,9 +81,9 @@ type ipfsIDResp struct {
}
type ipfsRepoStatResp struct {
RepoSize int
StorageMax int
NumObjects int
RepoSize uint64
StorageMax uint64
NumObjects uint64
}
type ipfsAddResp struct {
@ -800,7 +800,7 @@ func getConfigValue(path []string, cfg map[string]interface{}) (interface{}, err
// FreeSpace returns the amount of unused space in the ipfs repository. This
// value is derived from the RepoSize and StorageMax values given by "repo
// stats". The value is in bytes.
func (ipfs *Connector) FreeSpace() (int, error) {
func (ipfs *Connector) FreeSpace() (uint64, error) {
res, err := ipfs.post("repo/stat")
if err != nil {
logger.Error(err)
@ -818,7 +818,7 @@ func (ipfs *Connector) FreeSpace() (int, error) {
// RepoSize returns the current repository size of the ipfs daemon as
// provided by "repo stats". The value is in bytes.
func (ipfs *Connector) RepoSize() (int, error) {
func (ipfs *Connector) RepoSize() (uint64, error) {
res, err := ipfs.post("repo/stat")
if err != nil {
logger.Error(err)

View File

@ -243,14 +243,14 @@ func (rpcapi *RPCAPI) IPFSConfigKey(in string, out *interface{}) error {
}
// IPFSFreeSpace runs IPFSConnector.FreeSpace().
func (rpcapi *RPCAPI) IPFSFreeSpace(in struct{}, out *int) error {
func (rpcapi *RPCAPI) IPFSFreeSpace(in struct{}, out *uint64) error {
res, err := rpcapi.c.ipfs.FreeSpace()
*out = res
return err
}
// IPFSRepoSize runs IPFSConnector.RepoSize().
func (rpcapi *RPCAPI) IPFSRepoSize(in struct{}, out *int) error {
func (rpcapi *RPCAPI) IPFSRepoSize(in struct{}, out *uint64) error {
res, err := rpcapi.c.ipfs.RepoSize()
*out = res
return err