Skip to content

Commit

Permalink
voconed: add flags ipfsConnectKey, ipfsConnectPeers
Browse files Browse the repository at this point in the history
  • Loading branch information
altergui committed Oct 4, 2023
1 parent 7acab6e commit 0a35fad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
15 changes: 14 additions & 1 deletion cmd/voconed/voconed.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type VoconeConfig struct {
disableIpfs bool
fundedAccounts []string
enableFaucetWithAmount uint64
ipfsConnectKey string
ipfsConnectPeers []string
}

func main() {
Expand All @@ -56,6 +58,11 @@ func main() {
flag.Uint64Var(&config.txCosts, "txCosts", vocone.DefaultTxCosts, "transaction costs for all types")
flag.Uint64Var(&config.enableFaucetWithAmount, "enableFaucet", 0, "enable faucet API service for the given amount")
flag.BoolVar(&config.disableIpfs, "disableIpfs", false, "disable built-in IPFS node")
flag.StringVarP(&config.ipfsConnectKey, "ipfsConnectKey", "i", "",
"enable IPFS group synchronization using the given secret key")
flag.StringSliceVar(&config.ipfsConnectPeers, "ipfsConnectPeers", []string{},
"use custom ipfsconnect peers/bootnodes for accessing the DHT (comma-separated)")

flag.StringSliceVar(&config.fundedAccounts, "fundedAccounts", []string{},
"list of pre-funded accounts (address:balance,address:balance,...)")
flag.CommandLine.SortFlags = false
Expand Down Expand Up @@ -127,6 +134,12 @@ func main() {
}
*setTxCosts = pviper.GetBool("setTxCosts")

pviper.BindPFlag("ipfsConnectKey", flag.Lookup("ipfsConnectKey"))
config.ipfsConnectKey = pviper.GetString("ipfsConnectKey")

pviper.BindPFlag("ipfsConnectPeers", flag.Lookup("ipfsConnectPeers"))
config.ipfsConnectPeers = pviper.GetStringSlice("ipfsConnectPeers")

_, err = os.Stat(filepath.Join(config.dir, "voconed.yml"))
if err != nil {
if os.IsNotExist(err) {
Expand Down Expand Up @@ -170,7 +183,7 @@ func main() {
log.Fatal(err)
}

vc, err := vocone.NewVocone(config.dir, &mngKey, config.disableIpfs)
vc, err := vocone.NewVocone(config.dir, &mngKey, config.disableIpfs, config.ipfsConnectKey, config.ipfsConnectPeers)
if err != nil {
log.Fatal(err)
}
Expand Down
6 changes: 4 additions & 2 deletions vocone/vocone.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type Vocone struct {
}

// NewVocone returns a ready Vocone instance.
func NewVocone(dataDir string, keymanager *ethereum.SignKeys, disableIPFS bool) (*Vocone, error) {
func NewVocone(dataDir string, keymanager *ethereum.SignKeys, disableIPFS bool, connectKey string, connectPeers []string) (*Vocone, error) {
var err error

vc := &Vocone{}
Expand Down Expand Up @@ -106,7 +106,9 @@ func NewVocone(dataDir string, keymanager *ethereum.SignKeys, disableIPFS bool)
// Create the IPFS storage layer
if !disableIPFS {
vc.Storage, err = vc.IPFS(&config.IPFSCfg{
ConfigPath: filepath.Join(dataDir, "ipfs"),
ConfigPath: filepath.Join(dataDir, "ipfs"),
ConnectKey: connectKey,
ConnectPeers: connectPeers,
})
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion vocone/vocone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestVocone(t *testing.T) {
err = account.Generate()
qt.Assert(t, err, qt.IsNil)

vc, err := NewVocone(dir, &keymng, false)
vc, err := NewVocone(dir, &keymng, false, "", nil)
qt.Assert(t, err, qt.IsNil)

vc.SetBlockTimeTarget(time.Millisecond * 500)
Expand Down

0 comments on commit 0a35fad

Please sign in to comment.