Skip to content

Commit 18dcc29

Browse files
committed
Use the new storethehash with index GC
1 parent ffd300c commit 18dcc29

5 files changed

Lines changed: 19 additions & 17 deletions

File tree

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ require (
77
github.com/gammazero/keymutex v0.0.2
88
github.com/gammazero/radixtree v0.2.5
99
github.com/ipfs/go-cid v0.1.0
10-
github.com/ipfs/go-log/v2 v2.5.0
11-
github.com/ipld/go-storethehash v0.0.2
10+
github.com/ipfs/go-log/v2 v2.5.1
11+
github.com/ipld/go-storethehash v0.1.0
1212
github.com/libp2p/go-libp2p-core v0.14.0
1313
github.com/multiformats/go-multihash v0.1.0
1414
go.opencensus.io v0.23.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ github.com/ipfs/go-ipld-format v0.0.1/go.mod h1:kyJtbkDALmFHv3QR6et67i35QzO3S0dC
128128
github.com/ipfs/go-ipld-format v0.0.2/go.mod h1:4B6+FM2u9OJ9zCV+kSbgFAZlOrv1Hqbf0INGQgiKf9k=
129129
github.com/ipfs/go-log v0.0.1 h1:9XTUN/rW64BCG1YhPK9Hoy3q8nr4gOmHHBpgFdfw6Lc=
130130
github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM=
131-
github.com/ipfs/go-log/v2 v2.5.0 h1:+MhAooFd9XZNvR0i9FriKW6HB0ql7HNXUuflWtc0dd4=
132-
github.com/ipfs/go-log/v2 v2.5.0/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI=
131+
github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY=
132+
github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI=
133133
github.com/ipfs/go-merkledag v0.2.3/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk=
134134
github.com/ipfs/go-merkledag v0.2.4/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk=
135135
github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY=
@@ -140,8 +140,8 @@ github.com/ipld/go-car v0.1.0 h1:AaIEA5ITRnFA68uMyuIPYGM2XXllxsu8sNjFJP797us=
140140
github.com/ipld/go-car v0.1.0/go.mod h1:RCWzaUh2i4mOEkB3W45Vc+9jnS/M6Qay5ooytiBHl3g=
141141
github.com/ipld/go-ipld-prime v0.0.2-0.20191108012745-28a82f04c785/go.mod h1:bDDSvVz7vaK12FNvMeRYnpRFkSUPNQOiCYQezMD/P3w=
142142
github.com/ipld/go-ipld-prime-proto v0.0.0-20191113031812-e32bd156a1e5/go.mod h1:gcvzoEDBjwycpXt3LBE061wT9f46szXGHAmj9uoP6fU=
143-
github.com/ipld/go-storethehash v0.0.2 h1:PFAlcTG2RoS6Cwbes3J/X/NvuNTj+wgF1x0OED4x6bw=
144-
github.com/ipld/go-storethehash v0.0.2/go.mod h1:w8cQfWInks8lvvbQTiKbCPusU9v0sqiViBihTHbavpQ=
143+
github.com/ipld/go-storethehash v0.1.0 h1:HBa59pCuL33fLN8PekX+lq6vq1UlWCFxtfyLiN030ng=
144+
github.com/ipld/go-storethehash v0.1.0/go.mod h1:d3m79FZzARANjjBwZ1rNgyGUK+1M5m0SLHrarmJzcYo=
145145
github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA=
146146
github.com/jackpal/go-nat-pmp v1.0.1/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
147147
github.com/jbenet/go-cienv v0.0.0-20150120210510-1bb1476777ec/go.mod h1:rGaEvXB4uRSZMmzKNLoXvTu1sfx+1kv/DojUlPrSZGs=

store/storethehash/option.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const (
1111
defaultBurstRate = 4 * 1024 * 1024
1212
defaultIndexSizeBits = uint8(24)
1313
defaultSyncInterval = time.Second
14+
defaultGCInterval = 30 * time.Minute
1415
)
1516

1617
// config contains all options for configuring storethehash valuestore.
@@ -44,6 +45,11 @@ func SyncInterval(syncInterval time.Duration) Option {
4445
func BurstRate(burstRate uint64) Option {
4546
return func(cfg *config) {
4647
cfg.burstRate = sthtypes.Work(burstRate)
48+
}
49+
}
4750

51+
func GCInterval(gcInterval time.Duration) Option {
52+
return func(cfg *config) {
53+
cfg.gcInterval = gcInterval
4854
}
4955
}

store/storethehash/storethehash.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ func New(dir string, options ...Option) (indexer.Interface, error) {
6161
indexSizeBits: defaultIndexSizeBits,
6262
syncInterval: defaultSyncInterval,
6363
burstRate: defaultBurstRate,
64+
gcInterval: defaultGCInterval,
6465
}
6566
cfg.apply(options)
6667

67-
s, err := sth.OpenStore(indexPath, primary, cfg.indexSizeBits, cfg.syncInterval, cfg.burstRate)
68+
s, err := sth.OpenStore(indexPath, primary, cfg.indexSizeBits, cfg.syncInterval, cfg.burstRate, cfg.gcInterval)
6869
if err != nil {
6970
return nil, err
7071
}
@@ -180,22 +181,17 @@ func (s *sthStorage) RemoveProviderContext(providerID peer.ID, contextID []byte)
180181
}
181182

182183
func (s *sthStorage) Size() (int64, error) {
183-
var size int64
184-
fi, err := os.Stat(filepath.Join(s.dir, "storethehash.data"))
185-
if err != nil {
186-
return 0, err
187-
}
188-
size += fi.Size()
189-
fi, err = os.Stat(filepath.Join(s.dir, "storethehash.index"))
184+
size, err := s.store.IndexStorageSize()
190185
if err != nil {
191186
return 0, err
192187
}
193-
size += fi.Size()
194-
fi, err = os.Stat(filepath.Join(s.dir, "storethehash.index.free"))
188+
189+
fi, err := os.Stat(filepath.Join(s.dir, "storethehash.data"))
195190
if err != nil {
196191
return 0, err
197192
}
198193
size += fi.Size()
194+
199195
return size, nil
200196
}
201197

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "v0.2.9"
2+
"version": "v0.2.10"
33
}

0 commit comments

Comments
 (0)