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

Commit 0fb5b58

Browse files
committed
refactor: use custom types
This enables us to swap defaults in go-ipfs without touching the config file generated during `ipfs init` #146 (comment) #146 (comment)
1 parent 0226122 commit 0fb5b58

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

profile.go

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ fetching may be degraded.
179179
c.Swarm.ConnMgr.LowWater = 20
180180
c.Swarm.ConnMgr.HighWater = 40
181181
c.Swarm.ConnMgr.GracePeriod = time.Minute.String()
182+
c.Swarm.RelayService.Enabled = False
182183
return nil
183184
},
184185
},

swarm.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ type SwarmConfig struct {
1919
// `Transports.Relay` if specified.
2020
DisableRelay bool `json:",omitempty"`
2121

22-
// DisableRelayService disables the limited relay (circuit v2 relay).
23-
DisableRelayService bool
24-
25-
RelayServiceOpts RelayResources
22+
RelayService RelayService
2623

2724
// EnableAutoRelay enables the "auto relay" feature.
2825
//
29-
// When both EnableAutoRelay and EnableRelayHop are set, this go-ipfs node
26+
// When both EnableAutoRelay and RelayService.Enabled are set, this go-ipfs node
3027
// will advertise itself as a public relay. Otherwise it will find and use
3128
// advertised public relays when it determines that it's not reachable
3229
// from the public internet.
@@ -39,36 +36,39 @@ type SwarmConfig struct {
3936
ConnMgr ConnMgr
4037
}
4138

42-
// RelayResources configures the resources of the relay.
43-
// For any value set to 0, a reasonable default will be used.
44-
type RelayResources struct {
39+
// RelayService configures the resources of the circuit v2 relay.
40+
// For every field a reasonable default will be defined in go-ipfs.
41+
type RelayService struct {
42+
// Enables the limited relay (circuit v2 relay).
43+
Enabled Flag
44+
4545
// Limit is the (optional) relayed connection limits.
4646
Limit RelayLimit
4747

4848
// ReservationTTL is the duration of a new (or refreshed reservation).
4949
ReservationTTL Duration
5050

5151
// MaxReservations is the maximum number of active relay slots.
52-
MaxReservations int
52+
MaxReservations OptionalInteger
5353
// MaxCircuits is the maximum number of open relay connections for each peer; defaults to 16.
54-
MaxCircuits int
54+
MaxCircuits OptionalInteger
5555
// BufferSize is the size of the relayed connection buffers.
56-
BufferSize int
56+
BufferSize OptionalInteger
5757

5858
// MaxReservationsPerPeer is the maximum number of reservations originating from the same peer.
59-
MaxReservationsPerPeer int
59+
MaxReservationsPerPeer OptionalInteger
6060
// MaxReservationsPerIP is the maximum number of reservations originating from the same IP address.
61-
MaxReservationsPerIP int
61+
MaxReservationsPerIP OptionalInteger
6262
// MaxReservationsPerASN is the maximum number of reservations origination from the same ASN.
63-
MaxReservationsPerASN int
63+
MaxReservationsPerASN OptionalInteger
6464
}
6565

6666
// RelayLimit are the per relayed connection resource limits.
6767
type RelayLimit struct {
6868
// Duration is the time limit before resetting a relayed connection.
6969
Duration Duration
7070
// Data is the limit of data relayed (on each direction) before resetting the connection.
71-
Data int64
71+
Data OptionalInteger
7272
}
7373

7474
type Transports struct {

0 commit comments

Comments
 (0)