Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement peer empty connection #822

Merged
merged 7 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion proto/launch/genesis_validator.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ message Peer {
oneof connection {
string tcpAddress = 2; // use a TCP address
HTTPTunnel httpTunnel = 3; // or use an HTTP tunnel
EmptyConnection none = 4; // or don't provide any connection
}

message HTTPTunnel {
string name = 1; // e.g.: chisel (https://github.com/jpillora/chisel)
string address = 2; // for chisel running on Gitpod, e.g.: https://3475-chocolate-capybara-kkiztq32.ws-eu21.gitpod.io/
}
}

message EmptyConnection {}
}
256 changes: 229 additions & 27 deletions x/launch/types/genesis_validator.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions x/launch/types/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func NewPeerConn(id, address string) Peer {
}
}

func NewPeerEmpty(id string) Peer {
return Peer{Id: id, Connection: &Peer_None{None: &Peer_EmptyConnection{}}}
}

// Validate check the Peer object
func (m Peer) Validate() error {
if m.Id == "" {
Expand All @@ -42,6 +46,8 @@ func (m Peer) Validate() error {
if conn.HttpTunnel.Address == "" {
return errors.New("empty http tunnel peer address")
}
case *Peer_None:
return nil
default:
return errors.New("invalid peer connection")
}
Expand Down
5 changes: 5 additions & 0 deletions x/launch/types/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ func TestPeer_Validate(t *testing.T) {
peer: types.NewPeerTunnel(sample.String(r, 3), sample.String(r, 5), sample.String(r, 10)),
wantErr: false,
},
{
name: "validate new peer empty",
peer: types.NewPeerEmpty(sample.String(r, 3)),
wantErr: false,
},
{
name: "invalid peer",
peer: types.Peer{},
Expand Down