-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(p2p): refactor p2p config options (#861)
Co-authored-by: Daniel T <[email protected]>
- Loading branch information
Showing
21 changed files
with
203 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
package config | ||
|
||
import "time" | ||
import ( | ||
"fmt" | ||
"time" | ||
) | ||
|
||
// P2PConfig stores configuration related to peer-to-peer networking. | ||
type P2PConfig struct { | ||
ListenAddress string // Address to listen for incoming connections | ||
Seeds string // Comma separated list of seed nodes to connect to | ||
GossipCacheSize int | ||
BoostrapTime time.Duration | ||
// Listening address for P2P connections | ||
ListenAddress string `mapstructure:"p2p_listen_address"` | ||
// List of nodes used for P2P bootstrapping | ||
BootstrapNodes string `mapstructure:"p2p_bootstrap_nodes"` | ||
// Size of the Gossipsub router cache | ||
GossipedBlocksCacheSize int `mapstructure:"p2p_gossiped_blocks_cache_size"` | ||
// Time interval a node tries to bootstrap again, in case no nodes connected | ||
BootstrapRetryTime time.Duration `mapstructure:"p2p_bootstrap_retry_time"` | ||
} | ||
|
||
// Validate P2PConfig | ||
func (c P2PConfig) Validate() error { | ||
if c.GossipedBlocksCacheSize < 0 { | ||
return fmt.Errorf("gossipsub cache size cannot be negative") | ||
} | ||
if c.BootstrapRetryTime <= 0 { | ||
return fmt.Errorf("bootstrap time must be positive") | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.