// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.

syntax = "proto3";
option go_package = "storj.io/common/pb";

package contact;

import "gogo.proto";
import "google/protobuf/timestamp.proto";
import "node.proto";
import "noise.proto";
import "nodetags.proto";

service Contact {
    rpc PingNode(ContactPingRequest) returns (ContactPingResponse);
}

service Node {
    rpc CheckIn(CheckInRequest) returns (CheckInResponse);
    rpc PingMe(PingMeRequest) returns (PingMeResponse);
    rpc GetTime(GetTimeRequest) returns (GetTimeResponse);
}

message CheckInRequest {
    string address = 1;
    node.NodeVersion version = 2;
    node.NodeCapacity capacity = 3;
    node.NodeOperator operator = 4;

    // CheckIn may happen over TLS, which means there is not necessarily an
    // opportunity to use NoiseSessionAttestation instead of
    // NoiseKeyAttestation.
    noise.NoiseKeyAttestation noise_key_attestation = 5;

    int32 debounce_limit = 6;

    // features is a set of bit flags of the NodeAddress.Features enum.
    uint64 features = 7;

    node.SignedNodeTagSets signed_tags = 8;
}

message CheckInResponse {
    bool ping_node_success = 1;
    string ping_error_message = 2;
    bool ping_node_success_quic = 3;
    bool node_tag_success = 4;
    string node_tag_error_message = 5;
}

message GetTimeRequest {}

message GetTimeResponse {
    google.protobuf.Timestamp timestamp = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
}

message ContactPingRequest {}

message ContactPingResponse {}

message PingMeRequest {
    string address = 1;
    node.NodeTransport transport = 2;

    // PingMe may happen over TLS, which means there is not necessarily an
    // opportunity to use NoiseSessionAttestation instead of
    // NoiseKeyAttestation.
    noise.NoiseKeyAttestation noise_key_attestation = 3;
}

message PingMeResponse {}
