diff --git a/.gitignore b/.gitignore index 3e6161cc6..4c5ddc860 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,7 @@ *.test # Output of the go coverage tool, specifically when used with LiteIDE -*.out \ No newline at end of file +*.out + +# Generated protobuf files +*.pb.go \ No newline at end of file diff --git a/protos/.keep b/protos/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/protos/google/duration.proto b/protos/google/duration.proto new file mode 100644 index 000000000..975fce41a --- /dev/null +++ b/protos/google/duration.proto @@ -0,0 +1,117 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; +option go_package = "github.com/golang/protobuf/ptypes/duration"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "DurationProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; + +// A Duration represents a signed, fixed-length span of time represented +// as a count of seconds and fractions of seconds at nanosecond +// resolution. It is independent of any calendar and concepts like "day" +// or "month". It is related to Timestamp in that the difference between +// two Timestamp values is a Duration and it can be added or subtracted +// from a Timestamp. Range is approximately +-10,000 years. +// +// # Examples +// +// Example 1: Compute Duration from two Timestamps in pseudo code. +// +// Timestamp start = ...; +// Timestamp end = ...; +// Duration duration = ...; +// +// duration.seconds = end.seconds - start.seconds; +// duration.nanos = end.nanos - start.nanos; +// +// if (duration.seconds < 0 && duration.nanos > 0) { +// duration.seconds += 1; +// duration.nanos -= 1000000000; +// } else if (durations.seconds > 0 && duration.nanos < 0) { +// duration.seconds -= 1; +// duration.nanos += 1000000000; +// } +// +// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. +// +// Timestamp start = ...; +// Duration duration = ...; +// Timestamp end = ...; +// +// end.seconds = start.seconds + duration.seconds; +// end.nanos = start.nanos + duration.nanos; +// +// if (end.nanos < 0) { +// end.seconds -= 1; +// end.nanos += 1000000000; +// } else if (end.nanos >= 1000000000) { +// end.seconds += 1; +// end.nanos -= 1000000000; +// } +// +// Example 3: Compute Duration from datetime.timedelta in Python. +// +// td = datetime.timedelta(days=3, minutes=10) +// duration = Duration() +// duration.FromTimedelta(td) +// +// # JSON Mapping +// +// In JSON format, the Duration type is encoded as a string rather than an +// object, where the string ends in the suffix "s" (indicating seconds) and +// is preceded by the number of seconds, with nanoseconds expressed as +// fractional seconds. For example, 3 seconds with 0 nanoseconds should be +// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should +// be expressed in JSON format as "3.000000001s", and 3 seconds and 1 +// microsecond should be expressed in JSON format as "3.000001s". +// +// +message Duration { + + // Signed seconds of the span of time. Must be from -315,576,000,000 + // to +315,576,000,000 inclusive. Note: these bounds are computed from: + // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + int64 seconds = 1; + + // Signed fractions of a second at nanosecond resolution of the span + // of time. Durations less than one second are represented with a 0 + // `seconds` field and a positive or negative `nanos` field. For durations + // of one second or more, a non-zero value for the `nanos` field must be + // of the same sign as the `seconds` field. Must be from -999,999,999 + // to +999,999,999 inclusive. + int32 nanos = 2; +} diff --git a/protos/overlay/overlay.proto b/protos/overlay/overlay.proto new file mode 100644 index 000000000..1e8ea8432 --- /dev/null +++ b/protos/overlay/overlay.proto @@ -0,0 +1,63 @@ +// Copyright (C) 2018 Storj Labs, Inc. +// See LICENSE for copying information. + +syntax = "proto3"; + +import "duration.proto"; + +// NodeTransport is an enum of possible transports for the overlay network +enum NodeTransport { + TCP = 0; +} + +// Overlay defines the interface for communication with the overlay network +service Overlay { + // Lookup finds a nodes address from the network + rpc Lookup(LookupRequest) returns (LookupResponse); + // FindStorageNodes finds a list of nodes in the network that meet the specified request parameters + rpc FindStorageNodes(FindStorageNodesRequest) returns (FindStorageNodesResponse); +} + +// LookupRequest is is request message for the lookup rpc call +message LookupRequest { + string nodeID = 1; +} + +// LookupResponse is is response message for the lookup rpc call +message LookupResponse { + NodeAddress nodeAddress = 1; +} + +// FindStorageNodesResponse is is response message for the FindStorageNodes rpc call +message FindStorageNodesResponse { + repeated Node node = 1; +} + +// FindStorageNodesRequest is is request message for the FindStorageNodes rpc call +message FindStorageNodesRequest { + int64 objectSize = 1; + google.protobuf.Duration contractLength = 2; + OverlayOptions opts = 3; +} + +// NodeAddress contains the information needed to communicate with a node on the network +message NodeAddress { + NodeTransport transport = 1; + string address = 2; +} + +// OverlayOptions is a set of criteria that a node must meet to be considered for a storage opportunity +message OverlayOptions { + google.protobuf.Duration maxLatency = 1; + NodeRep minReputation = 2; // Not sure what NodeRep is yet. + int64 minSpeedKbps = 3; +} + +// NodeRep is the reputation characteristics of a node +message NodeRep {} + +// Node represents a node in the overlay network +message Node { + string id = 1; + NodeAddress address = 2; +}