Commit 96e45c74 authored by Tommi Virtanen's avatar Tommi Virtanen Committed by Jeromy

Use uint64 for indirect pin refcounts

Platform-dependent behavior is not nice, and negative refcounts are
not very useful.

License: MIT
Signed-off-by: default avatarJeromy <jeromyj@gmail.com>
parent fecfb76c
......@@ -275,7 +275,7 @@ Example:
type RefKeyObject struct {
Type string
Count int
Count uint64
}
type RefKeyList struct {
......
......@@ -6,23 +6,23 @@ import (
)
type indirectPin struct {
refCounts map[key.Key]int
refCounts map[key.Key]uint64
}
func newIndirectPin() *indirectPin {
return &indirectPin{
refCounts: make(map[key.Key]int),
refCounts: make(map[key.Key]uint64),
}
}
func loadIndirPin(d ds.Datastore, k ds.Key) (*indirectPin, error) {
var rcStore map[string]int
var rcStore map[string]uint64
err := loadSet(d, k, &rcStore)
if err != nil {
return nil, err
}
refcnt := make(map[key.Key]int)
refcnt := make(map[key.Key]uint64)
var keys []key.Key
for encK, v := range rcStore {
if v > 0 {
......@@ -38,7 +38,7 @@ func loadIndirPin(d ds.Datastore, k ds.Key) (*indirectPin, error) {
func storeIndirPin(d ds.Datastore, k ds.Key, p *indirectPin) error {
rcStore := map[string]int{}
rcStore := map[string]uint64{}
for k, v := range p.refCounts {
rcStore[key.B58KeyEncode(k)] = v
}
......@@ -65,6 +65,6 @@ func (i *indirectPin) HasKey(k key.Key) bool {
return found
}
func (i *indirectPin) GetRefs() map[key.Key]int {
func (i *indirectPin) GetRefs() map[key.Key]uint64 {
return i.refCounts
}
......@@ -46,7 +46,7 @@ type Pinner interface {
Flush() error
DirectKeys() []key.Key
IndirectKeys() map[key.Key]int
IndirectKeys() map[key.Key]uint64
RecursiveKeys() []key.Key
}
......@@ -254,7 +254,7 @@ func (p *pinner) DirectKeys() []key.Key {
}
// IndirectKeys returns a slice containing the indirectly pinned keys
func (p *pinner) IndirectKeys() map[key.Key]int {
func (p *pinner) IndirectKeys() map[key.Key]uint64 {
return p.indirPin.GetRefs()
}
......
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