-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from koinos/294-protocol-version
Protocol version
- Loading branch information
Showing
12 changed files
with
170 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package options | ||
|
||
import "time" | ||
|
||
const ( | ||
protocolVersionRetryTimeDefault = time.Millisecond * 50 | ||
protocolVersionTimeoutDefault = time.Second * 5 | ||
) | ||
|
||
// ConnectionManagerOptions are options for ConnectionManager | ||
type ConnectionManagerOptions struct { | ||
ProtocolVersionRetryTime time.Duration | ||
ProtocolVersionTimeout time.Duration | ||
} | ||
|
||
// NewConnectionManagerOptions returns default initialized ConnectionManagerOptions | ||
func NewConnectionManagerOptions() *ConnectionManagerOptions { | ||
return &ConnectionManagerOptions{ | ||
ProtocolVersionRetryTime: protocolVersionRetryTimeDefault, | ||
ProtocolVersionTimeout: protocolVersionTimeoutDefault, | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package p2p | ||
|
||
import "github.com/Masterminds/semver/v3" | ||
|
||
const ( | ||
koinosProtocolPrefix = "koinos/p2p/" | ||
versionMajor = 1 | ||
versionMinor = 0 | ||
versionPatch = 0 | ||
versionPrerelease = "" | ||
versionMetadata = "" | ||
) | ||
|
||
var ( | ||
koinosProtocolVersion *semver.Version | ||
) | ||
|
||
func KoinosProtocolVersion() *semver.Version { | ||
if koinosProtocolVersion == nil { | ||
koinosProtocolVersion = semver.New(versionMajor, versionMinor, versionPatch, versionPrerelease, versionMetadata) | ||
} | ||
|
||
return koinosProtocolVersion | ||
} | ||
|
||
func KoinosProtocolVersionString() string { | ||
return koinosProtocolPrefix + KoinosProtocolVersion().String() | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package p2p | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/Masterminds/semver/v3" | ||
"github.com/libp2p/go-libp2p/core/peer" | ||
) | ||
|
||
// ProtocolVersionProvider is an interface for a peer's protocol version to the PeerConnection | ||
type ProtocolVersionProvider interface { | ||
GetProtocolVersion(ctx context.Context, pid peer.ID) (*semver.Version, error) | ||
} |
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