Skip to content

Commit

Permalink
fix renterd setup
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Aug 19, 2024
1 parent 01d61eb commit 93ac69c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cmd/clusterd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func main() {
GenesisID: genesis.ID(),
UniqueID: gateway.GenerateUniqueID(),
NetAddress: "127.0.0.1:" + port,
}, syncer.WithMaxInboundPeers(10000)) // essentially no limit on inbound peers
}, syncer.WithLogger(log.Named("syncer")), syncer.WithMaxInboundPeers(10000), syncer.WithBanDuration(time.Second), syncer.WithPeerDiscoveryInterval(5*time.Second), syncer.WithSyncInterval(5*time.Second)) // essentially no limit on inbound peers
if err != nil {
log.Panic("failed to create syncer", zap.Error(err))
}
Expand Down
19 changes: 11 additions & 8 deletions nodes/hostd.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,22 @@ func (m *Manager) StartHostd(ctx context.Context, ready chan<- struct{}) error {
GenesisID: genesisIndex.ID,
UniqueID: gateway.GenerateUniqueID(),
NetAddress: "127.0.0.1:" + port,
})
}, syncer.WithLogger(log.Named("syncer")), syncer.WithPeerDiscoveryInterval(5*time.Second), syncer.WithSyncInterval(5*time.Second))
defer s.Close()
go s.Run(ctx)
// connect to the primary cluster syncer
err = func(ctx context.Context) error {
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
_, err := m.syncer.Connect(ctx, s.Addr())
return err
}(ctx)
node.SyncerAddress = syncerListener.Addr().String()
// connect to the cluster syncer
_, err = m.syncer.Connect(ctx, node.SyncerAddress)
if err != nil {
return fmt.Errorf("failed to connect to cluster syncer: %w", err)
}
// connect to other nodes in the cluster
for _, n := range m.Nodes() {
_, err = s.Connect(ctx, n.SyncerAddress)
if err != nil {
return fmt.Errorf("failed to connect to peer syncer: %w", err)
}
}

store, err := sqlite.OpenDatabase(filepath.Join(dir, "hostd.sqlite3"), log.Named("sqlite3"))
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions nodes/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type (
APIAddress string `json:"apiAddress"`
Password string `json:"password"`

SyncerAddress string `json:"syncerAddress"`

WalletAddress types.Address `json:"walletAddress"`
}

Expand Down
19 changes: 11 additions & 8 deletions nodes/renterd.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,22 @@ func (m *Manager) StartRenterd(ctx context.Context, ready chan<- struct{}) error
GenesisID: genesisIndex.ID,
UniqueID: gateway.GenerateUniqueID(),
NetAddress: "127.0.0.1:" + port,
})
}, syncer.WithLogger(log.Named("syncer")), syncer.WithPeerDiscoveryInterval(5*time.Second), syncer.WithSyncInterval(5*time.Second))
defer s.Close()
go s.Run(ctx)
// connect to the primary cluster syncer
err = func(ctx context.Context) error {
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
_, err := m.syncer.Connect(ctx, s.Addr())
return err
}(ctx)
node.SyncerAddress = syncerListener.Addr().String()
// connect to the cluster syncer
_, err = m.syncer.Connect(ctx, node.SyncerAddress)
if err != nil {
return fmt.Errorf("failed to connect to cluster syncer: %w", err)
}
// connect to other nodes in the cluster
for _, n := range m.Nodes() {
_, err = s.Connect(ctx, n.SyncerAddress)
if err != nil {
return fmt.Errorf("failed to connect to peer syncer: %w", err)
}
}

db, err := sqlite.Open(filepath.Join(dir, "db.sqlite"))
if err != nil {
Expand Down
19 changes: 11 additions & 8 deletions nodes/walletd.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,22 @@ func (m *Manager) StartWalletd(ctx context.Context, ready chan<- struct{}) error
GenesisID: genesisIndex.ID,
UniqueID: gateway.GenerateUniqueID(),
NetAddress: "127.0.0.1:" + port,
})
}, syncer.WithLogger(log.Named("syncer")), syncer.WithPeerDiscoveryInterval(5*time.Second), syncer.WithSyncInterval(5*time.Second))
defer s.Close()
go s.Run(ctx)
// connect to the primary cluster syncer
err = func(ctx context.Context) error {
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
_, err := m.syncer.Connect(ctx, s.Addr())
return err
}(ctx)
node.SyncerAddress = syncerListener.Addr().String()
// connect to the cluster syncer
_, err = m.syncer.Connect(ctx, node.SyncerAddress)
if err != nil {
return fmt.Errorf("failed to connect to cluster syncer: %w", err)
}
// connect to other nodes in the cluster
for _, n := range m.Nodes() {
_, err = s.Connect(ctx, n.SyncerAddress)
if err != nil {
return fmt.Errorf("failed to connect to peer syncer: %w", err)
}
}

wm, err := wallet.NewManager(cm, store, wallet.WithLogger(log.Named("wallet")), wallet.WithIndexMode(wallet.IndexModePersonal)) // TODO switch index modes
if err != nil {
Expand Down

0 comments on commit 93ac69c

Please sign in to comment.