Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit 2d928b2

Browse files
committed
Add config for downloading repo migrations
1 parent d75a8c6 commit 2d928b2

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

config.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Config struct {
2929
Pubsub PubsubConfig
3030
Peering Peering
3131
DNS DNS
32+
Migration Migration
3233

3334
Provider Provider
3435
Reprovider Reprovider

init.go

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ func InitWithIdentity(identity Identity) (*Config, error) {
9292
DNS: DNS{
9393
Resolvers: map[string]string{},
9494
},
95+
Migration: Migration{
96+
DownloadSources: DefaultMigrationDownloadSources,
97+
Keep: DefaultMigrationKeep,
98+
},
9599
}
96100

97101
return conf, nil

migration.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package config
2+
3+
import "github.com/libp2p/go-libp2p-core/peer"
4+
5+
const DefaultMigrationKeep = "cache"
6+
7+
var DefaultMigrationDownloadSources = []string{"HTTPS", "IPFS"}
8+
9+
// Migration configures how migrations are downloaded and if the downloads are
10+
// added to IPFS locally
11+
type Migration struct {
12+
// Sources in order of preference where "HTTPS" means our gateways and
13+
// "IPFS" means over IPFS. Any other values are interpretes as hostnames
14+
// for custom gateways. An empty list means "do the default thing"
15+
DownloadSources []string
16+
// Whether or not to keep the migration after downloading it.
17+
// Options are "discard", "cache", "pin". Empty string for default.
18+
Keep string
19+
// Peers lists the nodes to attempt to connect with when downloading
20+
// migrations.
21+
Peers []peer.AddrInfo
22+
}

0 commit comments

Comments
 (0)