From bc4c704fb6a37c7082a0665acd77b9249169d088 Mon Sep 17 00:00:00 2001 From: Keenan Nemetz Date: Tue, 10 Oct 2023 13:39:20 -0700 Subject: [PATCH] refactor: Remove net GRPC API (#1927) ## Relevant issue(s) N/A ## Description This PR removes the GRPC API from the net package. The HTTP and CLI interfaces now include this functionality. ## Tasks - [x] I made sure the code is well commented, particularly hard-to-understand areas. - [x] I made sure the repository-held documentation is changed accordingly. - [x] I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in [tools/configs/chglog/config.yml](tools/configs/chglog/config.yml)). - [x] I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ... ## How has this been tested? `make test` Specify the platform(s) on which this was tested: - MacOS --- cli/p2p_collection_add.go | 25 +- cli/p2p_collection_remove.go | 25 +- cli/start.go | 57 +- client/p2p.go | 16 +- config/config.go | 61 +- config/config_test.go | 52 - config/configfile_yaml.gotmpl | 8 - db/p2p_collection_test.go | 27 +- db/txn_db.go | 66 +- go.mod | 1 - go.sum | 7 - http/client.go | 20 +- http/handler.go | 4 +- http/handler_store.go | 16 +- net/config.go | 17 - net/config_test.go | 25 - net/dag_test.go | 4 +- net/dialer_test.go | 6 +- net/node.go | 15 +- net/node_test.go | 150 +- net/pb/Makefile | 5 + net/pb/net.pb.go | 1251 +------- net/pb/net.proto | 79 - net/pb/net_grpc.pb.go | 283 +- net/pb/net_vtproto.pb.go | 2805 ++--------------- net/peer.go | 233 +- net/peer_test.go | 315 +- net/server_test.go | 46 +- tests/clients/cli/wrapper.go | 8 +- tests/clients/http/wrapper.go | 8 +- tests/integration/net/order/utils.go | 23 +- .../replicator/with_create_update_test.go | 11 +- tests/integration/p2p.go | 68 +- tests/integration/utils2.go | 2 +- 34 files changed, 760 insertions(+), 4979 deletions(-) diff --git a/cli/p2p_collection_add.go b/cli/p2p_collection_add.go index 6970e8daec..86e0d8f6f9 100644 --- a/cli/p2p_collection_add.go +++ b/cli/p2p_collection_add.go @@ -11,19 +11,38 @@ package cli import ( + "strings" + "github.com/spf13/cobra" ) func MakeP2PCollectionAddCommand() *cobra.Command { var cmd = &cobra.Command{ - Use: "add [collectionID]", + Use: "add [collectionIDs]", Short: "Add P2P collections", Long: `Add P2P collections to the synchronized pubsub topics. -The collections are synchronized between nodes of a pubsub network.`, +The collections are synchronized between nodes of a pubsub network. + +Example: add single collection + defradb client p2p collection add bae123 + +Example: add multiple collections + defradb client p2p collection add bae123,bae456 + `, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { store := mustGetStoreContext(cmd) - return store.AddP2PCollection(cmd.Context(), args[0]) + + var collectionIDs []string + for _, id := range strings.Split(args[0], ",") { + id = strings.TrimSpace(id) + if id == "" { + continue + } + collectionIDs = append(collectionIDs, id) + } + + return store.AddP2PCollections(cmd.Context(), collectionIDs) }, } return cmd diff --git a/cli/p2p_collection_remove.go b/cli/p2p_collection_remove.go index ed67f5e7c6..0c4d14effd 100644 --- a/cli/p2p_collection_remove.go +++ b/cli/p2p_collection_remove.go @@ -11,19 +11,38 @@ package cli import ( + "strings" + "github.com/spf13/cobra" ) func MakeP2PCollectionRemoveCommand() *cobra.Command { var cmd = &cobra.Command{ - Use: "remove [collectionID]", + Use: "remove [collectionIDs]", Short: "Remove P2P collections", Long: `Remove P2P collections from the followed pubsub topics. -The removed collections will no longer be synchronized between nodes.`, +The removed collections will no longer be synchronized between nodes. + +Example: remove single collection + defradb client p2p collection remove bae123 + +Example: remove multiple collections + defradb client p2p collection remove bae123,bae456 + `, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { store := mustGetStoreContext(cmd) - return store.RemoveP2PCollection(cmd.Context(), args[0]) + + var collectionIDs []string + for _, id := range strings.Split(args[0], ",") { + id = strings.TrimSpace(id) + if id == "" { + continue + } + collectionIDs = append(collectionIDs, id) + } + + return store.RemoveP2PCollections(cmd.Context(), collectionIDs) }, } return cmd diff --git a/cli/start.go b/cli/start.go index 2962aa45e6..f0f8b19a8a 100644 --- a/cli/start.go +++ b/cli/start.go @@ -13,7 +13,6 @@ package cli import ( "context" "fmt" - gonet "net" "net/http" "os" "os/signal" @@ -22,12 +21,7 @@ import ( "syscall" badger "github.com/dgraph-io/badger/v4" - grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" - grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery" - ma "github.com/multiformats/go-multiaddr" "github.com/spf13/cobra" - "google.golang.org/grpc" - "google.golang.org/grpc/keepalive" "github.com/sourcenetwork/defradb/client" "github.com/sourcenetwork/defradb/config" @@ -38,7 +32,6 @@ import ( httpapi "github.com/sourcenetwork/defradb/http" "github.com/sourcenetwork/defradb/logging" "github.com/sourcenetwork/defradb/net" - netpb "github.com/sourcenetwork/defradb/net/pb" netutils "github.com/sourcenetwork/defradb/net/utils" ) @@ -114,15 +107,6 @@ func MakeStartCommand(cfg *config.Config) *cobra.Command { log.FeedbackFatalE(context.Background(), "Could not bind net.p2paddress", err) } - cmd.Flags().String( - "tcpaddr", cfg.Net.TCPAddress, - "Listener address for the tcp gRPC server (formatted as a libp2p MultiAddr)", - ) - err = cfg.BindFlag("net.tcpaddress", cmd.Flags().Lookup("tcpaddr")) - if err != nil { - log.FeedbackFatalE(context.Background(), "Could not bind net.tcpaddress", err) - } - cmd.Flags().Bool( "no-p2p", cfg.Net.P2PDisabled, "Disable the peer-to-peer network synchronization system", @@ -269,7 +253,7 @@ func start(ctx context.Context, cfg *config.Config) (*defraInstance, error) { return nil, errors.Wrap(fmt.Sprintf("failed to parse bootstrap peers %v", cfg.Net.Peers), err) } log.Debug(ctx, "Bootstrapping with peers", logging.NewKV("Addresses", addrs)) - n.Boostrap(addrs) + n.Bootstrap(addrs) } if err := n.Start(); err != nil { @@ -279,45 +263,6 @@ func start(ctx context.Context, cfg *config.Config) (*defraInstance, error) { db.Close(ctx) return nil, errors.Wrap("failed to start P2P listeners", err) } - - MtcpAddr, err := ma.NewMultiaddr(cfg.Net.TCPAddress) - if err != nil { - return nil, errors.Wrap("failed to parse multiaddress", err) - } - addr, err := netutils.TCPAddrFromMultiAddr(MtcpAddr) - if err != nil { - return nil, errors.Wrap("failed to parse TCP address", err) - } - - rpcTimeoutDuration, err := cfg.Net.RPCTimeoutDuration() - if err != nil { - return nil, errors.Wrap("failed to parse RPC timeout duration", err) - } - - server := grpc.NewServer( - grpc.UnaryInterceptor( - grpc_middleware.ChainUnaryServer( - grpc_recovery.UnaryServerInterceptor(), - ), - ), - grpc.KeepaliveParams( - keepalive.ServerParameters{ - MaxConnectionIdle: rpcTimeoutDuration, - }, - ), - ) - tcplistener, err := gonet.Listen("tcp", addr) - if err != nil { - return nil, errors.Wrap(fmt.Sprintf("failed to listen on TCP address %v", addr), err) - } - - go func() { - log.FeedbackInfo(ctx, "Started RPC server", logging.NewKV("Address", addr)) - netpb.RegisterCollectionServer(server, n.Peer) - if err := server.Serve(tcplistener); err != nil && !errors.Is(err, grpc.ErrServerStopped) { - log.FeedbackFatalE(ctx, "Failed to start RPC server", err) - } - }() } sOpt := []func(*httpapi.Server){ diff --git a/client/p2p.go b/client/p2p.go index 5f864fcb9d..800b946240 100644 --- a/client/p2p.go +++ b/client/p2p.go @@ -25,15 +25,15 @@ type P2P interface { // subscribed schemas. GetAllReplicators(ctx context.Context) ([]Replicator, error) - // AddP2PCollection adds the given collection ID that the P2P system - // subscribes to to the the persisted list. It will error if the provided - // collection ID is invalid. - AddP2PCollection(ctx context.Context, collectionID string) error + // AddP2PCollections adds the given collection IDs to the P2P system and + // subscribes to their topics. It will error if any of the provided + // collection IDs are invalid. + AddP2PCollections(ctx context.Context, collectionIDs []string) error - // RemoveP2PCollection removes the given collection ID that the P2P system - // subscribes to from the the persisted list. It will error if the provided - // collection ID is invalid. - RemoveP2PCollection(ctx context.Context, collectionID string) error + // RemoveP2PCollections removes the given collection IDs from the P2P system and + // unsubscribes from their topics. It will error if the provided + // collection IDs are invalid. + RemoveP2PCollections(ctx context.Context, collectionIDs []string) error // GetAllP2PCollections returns the list of persisted collection IDs that // the P2P system subscribes to. diff --git a/config/config.go b/config/config.go index 9832a92818..3b2a212c0a 100644 --- a/config/config.go +++ b/config/config.go @@ -51,7 +51,6 @@ import ( "strconv" "strings" "text/template" - "time" "github.com/mitchellh/mapstructure" ma "github.com/multiformats/go-multiaddr" @@ -350,48 +349,28 @@ func (apicfg *APIConfig) AddressToURL() string { // NetConfig configures aspects of network and peer-to-peer. type NetConfig struct { - P2PAddress string - P2PDisabled bool - Peers string - PubSubEnabled bool `mapstructure:"pubsub"` - RelayEnabled bool `mapstructure:"relay"` - RPCAddress string - RPCMaxConnectionIdle string - RPCTimeout string - TCPAddress string + P2PAddress string + P2PDisabled bool + Peers string + PubSubEnabled bool `mapstructure:"pubsub"` + RelayEnabled bool `mapstructure:"relay"` } func defaultNetConfig() *NetConfig { return &NetConfig{ - P2PAddress: "/ip4/0.0.0.0/tcp/9171", - P2PDisabled: false, - Peers: "", - PubSubEnabled: true, - RelayEnabled: false, - RPCAddress: "0.0.0.0:9161", - RPCMaxConnectionIdle: "5m", - RPCTimeout: "10s", - TCPAddress: "/ip4/0.0.0.0/tcp/9161", + P2PAddress: "/ip4/0.0.0.0/tcp/9171", + P2PDisabled: false, + Peers: "", + PubSubEnabled: true, + RelayEnabled: false, } } func (netcfg *NetConfig) validate() error { - _, err := time.ParseDuration(netcfg.RPCTimeout) - if err != nil { - return NewErrInvalidRPCTimeout(err, netcfg.RPCTimeout) - } - _, err = time.ParseDuration(netcfg.RPCMaxConnectionIdle) - if err != nil { - return NewErrInvalidRPCMaxConnectionIdle(err, netcfg.RPCMaxConnectionIdle) - } - _, err = ma.NewMultiaddr(netcfg.P2PAddress) + _, err := ma.NewMultiaddr(netcfg.P2PAddress) if err != nil { return NewErrInvalidP2PAddress(err, netcfg.P2PAddress) } - _, err = net.ResolveTCPAddr("tcp", netcfg.RPCAddress) - if err != nil { - return NewErrInvalidRPCAddress(err, netcfg.RPCAddress) - } if len(netcfg.Peers) > 0 { peers := strings.Split(netcfg.Peers, ",") maddrs := make([]ma.Multiaddr, len(peers)) @@ -405,24 +384,6 @@ func (netcfg *NetConfig) validate() error { return nil } -// RPCTimeoutDuration gives the RPC timeout as a time.Duration. -func (netcfg *NetConfig) RPCTimeoutDuration() (time.Duration, error) { - d, err := time.ParseDuration(netcfg.RPCTimeout) - if err != nil { - return d, NewErrInvalidRPCTimeout(err, netcfg.RPCTimeout) - } - return d, nil -} - -// RPCMaxConnectionIdleDuration gives the RPC MaxConnectionIdle as a time.Duration. -func (netcfg *NetConfig) RPCMaxConnectionIdleDuration() (time.Duration, error) { - d, err := time.ParseDuration(netcfg.RPCMaxConnectionIdle) - if err != nil { - return d, NewErrInvalidRPCMaxConnectionIdle(err, netcfg.RPCMaxConnectionIdle) - } - return d, nil -} - // LogConfig configures output and logger. type LoggingConfig struct { Level string diff --git a/config/config_test.go b/config/config_test.go index b7ff295efa..e29ef8aa81 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -15,7 +15,6 @@ import ( "os" "path/filepath" "testing" - "time" "github.com/stretchr/testify/assert" ) @@ -26,8 +25,6 @@ var envVarsDifferent = map[string]string{ "DEFRA_API_ADDRESS": "localhost:9999", "DEFRA_NET_P2PDISABLED": "true", "DEFRA_NET_P2PADDRESS": "/ip4/0.0.0.0/tcp/9876", - "DEFRA_NET_RPCADDRESS": "localhost:7777", - "DEFRA_NET_RPCTIMEOUT": "90s", "DEFRA_NET_PUBSUB": "false", "DEFRA_NET_RELAY": "false", "DEFRA_LOG_LEVEL": "error", @@ -41,8 +38,6 @@ var envVarsInvalid = map[string]string{ "DEFRA_API_ADDRESS": "^=+()&**()*(&))", "DEFRA_NET_P2PDISABLED": "^=+()&**()*(&))", "DEFRA_NET_P2PADDRESS": "^=+()&**()*(&))", - "DEFRA_NET_RPCADDRESS": "^=+()&**()*(&))", - "DEFRA_NET_RPCTIMEOUT": "^=+()&**()*(&))", "DEFRA_NET_PUBSUB": "^=+()&**()*(&))", "DEFRA_NET_RELAY": "^=+()&**()*(&))", "DEFRA_LOG_LEVEL": "^=+()&**()*(&))", @@ -178,8 +173,6 @@ func TestEnvVariablesAllConsidered(t *testing.T) { assert.Equal(t, "memory", cfg.Datastore.Store) assert.Equal(t, true, cfg.Net.P2PDisabled) assert.Equal(t, "/ip4/0.0.0.0/tcp/9876", cfg.Net.P2PAddress) - assert.Equal(t, "localhost:7777", cfg.Net.RPCAddress) - assert.Equal(t, "90s", cfg.Net.RPCTimeout) assert.Equal(t, false, cfg.Net.PubSubEnabled) assert.Equal(t, false, cfg.Net.RelayEnabled) assert.Equal(t, "error", cfg.Log.Level) @@ -390,51 +383,6 @@ func TestValidationInvalidNetConfigPeers(t *testing.T) { assert.ErrorIs(t, err, ErrFailedToValidateConfig) } -func TestValidationInvalidRPCMaxConnectionIdle(t *testing.T) { - cfg := DefaultConfig() - cfg.Net.RPCMaxConnectionIdle = "123123" - err := cfg.validate() - assert.ErrorIs(t, err, ErrFailedToValidateConfig) -} - -func TestValidationInvalidRPCTimeout(t *testing.T) { - cfg := DefaultConfig() - cfg.Net.RPCTimeout = "123123" - err := cfg.validate() - assert.ErrorIs(t, err, ErrFailedToValidateConfig) -} - -func TestValidationRPCTimeoutDuration(t *testing.T) { - cfg := DefaultConfig() - cfg.Net.RPCTimeout = "1s" - err := cfg.validate() - assert.NoError(t, err) -} - -func TestValidationInvalidRPCTimeoutDuration(t *testing.T) { - cfg := DefaultConfig() - cfg.Net.RPCTimeout = "123123" - err := cfg.validate() - assert.ErrorIs(t, err, ErrInvalidRPCTimeout) -} - -func TestValidationRPCMaxConnectionIdleDuration(t *testing.T) { - cfg := DefaultConfig() - cfg.Net.RPCMaxConnectionIdle = "1s" - err := cfg.validate() - assert.NoError(t, err) - duration, err := cfg.Net.RPCMaxConnectionIdleDuration() - assert.NoError(t, err) - assert.Equal(t, duration, 1*time.Second) -} - -func TestValidationInvalidMaxConnectionIdleDuration(t *testing.T) { - cfg := DefaultConfig() - cfg.Net.RPCMaxConnectionIdle = "*ˆ&%*&%" - err := cfg.validate() - assert.ErrorIs(t, err, ErrInvalidRPCMaxConnectionIdle) -} - func TestValidationInvalidLoggingConfig(t *testing.T) { cfg := DefaultConfig() cfg.Log.Level = "546578" diff --git a/config/configfile_yaml.gotmpl b/config/configfile_yaml.gotmpl index 8e011658e9..5346e41378 100644 --- a/config/configfile_yaml.gotmpl +++ b/config/configfile_yaml.gotmpl @@ -37,20 +37,12 @@ net: p2pdisabled: {{ .Net.P2PDisabled }} # Listening address of the P2P network p2paddress: {{ .Net.P2PAddress }} - # Listening address of the RPC endpoint - rpcaddress: {{ .Net.RPCAddress }} - # gRPC server address - tcpaddress: {{ .Net.TCPAddress }} - # Time duration after which a RPC connection to a peer times out - rpctimeout: {{ .Net.RPCTimeout }} # Whether the node has pubsub enabled or not pubsub: {{ .Net.PubSubEnabled }} # Enable libp2p's Circuit relay transport protocol https://docs.libp2p.io/concepts/circuit-relay/ relay: {{ .Net.RelayEnabled }} # List of peers to boostrap with, specified as multiaddresses (https://docs.libp2p.io/concepts/addressing/) peers: {{ .Net.Peers }} - # Amount of time after which an idle RPC connection would be closed - RPCMaxConnectionIdle: {{ .Net.RPCMaxConnectionIdle }} log: # Log level. Options are debug, info, error, fatal diff --git a/db/p2p_collection_test.go b/db/p2p_collection_test.go index db6b1e6417..acd80bd041 100644 --- a/db/p2p_collection_test.go +++ b/db/p2p_collection_test.go @@ -63,7 +63,7 @@ func TestAddP2PCollection(t *testing.T) { col := newTestCollection(t, ctx, db, "test") - err = db.AddP2PCollection(ctx, col.SchemaID()) + err = db.AddP2PCollections(ctx, []string{col.SchemaID()}) require.NoError(t, err) } @@ -74,20 +74,16 @@ func TestGetAllP2PCollection(t *testing.T) { defer db.Close(ctx) col1 := newTestCollection(t, ctx, db, "test1") - err = db.AddP2PCollection(ctx, col1.SchemaID()) - require.NoError(t, err) - col2 := newTestCollection(t, ctx, db, "test2") - err = db.AddP2PCollection(ctx, col2.SchemaID()) - require.NoError(t, err) - col3 := newTestCollection(t, ctx, db, "test3") - err = db.AddP2PCollection(ctx, col3.SchemaID()) + + collectionIDs := []string{col1.SchemaID(), col2.SchemaID(), col3.SchemaID()} + err = db.AddP2PCollections(ctx, collectionIDs) require.NoError(t, err) collections, err := db.GetAllP2PCollections(ctx) require.NoError(t, err) - require.ElementsMatch(t, collections, []string{col1.SchemaID(), col2.SchemaID(), col3.SchemaID()}) + require.ElementsMatch(t, collections, collectionIDs) } func TestRemoveP2PCollection(t *testing.T) { @@ -97,18 +93,15 @@ func TestRemoveP2PCollection(t *testing.T) { defer db.Close(ctx) col1 := newTestCollection(t, ctx, db, "test1") - err = db.AddP2PCollection(ctx, col1.SchemaID()) - require.NoError(t, err) - col2 := newTestCollection(t, ctx, db, "test2") - err = db.AddP2PCollection(ctx, col2.SchemaID()) - require.NoError(t, err) - col3 := newTestCollection(t, ctx, db, "test3") - err = db.AddP2PCollection(ctx, col3.SchemaID()) + + collectionIDs := []string{col1.SchemaID(), col2.SchemaID(), col3.SchemaID()} + + err = db.AddP2PCollections(ctx, collectionIDs) require.NoError(t, err) - err = db.RemoveP2PCollection(ctx, col2.SchemaID()) + err = db.RemoveP2PCollections(ctx, []string{col2.SchemaID()}) require.NoError(t, err) collections, err := db.GetAllP2PCollections(ctx) diff --git a/db/txn_db.go b/db/txn_db.go index b4cc32dee1..e996d9a9c8 100644 --- a/db/txn_db.go +++ b/db/txn_db.go @@ -121,54 +121,68 @@ func (db *explicitTxnDB) GetCollectionByVersionID( return db.getCollectionByVersionID(ctx, db.txn, schemaVersionID) } -// AddP2PCollection adds the given collection ID that the P2P system -// subscribes to to the the persisted list. It will error if the provided -// collection ID is invalid. -func (db *implicitTxnDB) AddP2PCollection(ctx context.Context, collectionID string) error { +// AddP2PCollections adds the given collection IDs to the P2P system and +// subscribes to their topics. It will error if any of the provided +// collection IDs are invalid. +func (db *implicitTxnDB) AddP2PCollections(ctx context.Context, collectionIDs []string) error { txn, err := db.NewTxn(ctx, false) if err != nil { return err } defer txn.Discard(ctx) - err = db.addP2PCollection(ctx, txn, collectionID) - if err != nil { - return err + for _, collectionID := range collectionIDs { + err = db.addP2PCollection(ctx, txn, collectionID) + if err != nil { + return err + } } - return txn.Commit(ctx) } -// AddP2PCollection adds the given collection ID that the P2P system -// subscribes to to the the persisted list. It will error if the provided -// collection ID is invalid. -func (db *explicitTxnDB) AddP2PCollection(ctx context.Context, collectionID string) error { - return db.addP2PCollection(ctx, db.txn, collectionID) +// AddP2PCollections adds the given collection IDs to the P2P system and +// subscribes to their topics. It will error if any of the provided +// collection IDs are invalid. +func (db *explicitTxnDB) AddP2PCollections(ctx context.Context, collectionIDs []string) error { + for _, collectionID := range collectionIDs { + err := db.addP2PCollection(ctx, db.txn, collectionID) + if err != nil { + return err + } + } + return nil } -// RemoveP2PCollection removes the given collection ID that the P2P system -// subscribes to from the the persisted list. It will error if the provided -// collection ID is invalid. -func (db *implicitTxnDB) RemoveP2PCollection(ctx context.Context, collectionID string) error { +// RemoveP2PCollections removes the given collection IDs from the P2P system and +// unsubscribes from their topics. It will error if the provided +// collection IDs are invalid. +func (db *implicitTxnDB) RemoveP2PCollections(ctx context.Context, collectionIDs []string) error { txn, err := db.NewTxn(ctx, false) if err != nil { return err } defer txn.Discard(ctx) - err = db.removeP2PCollection(ctx, txn, collectionID) - if err != nil { - return err + for _, collectionID := range collectionIDs { + err = db.removeP2PCollection(ctx, txn, collectionID) + if err != nil { + return err + } } - return txn.Commit(ctx) } -// RemoveP2PCollection removes the given collection ID that the P2P system -// subscribes to from the the persisted list. It will error if the provided -// collection ID is invalid. -func (db *explicitTxnDB) RemoveP2PCollection(ctx context.Context, collectionID string) error { - return db.removeP2PCollection(ctx, db.txn, collectionID) +// RemoveP2PCollections removes the given collection IDs from the P2P system and +// unsubscribes from their topics. It will error if the provided +// collection IDs are invalid. +func (db *explicitTxnDB) RemoveP2PCollections(ctx context.Context, collectionIDs []string) error { + for _, collectionID := range collectionIDs { + err := db.removeP2PCollection(ctx, db.txn, collectionID) + if err != nil { + return err + } + } + return nil } // GetAllCollections gets all the currently defined collections. diff --git a/go.mod b/go.mod index 8489f17281..2659ca7667 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,6 @@ require ( github.com/go-errors/errors v1.5.1 github.com/gofrs/uuid/v5 v5.0.0 github.com/graphql-go/graphql v0.8.1 - github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 github.com/iancoleman/strcase v0.3.0 github.com/ipfs/boxo v0.13.1 github.com/ipfs/go-block-format v0.2.0 diff --git a/go.sum b/go.sum index a7a1f36c26..34d3e57a48 100644 --- a/go.sum +++ b/go.sum @@ -233,7 +233,6 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= @@ -365,8 +364,6 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= -github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= @@ -1343,7 +1340,6 @@ go.uber.org/dig v1.17.0/go.mod h1:rTxpf7l5I0eBTlE6/9RL+lDybC7WFwY2QH55ZSjy1mU= go.uber.org/fx v1.20.0 h1:ZMC/pnRvhsthOZh9MZjMq5U8Or3mA9zBSPaLnzs3ihQ= go.uber.org/fx v1.20.0/go.mod h1:qCUj0btiR3/JnanEr1TYEePfSw6o/4qYJscgvzQ5Ub0= go.uber.org/goleak v1.0.0/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= @@ -1358,7 +1354,6 @@ go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= -go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= @@ -1596,7 +1591,6 @@ golang.org/x/sys v0.0.0-20210426080607-c94f62235c83/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1749,7 +1743,6 @@ google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= diff --git a/http/client.go b/http/client.go index 9dd7b7b065..79ff9e559b 100644 --- a/http/client.go +++ b/http/client.go @@ -131,10 +131,14 @@ func (c *Client) GetAllReplicators(ctx context.Context) ([]client.Replicator, er return reps, nil } -func (c *Client) AddP2PCollection(ctx context.Context, collectionID string) error { - methodURL := c.http.baseURL.JoinPath("p2p", "collections", collectionID) +func (c *Client) AddP2PCollections(ctx context.Context, collectionIDs []string) error { + methodURL := c.http.baseURL.JoinPath("p2p", "collections") - req, err := http.NewRequestWithContext(ctx, http.MethodPost, methodURL.String(), nil) + body, err := json.Marshal(collectionIDs) + if err != nil { + return err + } + req, err := http.NewRequestWithContext(ctx, http.MethodPost, methodURL.String(), bytes.NewBuffer(body)) if err != nil { return err } @@ -142,10 +146,14 @@ func (c *Client) AddP2PCollection(ctx context.Context, collectionID string) erro return err } -func (c *Client) RemoveP2PCollection(ctx context.Context, collectionID string) error { - methodURL := c.http.baseURL.JoinPath("p2p", "collections", collectionID) +func (c *Client) RemoveP2PCollections(ctx context.Context, collectionIDs []string) error { + methodURL := c.http.baseURL.JoinPath("p2p", "collections") - req, err := http.NewRequestWithContext(ctx, http.MethodDelete, methodURL.String(), nil) + body, err := json.Marshal(collectionIDs) + if err != nil { + return err + } + req, err := http.NewRequestWithContext(ctx, http.MethodDelete, methodURL.String(), bytes.NewBuffer(body)) if err != nil { return err } diff --git a/http/handler.go b/http/handler.go index 242dc5938c..d8cd33c444 100644 --- a/http/handler.go +++ b/http/handler.go @@ -107,8 +107,8 @@ func NewHandler(db client.DB, opts ServerOptions) *Handler { }) p2p.Route("/collections", func(p2p_collections chi.Router) { p2p_collections.Get("/", store_handler.GetAllP2PCollections) - p2p_collections.Post("/{id}", store_handler.AddP2PCollection) - p2p_collections.Delete("/{id}", store_handler.RemoveP2PCollection) + p2p_collections.Post("/", store_handler.AddP2PCollection) + p2p_collections.Delete("/", store_handler.RemoveP2PCollection) }) }) api.Route("/debug", func(debug chi.Router) { diff --git a/http/handler_store.go b/http/handler_store.go index 120b9f9018..93563c2f90 100644 --- a/http/handler_store.go +++ b/http/handler_store.go @@ -17,8 +17,6 @@ import ( "io" "net/http" - "github.com/go-chi/chi/v5" - "github.com/sourcenetwork/defradb/client" ) @@ -70,7 +68,12 @@ func (s *storeHandler) GetAllReplicators(rw http.ResponseWriter, req *http.Reque func (s *storeHandler) AddP2PCollection(rw http.ResponseWriter, req *http.Request) { store := req.Context().Value(storeContextKey).(client.Store) - err := store.AddP2PCollection(req.Context(), chi.URLParam(req, "id")) + var collectionIDs []string + if err := requestJSON(req, &collectionIDs); err != nil { + responseJSON(rw, http.StatusBadRequest, errorResponse{err}) + return + } + err := store.AddP2PCollections(req.Context(), collectionIDs) if err != nil { responseJSON(rw, http.StatusBadRequest, errorResponse{err}) return @@ -81,7 +84,12 @@ func (s *storeHandler) AddP2PCollection(rw http.ResponseWriter, req *http.Reques func (s *storeHandler) RemoveP2PCollection(rw http.ResponseWriter, req *http.Request) { store := req.Context().Value(storeContextKey).(client.Store) - err := store.RemoveP2PCollection(req.Context(), chi.URLParam(req, "id")) + var collectionIDs []string + if err := requestJSON(req, &collectionIDs); err != nil { + responseJSON(rw, http.StatusBadRequest, errorResponse{err}) + return + } + err := store.RemoveP2PCollections(req.Context(), collectionIDs) if err != nil { responseJSON(rw, http.StatusBadRequest, errorResponse{err}) return diff --git a/net/config.go b/net/config.go index 1055d0b1c8..4c33dc02a6 100644 --- a/net/config.go +++ b/net/config.go @@ -27,7 +27,6 @@ import ( // Options is the node options. type Options struct { ListenAddrs []ma.Multiaddr - TCPAddr ma.Multiaddr PrivateKey crypto.PrivKey EnablePubSub bool EnableRelay bool @@ -69,10 +68,6 @@ func WithConfig(cfg *config.Config) NodeOpt { if err != nil { return err } - err = WithListenTCPAddrString(cfg.Net.TCPAddress)(opt) - if err != nil { - return err - } opt.EnableRelay = cfg.Net.RelayEnabled opt.EnablePubSub = cfg.Net.PubSubEnabled opt.ConnManager, err = NewConnManager(100, 400, time.Second*20) @@ -121,18 +116,6 @@ func WithListenP2PAddrStrings(addrs ...string) NodeOpt { } } -// ListenTCPAddrString sets the TCP address to listen on, as Multiaddr. -func WithListenTCPAddrString(addr string) NodeOpt { - return func(opt *Options) error { - a, err := ma.NewMultiaddr(addr) - if err != nil { - return err - } - opt.TCPAddr = a - return nil - } -} - // ListenAddrs sets the address to listen on given as MultiAddr(s). func WithListenAddrs(addrs ...ma.Multiaddr) NodeOpt { return func(opt *Options) error { diff --git a/net/config_test.go b/net/config_test.go index 7c2b01dd06..6f306c29ed 100644 --- a/net/config_test.go +++ b/net/config_test.go @@ -55,17 +55,6 @@ func TestWithConfigWithP2PAddressError(t *testing.T) { require.Contains(t, err.Error(), "failed to parse multiaddr") } -func TestWithConfigWitTCPAddressError(t *testing.T) { - cfg := config.Config{ - Net: &config.NetConfig{ - P2PAddress: "/ip4/0.0.0.0/tcp/9999", - TCPAddress: "/willerror/0.0.0.0/tcp/9999", - }, - } - err := WithConfig(&cfg)(&Options{}) - require.Contains(t, err.Error(), "failed to parse multiaddr") -} - func TestWithPrivateKey(t *testing.T) { key, _, err := crypto.GenerateKeyPair(crypto.Ed25519, 0) require.NoError(t, err) @@ -104,20 +93,6 @@ func TestWithListenP2PAddrStrings(t *testing.T) { require.Equal(t, addr, opt.ListenAddrs[0].String()) } -func TestWithListenTCPAddrStringWithError(t *testing.T) { - addr := "/willerror/0.0.0.0/tcp/9999" - _, err := NewMergedOptions(WithListenTCPAddrString(addr)) - require.Contains(t, err.Error(), "failed to parse multiaddr") -} - -func TestWithListenTCPAddrString(t *testing.T) { - addr := "/ip4/0.0.0.0/tcp/9999" - opt, err := NewMergedOptions(WithListenTCPAddrString(addr)) - require.NoError(t, err) - require.NotNil(t, opt) - require.Equal(t, addr, opt.TCPAddr.String()) -} - func TestWithListenAddrs(t *testing.T) { addr := "/ip4/0.0.0.0/tcp/9999" a, err := ma.NewMultiaddr(addr) diff --git a/net/dag_test.go b/net/dag_test.go index d0e9a18ce7..7373967a76 100644 --- a/net/dag_test.go +++ b/net/dag_test.go @@ -190,7 +190,7 @@ func TestSendJobWorker_WithPeerAndNoChildren_NoError(t *testing.T) { addrs, err := netutils.ParsePeers([]string{n1.host.Addrs()[0].String() + "/p2p/" + n1.PeerID().String()}) require.NoError(t, err) - n2.Boostrap(addrs) + n2.Bootstrap(addrs) done := make(chan struct{}) go func() { @@ -268,7 +268,7 @@ func TestSendJobWorker_WithPeerAndChildren_NoError(t *testing.T) { addrs, err := netutils.ParsePeers([]string{n1.host.Addrs()[0].String() + "/p2p/" + n1.PeerID().String()}) require.NoError(t, err) - n2.Boostrap(addrs) + n2.Bootstrap(addrs) done := make(chan struct{}) go func() { diff --git a/net/dialer_test.go b/net/dialer_test.go index 58bdf44665..d092602490 100644 --- a/net/dialer_test.go +++ b/net/dialer_test.go @@ -39,7 +39,7 @@ func TestDial_WithConnectedPeer_NoError(t *testing.T) { if err != nil { t.Fatal(err) } - n2.Boostrap(addrs) + n2.Bootstrap(addrs) _, err = n1.server.dial(n2.PeerID()) require.NoError(t, err) } @@ -63,7 +63,7 @@ func TestDial_WithConnectedPeerAndSecondConnection_NoError(t *testing.T) { if err != nil { t.Fatal(err) } - n2.Boostrap(addrs) + n2.Bootstrap(addrs) _, err = n1.server.dial(n2.PeerID()) require.NoError(t, err) @@ -90,7 +90,7 @@ func TestDial_WithConnectedPeerAndSecondConnectionWithConnectionShutdown_Closing if err != nil { t.Fatal(err) } - n2.Boostrap(addrs) + n2.Bootstrap(addrs) _, err = n1.server.dial(n2.PeerID()) require.NoError(t, err) diff --git a/net/node.go b/net/node.go index 248650f5f2..392267fefa 100644 --- a/net/node.go +++ b/net/node.go @@ -54,7 +54,7 @@ var evtWaitTimeout = 10 * time.Second // Node is a networked peer instance of DefraDB. type Node struct { // embed the DB interface into the node - client.DB + DB client.DB *Peer @@ -160,7 +160,6 @@ func NewNode( h, ddht, ps, - options.TCPAddr, options.GRPCServerOptions, options.GRPCDialOptions, ) @@ -192,8 +191,8 @@ func NewNode( return n, nil } -// Boostrap connects to the given peers. -func (n *Node) Boostrap(addrs []peer.AddrInfo) { +// Bootstrap connects to the given peers. +func (n *Node) Bootstrap(addrs []peer.AddrInfo) { var connected uint64 var wg sync.WaitGroup @@ -234,6 +233,14 @@ func (n *Node) PeerID() peer.ID { return n.host.ID() } +// PeerInfo returns the node's peer id and listening addresses. +func (n *Node) PeerInfo() peer.AddrInfo { + return peer.AddrInfo{ + ID: n.host.ID(), + Addrs: n.host.Addrs(), + } +} + // subscribeToPeerConnectionEvents subscribes the node to the event bus for a peer connection change. func (n *Node) subscribeToPeerConnectionEvents() { sub, err := n.host.EventBus().Subscribe(new(event.EvtPeerConnectednessChanged)) diff --git a/net/node_test.go b/net/node_test.go index b099e9282c..941d171726 100644 --- a/net/node_test.go +++ b/net/node_test.go @@ -11,7 +11,6 @@ package net import ( - "bytes" "context" "testing" "time" @@ -27,7 +26,6 @@ import ( badgerds "github.com/sourcenetwork/defradb/datastore/badger/v4" "github.com/sourcenetwork/defradb/datastore/memory" "github.com/sourcenetwork/defradb/db" - "github.com/sourcenetwork/defradb/logging" netutils "github.com/sourcenetwork/defradb/net/utils" ) @@ -59,19 +57,6 @@ func TestNewNode_WithEnableRelay_NoError(t *testing.T) { require.NoError(t, err) } -func TestNewNode_WithInvalidListenTCPAddrString_ParseError(t *testing.T) { - ctx := context.Background() - store := memory.NewDatastore(ctx) - db, err := db.NewDB(ctx, store, db.WithUpdateEvents()) - require.NoError(t, err) - _, err = NewNode( - context.Background(), - db, - WithListenTCPAddrString("/ip4/碎片整理"), - ) - require.EqualError(t, err, "failed to parse multiaddr \"/ip4/碎片整理\": invalid value \"碎片整理\" for protocol ip4: failed to parse ip4 addr: 碎片整理") -} - func TestNewNode_WithDBClosed_NoError(t *testing.T) { ctx := context.Background() store := memory.NewDatastore(ctx) @@ -142,7 +127,7 @@ func TestNewNode_BootstrapWithNoPeer_NoError(t *testing.T) { WithListenP2PAddrStrings("/ip4/0.0.0.0/tcp/0"), ) require.NoError(t, err) - n1.Boostrap([]peer.AddrInfo{}) + n1.Bootstrap([]peer.AddrInfo{}) } func TestNewNode_BootstrapWithOnePeer_NoError(t *testing.T) { @@ -167,7 +152,7 @@ func TestNewNode_BootstrapWithOnePeer_NoError(t *testing.T) { if err != nil { t.Fatal(err) } - n2.Boostrap(addrs) + n2.Bootstrap(addrs) } func TestNewNode_BootstrapWithOneValidPeerAndManyInvalidPeers_NoError(t *testing.T) { @@ -195,21 +180,7 @@ func TestNewNode_BootstrapWithOneValidPeerAndManyInvalidPeers_NoError(t *testing "/ip4/0.0.0.0/tcp/1236/p2p/" + "12D3KooWC8YY6Tx3uAeHsdBmoy7PJPwqXAHE4HkCZ5veankKWci4", }) require.NoError(t, err) - n2.Boostrap(addrs) -} - -func mergeOptions(nodeOpts ...NodeOpt) (Options, error) { - var options Options - var nodeOpt NodeOpt - for _, opt := range append(nodeOpts, nodeOpt) { - if opt == nil { - continue - } - if err := opt(&options); err != nil { - return options, err - } - } - return options, nil + n2.Bootstrap(addrs) } func TestListenAddrs_WithListenP2PAddrStrings_NoError(t *testing.T) { @@ -227,19 +198,9 @@ func TestListenAddrs_WithListenP2PAddrStrings_NoError(t *testing.T) { require.Contains(t, n.ListenAddrs()[0].String(), "/tcp/") } -func TestWithListenTCPAddrString_WithInvalidListenTCPAddrString_ParseError(t *testing.T) { - opt := WithListenTCPAddrString("/ip4/碎片整理") - options, err := mergeOptions(opt) - require.EqualError(t, err, "failed to parse multiaddr \"/ip4/碎片整理\": invalid value \"碎片整理\" for protocol ip4: failed to parse ip4 addr: 碎片整理") - require.Equal(t, Options{}, options) -} - func TestNodeConfig_NoError(t *testing.T) { cfg := config.DefaultConfig() cfg.Net.P2PAddress = "/ip4/0.0.0.0/tcp/9179" - cfg.Net.TCPAddress = "/ip4/0.0.0.0/tcp/9169" - cfg.Net.RPCTimeout = "100s" - cfg.Net.RPCMaxConnectionIdle = "111s" cfg.Net.RelayEnabled = true cfg.Net.PubSubEnabled = true @@ -250,13 +211,10 @@ func TestNodeConfig_NoError(t *testing.T) { // confirming it provides the same config as a manually constructed node.Options p2pAddr, err := ma.NewMultiaddr(cfg.Net.P2PAddress) require.NoError(t, err) - tcpAddr, err := ma.NewMultiaddr(cfg.Net.TCPAddress) - require.NoError(t, err) connManager, err := NewConnManager(100, 400, time.Second*20) require.NoError(t, err) expectedOptions := Options{ ListenAddrs: []ma.Multiaddr{p2pAddr}, - TCPAddr: tcpAddr, EnablePubSub: true, EnableRelay: true, ConnManager: connManager, @@ -265,58 +223,11 @@ func TestNodeConfig_NoError(t *testing.T) { for k, v := range options.ListenAddrs { require.Equal(t, expectedOptions.ListenAddrs[k], v) } - require.Equal(t, expectedOptions.TCPAddr.String(), options.TCPAddr.String()) + require.Equal(t, expectedOptions.EnablePubSub, options.EnablePubSub) require.Equal(t, expectedOptions.EnableRelay, options.EnableRelay) } -func TestSubscribeToPeerConnectionEvents_SubscriptionError(t *testing.T) { - db := FixtureNewMemoryDBWithBroadcaster(t) - n, err := NewNode( - context.Background(), - db, - ) - require.NoError(t, err) - - b := &bytes.Buffer{} - - log.ApplyConfig(logging.Config{ - Pipe: b, - }) - - n.Peer.host = &mockHost{n.Peer.host} - - n.subscribeToPeerConnectionEvents() - - logLines, err := parseLines(b) - if err != nil { - t.Fatal(err) - } - - if len(logLines) != 1 { - t.Fatalf("expecting exactly 1 log line but got %d lines", len(logLines)) - } - require.Equal(t, "failed to subscribe to peer connectedness changed event: mock error", logLines[0]["msg"]) - - // reset logger - log = logging.MustNewLogger("defra.net") -} - -func TestPeerConnectionEventEmitter_SingleEvent_NoError(t *testing.T) { - db := FixtureNewMemoryDBWithBroadcaster(t) - n, err := NewNode( - context.Background(), - db, - ) - require.NoError(t, err) - - emitter, err := n.host.EventBus().Emitter(new(event.EvtPeerConnectednessChanged)) - require.NoError(t, err) - - err = emitter.Emit(event.EvtPeerConnectednessChanged{}) - require.NoError(t, err) -} - func TestPeerConnectionEventEmitter_MultiEvent_NoError(t *testing.T) { db := FixtureNewMemoryDBWithBroadcaster(t) n, err := NewNode( @@ -343,43 +254,9 @@ func TestSubscribeToPubSubEvents_SubscriptionError(t *testing.T) { ) require.NoError(t, err) - b := &bytes.Buffer{} - - log.ApplyConfig(logging.Config{ - Pipe: b, - }) - n.Peer.host = &mockHost{n.Peer.host} n.subscribeToPubSubEvents() - - logLines, err := parseLines(b) - if err != nil { - t.Fatal(err) - } - - if len(logLines) != 1 { - t.Fatalf("expecting exactly 1 log line but got %d lines", len(logLines)) - } - require.Equal(t, "failed to subscribe to pubsub event: mock error", logLines[0]["msg"]) - - // reset logger - log = logging.MustNewLogger("defra.net") -} - -func TestPubSubEventEmitter_SingleEvent_NoError(t *testing.T) { - db := FixtureNewMemoryDBWithBroadcaster(t) - n, err := NewNode( - context.Background(), - db, - ) - require.NoError(t, err) - - emitter, err := n.host.EventBus().Emitter(new(EvtPubSub)) - require.NoError(t, err) - - err = emitter.Emit(EvtPubSub{}) - require.NoError(t, err) } func TestPubSubEventEmitter_MultiEvent_NoError(t *testing.T) { @@ -408,28 +285,9 @@ func TestSubscribeToPushLogEvents_SubscriptionError(t *testing.T) { ) require.NoError(t, err) - b := &bytes.Buffer{} - - log.ApplyConfig(logging.Config{ - Pipe: b, - }) - n.Peer.host = &mockHost{n.Peer.host} n.subscribeToPushLogEvents() - - logLines, err := parseLines(b) - if err != nil { - t.Fatal(err) - } - - if len(logLines) != 1 { - t.Fatalf("expecting exactly 1 log line but got %d lines", len(logLines)) - } - require.Equal(t, "failed to subscribe to push log event: mock error", logLines[0]["msg"]) - - // reset logger - log = logging.MustNewLogger("defra.net") } func TestPushLogEventEmitter_SingleEvent_NoError(t *testing.T) { diff --git a/net/pb/Makefile b/net/pb/Makefile index 62eef77354..233665c334 100644 --- a/net/pb/Makefile +++ b/net/pb/Makefile @@ -3,6 +3,11 @@ GO = $(PB:.proto=.pb.go) all: $(GO) +deps: + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest + go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@latest + %.pb.go: %.proto protoc \ --go_out=. --plugin protoc-gen-go="${GOBIN}/protoc-gen-go" \ diff --git a/net/pb/net.pb.go b/net/pb/net.pb.go index 70daae73a7..c1a3cf3212 100644 --- a/net/pb/net.pb.go +++ b/net/pb/net.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v3.21.9 +// protoc-gen-go v1.31.0 +// protoc v4.24.3 // source: net.proto package net_pb @@ -467,727 +467,33 @@ func (*GetHeadLogReply) Descriptor() ([]byte, []int) { return file_net_proto_rawDescGZIP(), []int{10} } -type SetReplicatorRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Collections []string `protobuf:"bytes,1,rep,name=collections,proto3" json:"collections,omitempty"` - Addr []byte `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` -} - -func (x *SetReplicatorRequest) Reset() { - *x = SetReplicatorRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SetReplicatorRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SetReplicatorRequest) ProtoMessage() {} - -func (x *SetReplicatorRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SetReplicatorRequest.ProtoReflect.Descriptor instead. -func (*SetReplicatorRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{11} -} - -func (x *SetReplicatorRequest) GetCollections() []string { - if x != nil { - return x.Collections - } - return nil -} - -func (x *SetReplicatorRequest) GetAddr() []byte { - if x != nil { - return x.Addr - } - return nil -} - -type SetReplicatorReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PeerID []byte `protobuf:"bytes,1,opt,name=peerID,proto3" json:"peerID,omitempty"` -} - -func (x *SetReplicatorReply) Reset() { - *x = SetReplicatorReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SetReplicatorReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SetReplicatorReply) ProtoMessage() {} - -func (x *SetReplicatorReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SetReplicatorReply.ProtoReflect.Descriptor instead. -func (*SetReplicatorReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{12} -} - -func (x *SetReplicatorReply) GetPeerID() []byte { - if x != nil { - return x.PeerID - } - return nil -} - -type DeleteReplicatorRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PeerID []byte `protobuf:"bytes,1,opt,name=peerID,proto3" json:"peerID,omitempty"` - Collections []string `protobuf:"bytes,2,rep,name=collections,proto3" json:"collections,omitempty"` -} - -func (x *DeleteReplicatorRequest) Reset() { - *x = DeleteReplicatorRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteReplicatorRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteReplicatorRequest) ProtoMessage() {} - -func (x *DeleteReplicatorRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteReplicatorRequest.ProtoReflect.Descriptor instead. -func (*DeleteReplicatorRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{13} -} - -func (x *DeleteReplicatorRequest) GetPeerID() []byte { - if x != nil { - return x.PeerID - } - return nil -} - -func (x *DeleteReplicatorRequest) GetCollections() []string { - if x != nil { - return x.Collections - } - return nil -} - -type DeleteReplicatorReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PeerID []byte `protobuf:"bytes,1,opt,name=peerID,proto3" json:"peerID,omitempty"` -} - -func (x *DeleteReplicatorReply) Reset() { - *x = DeleteReplicatorReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteReplicatorReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteReplicatorReply) ProtoMessage() {} - -func (x *DeleteReplicatorReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[14] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteReplicatorReply.ProtoReflect.Descriptor instead. -func (*DeleteReplicatorReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{14} -} - -func (x *DeleteReplicatorReply) GetPeerID() []byte { - if x != nil { - return x.PeerID - } - return nil -} - -type GetAllReplicatorRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *GetAllReplicatorRequest) Reset() { - *x = GetAllReplicatorRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetAllReplicatorRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetAllReplicatorRequest) ProtoMessage() {} - -func (x *GetAllReplicatorRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[15] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetAllReplicatorRequest.ProtoReflect.Descriptor instead. -func (*GetAllReplicatorRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{15} -} - -type GetAllReplicatorReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Replicators []*GetAllReplicatorReply_Replicators `protobuf:"bytes,1,rep,name=replicators,proto3" json:"replicators,omitempty"` -} - -func (x *GetAllReplicatorReply) Reset() { - *x = GetAllReplicatorReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetAllReplicatorReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetAllReplicatorReply) ProtoMessage() {} - -func (x *GetAllReplicatorReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[16] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetAllReplicatorReply.ProtoReflect.Descriptor instead. -func (*GetAllReplicatorReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{16} -} - -func (x *GetAllReplicatorReply) GetReplicators() []*GetAllReplicatorReply_Replicators { - if x != nil { - return x.Replicators - } - return nil -} - -type AddP2PCollectionsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Collections []string `protobuf:"bytes,1,rep,name=collections,proto3" json:"collections,omitempty"` -} - -func (x *AddP2PCollectionsRequest) Reset() { - *x = AddP2PCollectionsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AddP2PCollectionsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddP2PCollectionsRequest) ProtoMessage() {} - -func (x *AddP2PCollectionsRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[17] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AddP2PCollectionsRequest.ProtoReflect.Descriptor instead. -func (*AddP2PCollectionsRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{17} -} - -func (x *AddP2PCollectionsRequest) GetCollections() []string { - if x != nil { - return x.Collections - } - return nil -} - -type AddP2PCollectionsReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Err string `protobuf:"bytes,1,opt,name=err,proto3" json:"err,omitempty"` -} - -func (x *AddP2PCollectionsReply) Reset() { - *x = AddP2PCollectionsReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AddP2PCollectionsReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddP2PCollectionsReply) ProtoMessage() {} - -func (x *AddP2PCollectionsReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[18] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AddP2PCollectionsReply.ProtoReflect.Descriptor instead. -func (*AddP2PCollectionsReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{18} -} - -func (x *AddP2PCollectionsReply) GetErr() string { - if x != nil { - return x.Err - } - return "" -} - -type RemoveP2PCollectionsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Collections []string `protobuf:"bytes,1,rep,name=collections,proto3" json:"collections,omitempty"` -} - -func (x *RemoveP2PCollectionsRequest) Reset() { - *x = RemoveP2PCollectionsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RemoveP2PCollectionsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RemoveP2PCollectionsRequest) ProtoMessage() {} - -func (x *RemoveP2PCollectionsRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[19] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RemoveP2PCollectionsRequest.ProtoReflect.Descriptor instead. -func (*RemoveP2PCollectionsRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{19} -} - -func (x *RemoveP2PCollectionsRequest) GetCollections() []string { - if x != nil { - return x.Collections - } - return nil -} - -type RemoveP2PCollectionsReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Err string `protobuf:"bytes,1,opt,name=err,proto3" json:"err,omitempty"` -} - -func (x *RemoveP2PCollectionsReply) Reset() { - *x = RemoveP2PCollectionsReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RemoveP2PCollectionsReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RemoveP2PCollectionsReply) ProtoMessage() {} - -func (x *RemoveP2PCollectionsReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[20] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RemoveP2PCollectionsReply.ProtoReflect.Descriptor instead. -func (*RemoveP2PCollectionsReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{20} -} - -func (x *RemoveP2PCollectionsReply) GetErr() string { - if x != nil { - return x.Err - } - return "" -} - -type GetAllP2PCollectionsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *GetAllP2PCollectionsRequest) Reset() { - *x = GetAllP2PCollectionsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetAllP2PCollectionsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetAllP2PCollectionsRequest) ProtoMessage() {} - -func (x *GetAllP2PCollectionsRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[21] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetAllP2PCollectionsRequest.ProtoReflect.Descriptor instead. -func (*GetAllP2PCollectionsRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{21} -} - -type GetAllP2PCollectionsReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Collections []*GetAllP2PCollectionsReply_Collection `protobuf:"bytes,1,rep,name=collections,proto3" json:"collections,omitempty"` -} - -func (x *GetAllP2PCollectionsReply) Reset() { - *x = GetAllP2PCollectionsReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetAllP2PCollectionsReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetAllP2PCollectionsReply) ProtoMessage() {} - -func (x *GetAllP2PCollectionsReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[22] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetAllP2PCollectionsReply.ProtoReflect.Descriptor instead. -func (*GetAllP2PCollectionsReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{22} -} - -func (x *GetAllP2PCollectionsReply) GetCollections() []*GetAllP2PCollectionsReply_Collection { - if x != nil { - return x.Collections - } - return nil -} - -// Record is a thread record containing link data. -type Document_Log struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // block is the top-level node's raw data as an ipld.Block. - Block []byte `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` -} - -func (x *Document_Log) Reset() { - *x = Document_Log{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Document_Log) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Document_Log) ProtoMessage() {} - -func (x *Document_Log) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[23] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Document_Log.ProtoReflect.Descriptor instead. -func (*Document_Log) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{0, 0} -} - -func (x *Document_Log) GetBlock() []byte { - if x != nil { - return x.Block - } - return nil -} - -type PushLogRequest_Body struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // docKey is the DocKey of the document that is affected by the log. - DocKey []byte `protobuf:"bytes,1,opt,name=docKey,proto3" json:"docKey,omitempty"` - // cid is the CID of the composite of the document. - Cid []byte `protobuf:"bytes,2,opt,name=cid,proto3" json:"cid,omitempty"` - // schemaID is the SchemaID of the collection that the document resides in. - SchemaID []byte `protobuf:"bytes,3,opt,name=schemaID,proto3" json:"schemaID,omitempty"` - // creator is the PeerID of the peer that created the log. - Creator string `protobuf:"bytes,4,opt,name=creator,proto3" json:"creator,omitempty"` - // log hold the block that represent version of the document. - Log *Document_Log `protobuf:"bytes,6,opt,name=log,proto3" json:"log,omitempty"` -} - -func (x *PushLogRequest_Body) Reset() { - *x = PushLogRequest_Body{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PushLogRequest_Body) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PushLogRequest_Body) ProtoMessage() {} - -func (x *PushLogRequest_Body) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[24] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PushLogRequest_Body.ProtoReflect.Descriptor instead. -func (*PushLogRequest_Body) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{7, 0} -} - -func (x *PushLogRequest_Body) GetDocKey() []byte { - if x != nil { - return x.DocKey - } - return nil -} - -func (x *PushLogRequest_Body) GetCid() []byte { - if x != nil { - return x.Cid - } - return nil -} - -func (x *PushLogRequest_Body) GetSchemaID() []byte { - if x != nil { - return x.SchemaID - } - return nil -} - -func (x *PushLogRequest_Body) GetCreator() string { - if x != nil { - return x.Creator - } - return "" -} - -func (x *PushLogRequest_Body) GetLog() *Document_Log { - if x != nil { - return x.Log - } - return nil -} - -type GetAllReplicatorReply_Replicators struct { +// Record is a thread record containing link data. +type Document_Log struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Info *GetAllReplicatorReply_Replicators_Info `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` - Schemas []string `protobuf:"bytes,2,rep,name=schemas,proto3" json:"schemas,omitempty"` + // block is the top-level node's raw data as an ipld.Block. + Block []byte `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` } -func (x *GetAllReplicatorReply_Replicators) Reset() { - *x = GetAllReplicatorReply_Replicators{} +func (x *Document_Log) Reset() { + *x = Document_Log{} if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[25] + mi := &file_net_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *GetAllReplicatorReply_Replicators) String() string { +func (x *Document_Log) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetAllReplicatorReply_Replicators) ProtoMessage() {} +func (*Document_Log) ProtoMessage() {} -func (x *GetAllReplicatorReply_Replicators) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[25] +func (x *Document_Log) ProtoReflect() protoreflect.Message { + mi := &file_net_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1198,51 +504,52 @@ func (x *GetAllReplicatorReply_Replicators) ProtoReflect() protoreflect.Message return mi.MessageOf(x) } -// Deprecated: Use GetAllReplicatorReply_Replicators.ProtoReflect.Descriptor instead. -func (*GetAllReplicatorReply_Replicators) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{16, 0} -} - -func (x *GetAllReplicatorReply_Replicators) GetInfo() *GetAllReplicatorReply_Replicators_Info { - if x != nil { - return x.Info - } - return nil +// Deprecated: Use Document_Log.ProtoReflect.Descriptor instead. +func (*Document_Log) Descriptor() ([]byte, []int) { + return file_net_proto_rawDescGZIP(), []int{0, 0} } -func (x *GetAllReplicatorReply_Replicators) GetSchemas() []string { +func (x *Document_Log) GetBlock() []byte { if x != nil { - return x.Schemas + return x.Block } return nil } -type GetAllReplicatorReply_Replicators_Info struct { +type PushLogRequest_Body struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Addrs []byte `protobuf:"bytes,2,opt,name=addrs,proto3" json:"addrs,omitempty"` + // docKey is the DocKey of the document that is affected by the log. + DocKey []byte `protobuf:"bytes,1,opt,name=docKey,proto3" json:"docKey,omitempty"` + // cid is the CID of the composite of the document. + Cid []byte `protobuf:"bytes,2,opt,name=cid,proto3" json:"cid,omitempty"` + // schemaID is the SchemaID of the collection that the document resides in. + SchemaID []byte `protobuf:"bytes,3,opt,name=schemaID,proto3" json:"schemaID,omitempty"` + // creator is the PeerID of the peer that created the log. + Creator string `protobuf:"bytes,4,opt,name=creator,proto3" json:"creator,omitempty"` + // log hold the block that represent version of the document. + Log *Document_Log `protobuf:"bytes,6,opt,name=log,proto3" json:"log,omitempty"` } -func (x *GetAllReplicatorReply_Replicators_Info) Reset() { - *x = GetAllReplicatorReply_Replicators_Info{} +func (x *PushLogRequest_Body) Reset() { + *x = PushLogRequest_Body{} if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[26] + mi := &file_net_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *GetAllReplicatorReply_Replicators_Info) String() string { +func (x *PushLogRequest_Body) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetAllReplicatorReply_Replicators_Info) ProtoMessage() {} +func (*PushLogRequest_Body) ProtoMessage() {} -func (x *GetAllReplicatorReply_Replicators_Info) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[26] +func (x *PushLogRequest_Body) ProtoReflect() protoreflect.Message { + mi := &file_net_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1253,78 +560,44 @@ func (x *GetAllReplicatorReply_Replicators_Info) ProtoReflect() protoreflect.Mes return mi.MessageOf(x) } -// Deprecated: Use GetAllReplicatorReply_Replicators_Info.ProtoReflect.Descriptor instead. -func (*GetAllReplicatorReply_Replicators_Info) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{16, 0, 0} +// Deprecated: Use PushLogRequest_Body.ProtoReflect.Descriptor instead. +func (*PushLogRequest_Body) Descriptor() ([]byte, []int) { + return file_net_proto_rawDescGZIP(), []int{7, 0} } -func (x *GetAllReplicatorReply_Replicators_Info) GetId() []byte { +func (x *PushLogRequest_Body) GetDocKey() []byte { if x != nil { - return x.Id + return x.DocKey } return nil } -func (x *GetAllReplicatorReply_Replicators_Info) GetAddrs() []byte { +func (x *PushLogRequest_Body) GetCid() []byte { if x != nil { - return x.Addrs + return x.Cid } return nil } -type GetAllP2PCollectionsReply_Collection struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *GetAllP2PCollectionsReply_Collection) Reset() { - *x = GetAllP2PCollectionsReply_Collection{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[27] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetAllP2PCollectionsReply_Collection) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetAllP2PCollectionsReply_Collection) ProtoMessage() {} - -func (x *GetAllP2PCollectionsReply_Collection) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[27] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms +func (x *PushLogRequest_Body) GetSchemaID() []byte { + if x != nil { + return x.SchemaID } - return mi.MessageOf(x) -} - -// Deprecated: Use GetAllP2PCollectionsReply_Collection.ProtoReflect.Descriptor instead. -func (*GetAllP2PCollectionsReply_Collection) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{22, 0} + return nil } -func (x *GetAllP2PCollectionsReply_Collection) GetId() string { +func (x *PushLogRequest_Body) GetCreator() string { if x != nil { - return x.Id + return x.Creator } return "" } -func (x *GetAllP2PCollectionsReply_Collection) GetName() string { +func (x *PushLogRequest_Body) GetLog() *Document_Log { if x != nil { - return x.Name + return x.Log } - return "" + return nil } var File_net_proto protoreflect.FileDescriptor @@ -1360,124 +633,30 @@ var file_net_proto_rawDesc = []byte{ 0x6c, 0x6f, 0x67, 0x22, 0x13, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x75, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x11, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x48, - 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x4c, 0x0a, 0x14, 0x53, - 0x65, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, 0x22, 0x2c, 0x0a, 0x12, 0x53, 0x65, 0x74, - 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, - 0x16, 0x0a, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x44, 0x22, 0x53, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x44, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, - 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x0b, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x2f, 0x0a, 0x15, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, - 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x44, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x44, 0x22, 0x19, 0x0a, - 0x17, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x80, 0x02, 0x0a, 0x15, 0x47, 0x65, 0x74, - 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x70, - 0x6c, 0x79, 0x12, 0x4b, 0x0a, 0x0b, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, - 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, - 0x72, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, - 0x72, 0x73, 0x52, 0x0b, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x1a, - 0x99, 0x01, 0x0a, 0x0b, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, - 0x42, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, - 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x2e, 0x52, 0x65, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, - 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x1a, 0x2c, 0x0a, - 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x22, 0x3c, 0x0a, 0x18, 0x41, - 0x64, 0x64, 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6c, 0x6c, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, - 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x2a, 0x0a, 0x16, 0x41, 0x64, 0x64, - 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, - 0x70, 0x6c, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x3f, 0x0a, 0x1b, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x50, - 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6c, 0x6c, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x2d, 0x0a, 0x19, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, - 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, - 0x70, 0x6c, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x1d, 0x0a, 0x1b, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x50, - 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x22, 0x9d, 0x01, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x50, - 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x70, - 0x6c, 0x79, 0x12, 0x4e, 0x0a, 0x0b, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, - 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x1a, 0x30, 0x0a, 0x0a, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x32, 0xd1, 0x02, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x45, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x12, - 0x1a, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x47, - 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x6e, 0x65, - 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, - 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x0c, 0x50, 0x75, 0x73, 0x68, 0x44, - 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x12, 0x1b, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, - 0x2e, 0x50, 0x75, 0x73, 0x68, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, - 0x73, 0x68, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, - 0x00, 0x12, 0x36, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x12, 0x15, 0x2e, 0x6e, 0x65, - 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x4c, - 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x07, 0x50, 0x75, 0x73, - 0x68, 0x4c, 0x6f, 0x67, 0x12, 0x16, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, - 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x6e, - 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, - 0x6c, 0x79, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x4c, - 0x6f, 0x67, 0x12, 0x19, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x48, - 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, - 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x4c, 0x6f, - 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x32, 0xa3, 0x04, 0x0a, 0x0a, 0x43, 0x6f, 0x6c, - 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4b, 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x52, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1c, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, - 0x62, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, - 0x53, 0x65, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x70, - 0x6c, 0x79, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1f, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, - 0x62, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, - 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6e, 0x65, 0x74, 0x2e, - 0x70, 0x62, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x6f, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x55, 0x0a, 0x11, 0x47, 0x65, - 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, - 0x1f, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x52, - 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1d, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, - 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, - 0x00, 0x12, 0x57, 0x0a, 0x11, 0x41, 0x64, 0x64, 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x20, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, - 0x41, 0x64, 0x64, 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, - 0x62, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x60, 0x0a, 0x14, 0x52, 0x65, - 0x6d, 0x6f, 0x76, 0x65, 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x12, 0x23, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x6d, 0x6f, - 0x76, 0x65, 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, - 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x60, 0x0a, 0x14, - 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x23, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, - 0x74, 0x41, 0x6c, 0x6c, 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x6e, 0x65, 0x74, 0x2e, - 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x50, 0x32, 0x50, 0x43, 0x6f, 0x6c, 0x6c, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x0a, - 0x5a, 0x08, 0x2f, 0x3b, 0x6e, 0x65, 0x74, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x32, 0xd1, 0x02, 0x0a, 0x07, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x45, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x44, 0x6f, + 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x12, 0x1a, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, + 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x44, + 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x48, + 0x0a, 0x0c, 0x50, 0x75, 0x73, 0x68, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x12, 0x1b, + 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x44, 0x6f, 0x63, 0x47, + 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6e, 0x65, + 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, + 0x68, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x4c, + 0x6f, 0x67, 0x12, 0x15, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x4c, + 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6e, 0x65, 0x74, 0x2e, + 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, + 0x12, 0x39, 0x0a, 0x07, 0x50, 0x75, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x12, 0x16, 0x2e, 0x6e, 0x65, + 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x73, + 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x0a, 0x47, + 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x12, 0x19, 0x2e, 0x6e, 0x65, 0x74, 0x2e, + 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, + 0x74, 0x48, 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, + 0x0a, 0x5a, 0x08, 0x2f, 0x3b, 0x6e, 0x65, 0x74, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -1492,70 +671,40 @@ func file_net_proto_rawDescGZIP() []byte { return file_net_proto_rawDescData } -var file_net_proto_msgTypes = make([]protoimpl.MessageInfo, 28) +var file_net_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_net_proto_goTypes = []interface{}{ - (*Document)(nil), // 0: net.pb.Document - (*GetDocGraphRequest)(nil), // 1: net.pb.GetDocGraphRequest - (*GetDocGraphReply)(nil), // 2: net.pb.GetDocGraphReply - (*PushDocGraphRequest)(nil), // 3: net.pb.PushDocGraphRequest - (*PushDocGraphReply)(nil), // 4: net.pb.PushDocGraphReply - (*GetLogRequest)(nil), // 5: net.pb.GetLogRequest - (*GetLogReply)(nil), // 6: net.pb.GetLogReply - (*PushLogRequest)(nil), // 7: net.pb.PushLogRequest - (*GetHeadLogRequest)(nil), // 8: net.pb.GetHeadLogRequest - (*PushLogReply)(nil), // 9: net.pb.PushLogReply - (*GetHeadLogReply)(nil), // 10: net.pb.GetHeadLogReply - (*SetReplicatorRequest)(nil), // 11: net.pb.SetReplicatorRequest - (*SetReplicatorReply)(nil), // 12: net.pb.SetReplicatorReply - (*DeleteReplicatorRequest)(nil), // 13: net.pb.DeleteReplicatorRequest - (*DeleteReplicatorReply)(nil), // 14: net.pb.DeleteReplicatorReply - (*GetAllReplicatorRequest)(nil), // 15: net.pb.GetAllReplicatorRequest - (*GetAllReplicatorReply)(nil), // 16: net.pb.GetAllReplicatorReply - (*AddP2PCollectionsRequest)(nil), // 17: net.pb.AddP2PCollectionsRequest - (*AddP2PCollectionsReply)(nil), // 18: net.pb.AddP2PCollectionsReply - (*RemoveP2PCollectionsRequest)(nil), // 19: net.pb.RemoveP2PCollectionsRequest - (*RemoveP2PCollectionsReply)(nil), // 20: net.pb.RemoveP2PCollectionsReply - (*GetAllP2PCollectionsRequest)(nil), // 21: net.pb.GetAllP2PCollectionsRequest - (*GetAllP2PCollectionsReply)(nil), // 22: net.pb.GetAllP2PCollectionsReply - (*Document_Log)(nil), // 23: net.pb.Document.Log - (*PushLogRequest_Body)(nil), // 24: net.pb.PushLogRequest.Body - (*GetAllReplicatorReply_Replicators)(nil), // 25: net.pb.GetAllReplicatorReply.Replicators - (*GetAllReplicatorReply_Replicators_Info)(nil), // 26: net.pb.GetAllReplicatorReply.Replicators.Info - (*GetAllP2PCollectionsReply_Collection)(nil), // 27: net.pb.GetAllP2PCollectionsReply.Collection + (*Document)(nil), // 0: net.pb.Document + (*GetDocGraphRequest)(nil), // 1: net.pb.GetDocGraphRequest + (*GetDocGraphReply)(nil), // 2: net.pb.GetDocGraphReply + (*PushDocGraphRequest)(nil), // 3: net.pb.PushDocGraphRequest + (*PushDocGraphReply)(nil), // 4: net.pb.PushDocGraphReply + (*GetLogRequest)(nil), // 5: net.pb.GetLogRequest + (*GetLogReply)(nil), // 6: net.pb.GetLogReply + (*PushLogRequest)(nil), // 7: net.pb.PushLogRequest + (*GetHeadLogRequest)(nil), // 8: net.pb.GetHeadLogRequest + (*PushLogReply)(nil), // 9: net.pb.PushLogReply + (*GetHeadLogReply)(nil), // 10: net.pb.GetHeadLogReply + (*Document_Log)(nil), // 11: net.pb.Document.Log + (*PushLogRequest_Body)(nil), // 12: net.pb.PushLogRequest.Body } var file_net_proto_depIdxs = []int32{ - 24, // 0: net.pb.PushLogRequest.body:type_name -> net.pb.PushLogRequest.Body - 25, // 1: net.pb.GetAllReplicatorReply.replicators:type_name -> net.pb.GetAllReplicatorReply.Replicators - 27, // 2: net.pb.GetAllP2PCollectionsReply.collections:type_name -> net.pb.GetAllP2PCollectionsReply.Collection - 23, // 3: net.pb.PushLogRequest.Body.log:type_name -> net.pb.Document.Log - 26, // 4: net.pb.GetAllReplicatorReply.Replicators.info:type_name -> net.pb.GetAllReplicatorReply.Replicators.Info - 1, // 5: net.pb.Service.GetDocGraph:input_type -> net.pb.GetDocGraphRequest - 3, // 6: net.pb.Service.PushDocGraph:input_type -> net.pb.PushDocGraphRequest - 5, // 7: net.pb.Service.GetLog:input_type -> net.pb.GetLogRequest - 7, // 8: net.pb.Service.PushLog:input_type -> net.pb.PushLogRequest - 8, // 9: net.pb.Service.GetHeadLog:input_type -> net.pb.GetHeadLogRequest - 11, // 10: net.pb.Collection.SetReplicator:input_type -> net.pb.SetReplicatorRequest - 13, // 11: net.pb.Collection.DeleteReplicator:input_type -> net.pb.DeleteReplicatorRequest - 15, // 12: net.pb.Collection.GetAllReplicators:input_type -> net.pb.GetAllReplicatorRequest - 17, // 13: net.pb.Collection.AddP2PCollections:input_type -> net.pb.AddP2PCollectionsRequest - 19, // 14: net.pb.Collection.RemoveP2PCollections:input_type -> net.pb.RemoveP2PCollectionsRequest - 21, // 15: net.pb.Collection.GetAllP2PCollections:input_type -> net.pb.GetAllP2PCollectionsRequest - 2, // 16: net.pb.Service.GetDocGraph:output_type -> net.pb.GetDocGraphReply - 4, // 17: net.pb.Service.PushDocGraph:output_type -> net.pb.PushDocGraphReply - 6, // 18: net.pb.Service.GetLog:output_type -> net.pb.GetLogReply - 9, // 19: net.pb.Service.PushLog:output_type -> net.pb.PushLogReply - 10, // 20: net.pb.Service.GetHeadLog:output_type -> net.pb.GetHeadLogReply - 12, // 21: net.pb.Collection.SetReplicator:output_type -> net.pb.SetReplicatorReply - 14, // 22: net.pb.Collection.DeleteReplicator:output_type -> net.pb.DeleteReplicatorReply - 16, // 23: net.pb.Collection.GetAllReplicators:output_type -> net.pb.GetAllReplicatorReply - 18, // 24: net.pb.Collection.AddP2PCollections:output_type -> net.pb.AddP2PCollectionsReply - 20, // 25: net.pb.Collection.RemoveP2PCollections:output_type -> net.pb.RemoveP2PCollectionsReply - 22, // 26: net.pb.Collection.GetAllP2PCollections:output_type -> net.pb.GetAllP2PCollectionsReply - 16, // [16:27] is the sub-list for method output_type - 5, // [5:16] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 12, // 0: net.pb.PushLogRequest.body:type_name -> net.pb.PushLogRequest.Body + 11, // 1: net.pb.PushLogRequest.Body.log:type_name -> net.pb.Document.Log + 1, // 2: net.pb.Service.GetDocGraph:input_type -> net.pb.GetDocGraphRequest + 3, // 3: net.pb.Service.PushDocGraph:input_type -> net.pb.PushDocGraphRequest + 5, // 4: net.pb.Service.GetLog:input_type -> net.pb.GetLogRequest + 7, // 5: net.pb.Service.PushLog:input_type -> net.pb.PushLogRequest + 8, // 6: net.pb.Service.GetHeadLog:input_type -> net.pb.GetHeadLogRequest + 2, // 7: net.pb.Service.GetDocGraph:output_type -> net.pb.GetDocGraphReply + 4, // 8: net.pb.Service.PushDocGraph:output_type -> net.pb.PushDocGraphReply + 6, // 9: net.pb.Service.GetLog:output_type -> net.pb.GetLogReply + 9, // 10: net.pb.Service.PushLog:output_type -> net.pb.PushLogReply + 10, // 11: net.pb.Service.GetHeadLog:output_type -> net.pb.GetHeadLogReply + 7, // [7:12] is the sub-list for method output_type + 2, // [2:7] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_net_proto_init() } @@ -1697,150 +846,6 @@ func file_net_proto_init() { } } file_net_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SetReplicatorRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SetReplicatorReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteReplicatorRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteReplicatorReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetAllReplicatorRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetAllReplicatorReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddP2PCollectionsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddP2PCollectionsReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveP2PCollectionsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveP2PCollectionsReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetAllP2PCollectionsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetAllP2PCollectionsReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Document_Log); i { case 0: return &v.state @@ -1852,7 +857,7 @@ func file_net_proto_init() { return nil } } - file_net_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + file_net_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PushLogRequest_Body); i { case 0: return &v.state @@ -1864,42 +869,6 @@ func file_net_proto_init() { return nil } } - file_net_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetAllReplicatorReply_Replicators); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetAllReplicatorReply_Replicators_Info); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetAllP2PCollectionsReply_Collection); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1907,9 +876,9 @@ func file_net_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_net_proto_rawDesc, NumEnums: 0, - NumMessages: 28, + NumMessages: 13, NumExtensions: 0, - NumServices: 2, + NumServices: 1, }, GoTypes: file_net_proto_goTypes, DependencyIndexes: file_net_proto_depIdxs, diff --git a/net/pb/net.proto b/net/pb/net.proto index a4799a1d89..04bea485c8 100644 --- a/net/pb/net.proto +++ b/net/pb/net.proto @@ -65,82 +65,3 @@ service Service { // GetHeadLog from this peer rpc GetHeadLog(GetHeadLogRequest) returns (GetHeadLogReply) {} } - -message SetReplicatorRequest { - repeated string collections = 1; - bytes addr = 2; -} - -message SetReplicatorReply { - bytes peerID = 1; -} - -message DeleteReplicatorRequest { - bytes peerID = 1; - repeated string collections = 2; -} - -message DeleteReplicatorReply { - bytes peerID = 1; -} - -message GetAllReplicatorRequest {} - -message GetAllReplicatorReply { - message Replicators { - message Info { - bytes id = 1; - bytes addrs = 2; - } - Info info = 1; - repeated string schemas = 2; - } - - repeated Replicators replicators = 1; - -} - -message AddP2PCollectionsRequest { - repeated string collections = 1; -} - -message AddP2PCollectionsReply { - string err = 1; -} - -message RemoveP2PCollectionsRequest { - repeated string collections = 1; -} - -message RemoveP2PCollectionsReply { - string err = 1; -} - -message GetAllP2PCollectionsRequest {} - -message GetAllP2PCollectionsReply { - message Collection { - string id = 1; - string name = 2; - } - repeated Collection collections = 1; -} - - -// Collection is the peer-to-peer network API for document sync by replication and subscription to collections -service Collection { - // SetReplicator for this peer - rpc SetReplicator(SetReplicatorRequest) returns (SetReplicatorReply) {} - - // DeleteReplicator for this peer - rpc DeleteReplicator(DeleteReplicatorRequest) returns (DeleteReplicatorReply) {} - - // DeleteReplicator for this peer - rpc GetAllReplicators(GetAllReplicatorRequest) returns (GetAllReplicatorReply) {} - - rpc AddP2PCollections(AddP2PCollectionsRequest) returns (AddP2PCollectionsReply) {} - - rpc RemoveP2PCollections(RemoveP2PCollectionsRequest) returns (RemoveP2PCollectionsReply) {} - - rpc GetAllP2PCollections(GetAllP2PCollectionsRequest) returns (GetAllP2PCollectionsReply) {} -} \ No newline at end of file diff --git a/net/pb/net_grpc.pb.go b/net/pb/net_grpc.pb.go index e50cbec859..c42b111148 100644 --- a/net/pb/net_grpc.pb.go +++ b/net/pb/net_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v3.21.9 +// - protoc v4.24.3 // source: net.proto package net_pb @@ -265,284 +265,3 @@ var Service_ServiceDesc = grpc.ServiceDesc{ Streams: []grpc.StreamDesc{}, Metadata: "net.proto", } - -const ( - Collection_SetReplicator_FullMethodName = "/net.pb.Collection/SetReplicator" - Collection_DeleteReplicator_FullMethodName = "/net.pb.Collection/DeleteReplicator" - Collection_GetAllReplicators_FullMethodName = "/net.pb.Collection/GetAllReplicators" - Collection_AddP2PCollections_FullMethodName = "/net.pb.Collection/AddP2PCollections" - Collection_RemoveP2PCollections_FullMethodName = "/net.pb.Collection/RemoveP2PCollections" - Collection_GetAllP2PCollections_FullMethodName = "/net.pb.Collection/GetAllP2PCollections" -) - -// CollectionClient is the client API for Collection service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type CollectionClient interface { - // SetReplicator for this peer - SetReplicator(ctx context.Context, in *SetReplicatorRequest, opts ...grpc.CallOption) (*SetReplicatorReply, error) - // DeleteReplicator for this peer - DeleteReplicator(ctx context.Context, in *DeleteReplicatorRequest, opts ...grpc.CallOption) (*DeleteReplicatorReply, error) - // DeleteReplicator for this peer - GetAllReplicators(ctx context.Context, in *GetAllReplicatorRequest, opts ...grpc.CallOption) (*GetAllReplicatorReply, error) - AddP2PCollections(ctx context.Context, in *AddP2PCollectionsRequest, opts ...grpc.CallOption) (*AddP2PCollectionsReply, error) - RemoveP2PCollections(ctx context.Context, in *RemoveP2PCollectionsRequest, opts ...grpc.CallOption) (*RemoveP2PCollectionsReply, error) - GetAllP2PCollections(ctx context.Context, in *GetAllP2PCollectionsRequest, opts ...grpc.CallOption) (*GetAllP2PCollectionsReply, error) -} - -type collectionClient struct { - cc grpc.ClientConnInterface -} - -func NewCollectionClient(cc grpc.ClientConnInterface) CollectionClient { - return &collectionClient{cc} -} - -func (c *collectionClient) SetReplicator(ctx context.Context, in *SetReplicatorRequest, opts ...grpc.CallOption) (*SetReplicatorReply, error) { - out := new(SetReplicatorReply) - err := c.cc.Invoke(ctx, Collection_SetReplicator_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *collectionClient) DeleteReplicator(ctx context.Context, in *DeleteReplicatorRequest, opts ...grpc.CallOption) (*DeleteReplicatorReply, error) { - out := new(DeleteReplicatorReply) - err := c.cc.Invoke(ctx, Collection_DeleteReplicator_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *collectionClient) GetAllReplicators(ctx context.Context, in *GetAllReplicatorRequest, opts ...grpc.CallOption) (*GetAllReplicatorReply, error) { - out := new(GetAllReplicatorReply) - err := c.cc.Invoke(ctx, Collection_GetAllReplicators_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *collectionClient) AddP2PCollections(ctx context.Context, in *AddP2PCollectionsRequest, opts ...grpc.CallOption) (*AddP2PCollectionsReply, error) { - out := new(AddP2PCollectionsReply) - err := c.cc.Invoke(ctx, Collection_AddP2PCollections_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *collectionClient) RemoveP2PCollections(ctx context.Context, in *RemoveP2PCollectionsRequest, opts ...grpc.CallOption) (*RemoveP2PCollectionsReply, error) { - out := new(RemoveP2PCollectionsReply) - err := c.cc.Invoke(ctx, Collection_RemoveP2PCollections_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *collectionClient) GetAllP2PCollections(ctx context.Context, in *GetAllP2PCollectionsRequest, opts ...grpc.CallOption) (*GetAllP2PCollectionsReply, error) { - out := new(GetAllP2PCollectionsReply) - err := c.cc.Invoke(ctx, Collection_GetAllP2PCollections_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// CollectionServer is the server API for Collection service. -// All implementations must embed UnimplementedCollectionServer -// for forward compatibility -type CollectionServer interface { - // SetReplicator for this peer - SetReplicator(context.Context, *SetReplicatorRequest) (*SetReplicatorReply, error) - // DeleteReplicator for this peer - DeleteReplicator(context.Context, *DeleteReplicatorRequest) (*DeleteReplicatorReply, error) - // DeleteReplicator for this peer - GetAllReplicators(context.Context, *GetAllReplicatorRequest) (*GetAllReplicatorReply, error) - AddP2PCollections(context.Context, *AddP2PCollectionsRequest) (*AddP2PCollectionsReply, error) - RemoveP2PCollections(context.Context, *RemoveP2PCollectionsRequest) (*RemoveP2PCollectionsReply, error) - GetAllP2PCollections(context.Context, *GetAllP2PCollectionsRequest) (*GetAllP2PCollectionsReply, error) - mustEmbedUnimplementedCollectionServer() -} - -// UnimplementedCollectionServer must be embedded to have forward compatible implementations. -type UnimplementedCollectionServer struct { -} - -func (UnimplementedCollectionServer) SetReplicator(context.Context, *SetReplicatorRequest) (*SetReplicatorReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetReplicator not implemented") -} -func (UnimplementedCollectionServer) DeleteReplicator(context.Context, *DeleteReplicatorRequest) (*DeleteReplicatorReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteReplicator not implemented") -} -func (UnimplementedCollectionServer) GetAllReplicators(context.Context, *GetAllReplicatorRequest) (*GetAllReplicatorReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetAllReplicators not implemented") -} -func (UnimplementedCollectionServer) AddP2PCollections(context.Context, *AddP2PCollectionsRequest) (*AddP2PCollectionsReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddP2PCollections not implemented") -} -func (UnimplementedCollectionServer) RemoveP2PCollections(context.Context, *RemoveP2PCollectionsRequest) (*RemoveP2PCollectionsReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method RemoveP2PCollections not implemented") -} -func (UnimplementedCollectionServer) GetAllP2PCollections(context.Context, *GetAllP2PCollectionsRequest) (*GetAllP2PCollectionsReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetAllP2PCollections not implemented") -} -func (UnimplementedCollectionServer) mustEmbedUnimplementedCollectionServer() {} - -// UnsafeCollectionServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to CollectionServer will -// result in compilation errors. -type UnsafeCollectionServer interface { - mustEmbedUnimplementedCollectionServer() -} - -func RegisterCollectionServer(s grpc.ServiceRegistrar, srv CollectionServer) { - s.RegisterService(&Collection_ServiceDesc, srv) -} - -func _Collection_SetReplicator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SetReplicatorRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CollectionServer).SetReplicator(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Collection_SetReplicator_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CollectionServer).SetReplicator(ctx, req.(*SetReplicatorRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Collection_DeleteReplicator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteReplicatorRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CollectionServer).DeleteReplicator(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Collection_DeleteReplicator_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CollectionServer).DeleteReplicator(ctx, req.(*DeleteReplicatorRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Collection_GetAllReplicators_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetAllReplicatorRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CollectionServer).GetAllReplicators(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Collection_GetAllReplicators_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CollectionServer).GetAllReplicators(ctx, req.(*GetAllReplicatorRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Collection_AddP2PCollections_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AddP2PCollectionsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CollectionServer).AddP2PCollections(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Collection_AddP2PCollections_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CollectionServer).AddP2PCollections(ctx, req.(*AddP2PCollectionsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Collection_RemoveP2PCollections_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RemoveP2PCollectionsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CollectionServer).RemoveP2PCollections(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Collection_RemoveP2PCollections_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CollectionServer).RemoveP2PCollections(ctx, req.(*RemoveP2PCollectionsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Collection_GetAllP2PCollections_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetAllP2PCollectionsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CollectionServer).GetAllP2PCollections(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Collection_GetAllP2PCollections_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CollectionServer).GetAllP2PCollections(ctx, req.(*GetAllP2PCollectionsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Collection_ServiceDesc is the grpc.ServiceDesc for Collection service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Collection_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "net.pb.Collection", - HandlerType: (*CollectionServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SetReplicator", - Handler: _Collection_SetReplicator_Handler, - }, - { - MethodName: "DeleteReplicator", - Handler: _Collection_DeleteReplicator_Handler, - }, - { - MethodName: "GetAllReplicators", - Handler: _Collection_GetAllReplicators_Handler, - }, - { - MethodName: "AddP2PCollections", - Handler: _Collection_AddP2PCollections_Handler, - }, - { - MethodName: "RemoveP2PCollections", - Handler: _Collection_RemoveP2PCollections_Handler, - }, - { - MethodName: "GetAllP2PCollections", - Handler: _Collection_GetAllP2PCollections_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "net.proto", -} diff --git a/net/pb/net_vtproto.pb.go b/net/pb/net_vtproto.pb.go index 9ac8b5c379..1f5b734a9d 100644 --- a/net/pb/net_vtproto.pb.go +++ b/net/pb/net_vtproto.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go-vtproto. DO NOT EDIT. -// protoc-gen-go-vtproto version: v0.4.0 +// protoc-gen-go-vtproto version: v0.5.0 // source: net.proto package net_pb @@ -516,1939 +516,190 @@ func (m *GetHeadLogReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SetReplicatorRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err +func encodeVarint(dAtA []byte, offset int, v uint64) int { + offset -= sov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ } - return dAtA[:n], nil -} - -func (m *SetReplicatorRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) + dAtA[offset] = uint8(v) + return base } - -func (m *SetReplicatorRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *Document_Log) SizeVT() (n int) { if m == nil { - return 0, nil + return 0 } - i := len(dAtA) - _ = i var l int _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Addr) > 0 { - i -= len(m.Addr) - copy(dAtA[i:], m.Addr) - i = encodeVarint(dAtA, i, uint64(len(m.Addr))) - i-- - dAtA[i] = 0x12 - } - if len(m.Collections) > 0 { - for iNdEx := len(m.Collections) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Collections[iNdEx]) - copy(dAtA[i:], m.Collections[iNdEx]) - i = encodeVarint(dAtA, i, uint64(len(m.Collections[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *SetReplicatorReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err + l = len(m.Block) + if l > 0 { + n += 1 + l + sov(uint64(l)) } - return dAtA[:n], nil -} - -func (m *SetReplicatorReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) + n += len(m.unknownFields) + return n } -func (m *SetReplicatorReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *Document) SizeVT() (n int) { if m == nil { - return 0, nil + return 0 } - i := len(dAtA) - _ = i var l int _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.PeerID) > 0 { - i -= len(m.PeerID) - copy(dAtA[i:], m.PeerID) - i = encodeVarint(dAtA, i, uint64(len(m.PeerID))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DeleteReplicatorRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil + l = len(m.DocKey) + if l > 0 { + n += 1 + l + sov(uint64(l)) } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err + l = len(m.Head) + if l > 0 { + n += 1 + l + sov(uint64(l)) } - return dAtA[:n], nil -} - -func (m *DeleteReplicatorRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) + n += len(m.unknownFields) + return n } -func (m *DeleteReplicatorRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *GetDocGraphRequest) SizeVT() (n int) { if m == nil { - return 0, nil + return 0 } - i := len(dAtA) - _ = i var l int _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Collections) > 0 { - for iNdEx := len(m.Collections) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Collections[iNdEx]) - copy(dAtA[i:], m.Collections[iNdEx]) - i = encodeVarint(dAtA, i, uint64(len(m.Collections[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(m.PeerID) > 0 { - i -= len(m.PeerID) - copy(dAtA[i:], m.PeerID) - i = encodeVarint(dAtA, i, uint64(len(m.PeerID))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DeleteReplicatorReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DeleteReplicatorReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) + n += len(m.unknownFields) + return n } -func (m *DeleteReplicatorReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *GetDocGraphReply) SizeVT() (n int) { if m == nil { - return 0, nil + return 0 } - i := len(dAtA) - _ = i var l int _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.PeerID) > 0 { - i -= len(m.PeerID) - copy(dAtA[i:], m.PeerID) - i = encodeVarint(dAtA, i, uint64(len(m.PeerID))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *GetAllReplicatorRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetAllReplicatorRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) + n += len(m.unknownFields) + return n } -func (m *GetAllReplicatorRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *PushDocGraphRequest) SizeVT() (n int) { if m == nil { - return 0, nil + return 0 } - i := len(dAtA) - _ = i var l int _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - return len(dAtA) - i, nil + n += len(m.unknownFields) + return n } -func (m *GetAllReplicatorReply_Replicators_Info) MarshalVT() (dAtA []byte, err error) { +func (m *PushDocGraphReply) SizeVT() (n int) { if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err + return 0 } - return dAtA[:n], nil -} - -func (m *GetAllReplicatorReply_Replicators_Info) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) + var l int + _ = l + n += len(m.unknownFields) + return n } -func (m *GetAllReplicatorReply_Replicators_Info) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *GetLogRequest) SizeVT() (n int) { if m == nil { - return 0, nil + return 0 } - i := len(dAtA) - _ = i var l int _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Addrs) > 0 { - i -= len(m.Addrs) - copy(dAtA[i:], m.Addrs) - i = encodeVarint(dAtA, i, uint64(len(m.Addrs))) - i-- - dAtA[i] = 0x12 - } - if len(m.Id) > 0 { - i -= len(m.Id) - copy(dAtA[i:], m.Id) - i = encodeVarint(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil + n += len(m.unknownFields) + return n } -func (m *GetAllReplicatorReply_Replicators) MarshalVT() (dAtA []byte, err error) { +func (m *GetLogReply) SizeVT() (n int) { if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err + return 0 } - return dAtA[:n], nil -} - -func (m *GetAllReplicatorReply_Replicators) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) + var l int + _ = l + n += len(m.unknownFields) + return n } -func (m *GetAllReplicatorReply_Replicators) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *PushLogRequest_Body) SizeVT() (n int) { if m == nil { - return 0, nil + return 0 } - i := len(dAtA) - _ = i var l int _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) + l = len(m.DocKey) + if l > 0 { + n += 1 + l + sov(uint64(l)) } - if len(m.Schemas) > 0 { - for iNdEx := len(m.Schemas) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Schemas[iNdEx]) - copy(dAtA[i:], m.Schemas[iNdEx]) - i = encodeVarint(dAtA, i, uint64(len(m.Schemas[iNdEx]))) - i-- - dAtA[i] = 0x12 - } + l = len(m.Cid) + if l > 0 { + n += 1 + l + sov(uint64(l)) } - if m.Info != nil { - size, err := m.Info.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa + l = len(m.SchemaID) + if l > 0 { + n += 1 + l + sov(uint64(l)) } - return len(dAtA) - i, nil -} - -func (m *GetAllReplicatorReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil + l = len(m.Creator) + if l > 0 { + n += 1 + l + sov(uint64(l)) } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetAllReplicatorReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *GetAllReplicatorReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Replicators) > 0 { - for iNdEx := len(m.Replicators) - 1; iNdEx >= 0; iNdEx-- { - size, err := m.Replicators[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *AddP2PCollectionsRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *AddP2PCollectionsRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *AddP2PCollectionsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Collections) > 0 { - for iNdEx := len(m.Collections) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Collections[iNdEx]) - copy(dAtA[i:], m.Collections[iNdEx]) - i = encodeVarint(dAtA, i, uint64(len(m.Collections[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *AddP2PCollectionsReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *AddP2PCollectionsReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *AddP2PCollectionsReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Err) > 0 { - i -= len(m.Err) - copy(dAtA[i:], m.Err) - i = encodeVarint(dAtA, i, uint64(len(m.Err))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RemoveP2PCollectionsRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RemoveP2PCollectionsRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *RemoveP2PCollectionsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Collections) > 0 { - for iNdEx := len(m.Collections) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Collections[iNdEx]) - copy(dAtA[i:], m.Collections[iNdEx]) - i = encodeVarint(dAtA, i, uint64(len(m.Collections[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *RemoveP2PCollectionsReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RemoveP2PCollectionsReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *RemoveP2PCollectionsReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Err) > 0 { - i -= len(m.Err) - copy(dAtA[i:], m.Err) - i = encodeVarint(dAtA, i, uint64(len(m.Err))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *GetAllP2PCollectionsRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetAllP2PCollectionsRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *GetAllP2PCollectionsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - return len(dAtA) - i, nil -} - -func (m *GetAllP2PCollectionsReply_Collection) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetAllP2PCollectionsReply_Collection) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *GetAllP2PCollectionsReply_Collection) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarint(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x12 - } - if len(m.Id) > 0 { - i -= len(m.Id) - copy(dAtA[i:], m.Id) - i = encodeVarint(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *GetAllP2PCollectionsReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetAllP2PCollectionsReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *GetAllP2PCollectionsReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Collections) > 0 { - for iNdEx := len(m.Collections) - 1; iNdEx >= 0; iNdEx-- { - size, err := m.Collections[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarint(dAtA []byte, offset int, v uint64) int { - offset -= sov(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Document_Log) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Block) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *Document) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DocKey) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.Head) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *GetDocGraphRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *GetDocGraphReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *PushDocGraphRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *PushDocGraphReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *GetLogRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *GetLogReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *PushLogRequest_Body) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DocKey) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.Cid) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.SchemaID) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.Creator) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - if m.Log != nil { - l = m.Log.SizeVT() - n += 1 + l + sov(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *PushLogRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Body != nil { - l = m.Body.SizeVT() - n += 1 + l + sov(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *GetHeadLogRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *PushLogReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *GetHeadLogReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *SetReplicatorRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Collections) > 0 { - for _, s := range m.Collections { - l = len(s) - n += 1 + l + sov(uint64(l)) - } - } - l = len(m.Addr) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *SetReplicatorReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PeerID) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *DeleteReplicatorRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PeerID) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - if len(m.Collections) > 0 { - for _, s := range m.Collections { - l = len(s) - n += 1 + l + sov(uint64(l)) - } - } - n += len(m.unknownFields) - return n -} - -func (m *DeleteReplicatorReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PeerID) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *GetAllReplicatorRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *GetAllReplicatorReply_Replicators_Info) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Id) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.Addrs) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *GetAllReplicatorReply_Replicators) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Info != nil { - l = m.Info.SizeVT() - n += 1 + l + sov(uint64(l)) - } - if len(m.Schemas) > 0 { - for _, s := range m.Schemas { - l = len(s) - n += 1 + l + sov(uint64(l)) - } - } - n += len(m.unknownFields) - return n -} - -func (m *GetAllReplicatorReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Replicators) > 0 { - for _, e := range m.Replicators { - l = e.SizeVT() - n += 1 + l + sov(uint64(l)) - } - } - n += len(m.unknownFields) - return n -} - -func (m *AddP2PCollectionsRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Collections) > 0 { - for _, s := range m.Collections { - l = len(s) - n += 1 + l + sov(uint64(l)) - } - } - n += len(m.unknownFields) - return n -} - -func (m *AddP2PCollectionsReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Err) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *RemoveP2PCollectionsRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Collections) > 0 { - for _, s := range m.Collections { - l = len(s) - n += 1 + l + sov(uint64(l)) - } - } - n += len(m.unknownFields) - return n -} - -func (m *RemoveP2PCollectionsReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Err) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *GetAllP2PCollectionsRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *GetAllP2PCollectionsReply_Collection) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Id) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - l = len(m.Name) - if l > 0 { - n += 1 + l + sov(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *GetAllP2PCollectionsReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Collections) > 0 { - for _, e := range m.Collections { - l = e.SizeVT() - n += 1 + l + sov(uint64(l)) - } - } - n += len(m.unknownFields) - return n -} - -func sov(x uint64) (n int) { - return (bits.Len64(x|1) + 6) / 7 -} -func soz(x uint64) (n int) { - return sov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Document_Log) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Document_Log: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Document_Log: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Block = append(m.Block[:0], dAtA[iNdEx:postIndex]...) - if m.Block == nil { - m.Block = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Document) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Document: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Document: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DocKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DocKey = append(m.DocKey[:0], dAtA[iNdEx:postIndex]...) - if m.DocKey == nil { - m.DocKey = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Head", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Head = append(m.Head[:0], dAtA[iNdEx:postIndex]...) - if m.Head == nil { - m.Head = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetDocGraphRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetDocGraphRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetDocGraphRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetDocGraphReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetDocGraphReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetDocGraphReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PushDocGraphRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PushDocGraphRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PushDocGraphRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PushDocGraphReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PushDocGraphReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PushDocGraphReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetLogRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetLogRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetLogRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetLogReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetLogReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetLogReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PushLogRequest_Body) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PushLogRequest_Body: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PushLogRequest_Body: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DocKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DocKey = append(m.DocKey[:0], dAtA[iNdEx:postIndex]...) - if m.DocKey == nil { - m.DocKey = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Cid = append(m.Cid[:0], dAtA[iNdEx:postIndex]...) - if m.Cid == nil { - m.Cid = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SchemaID = append(m.SchemaID[:0], dAtA[iNdEx:postIndex]...) - if m.SchemaID == nil { - m.SchemaID = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Log", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Log == nil { - m.Log = &Document_Log{} - } - if err := m.Log.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PushLogRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PushLogRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PushLogRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Body == nil { - m.Body = &PushLogRequest_Body{} - } - if err := m.Body.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetHeadLogRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetHeadLogRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetHeadLogRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } + if m.Log != nil { + l = m.Log.SizeVT() + n += 1 + l + sov(uint64(l)) } + n += len(m.unknownFields) + return n +} - if iNdEx > l { - return io.ErrUnexpectedEOF +func (m *PushLogRequest) SizeVT() (n int) { + if m == nil { + return 0 } - return nil + var l int + _ = l + if m.Body != nil { + l = m.Body.SizeVT() + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n } -func (m *PushLogReply) UnmarshalVT(dAtA []byte) error { + +func (m *GetHeadLogRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *PushLogReply) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *GetHeadLogReply) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func sov(x uint64) (n int) { + return (bits.Len64(x|1) + 6) / 7 +} +func soz(x uint64) (n int) { + return sov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Document_Log) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2471,63 +722,46 @@ func (m *PushLogReply) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PushLogReply: wiretype end group for non-group") + return fmt.Errorf("proto: Document_Log: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PushLogReply: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Document_Log: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if byteLen < 0 { + return ErrInvalidLength } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetHeadLogReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.Block = append(m.Block[:0], dAtA[iNdEx:postIndex]...) + if m.Block == nil { + m.Block = []byte{} } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetHeadLogReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetHeadLogReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -2550,7 +784,7 @@ func (m *GetHeadLogReply) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *SetReplicatorRequest) UnmarshalVT(dAtA []byte) error { +func (m *Document) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2573,17 +807,17 @@ func (m *SetReplicatorRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SetReplicatorRequest: wiretype end group for non-group") + return fmt.Errorf("proto: Document: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SetReplicatorRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Document: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Collections", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DocKey", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -2593,27 +827,29 @@ func (m *SetReplicatorRequest) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Collections = append(m.Collections, string(dAtA[iNdEx:postIndex])) + m.DocKey = append(m.DocKey[:0], dAtA[iNdEx:postIndex]...) + if m.DocKey == nil { + m.DocKey = []byte{} + } iNdEx = postIndex - case 2: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Head", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -2640,9 +876,9 @@ func (m *SetReplicatorRequest) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Addr = append(m.Addr[:0], dAtA[iNdEx:postIndex]...) - if m.Addr == nil { - m.Addr = []byte{} + m.Head = append(m.Head[:0], dAtA[iNdEx:postIndex]...) + if m.Head == nil { + m.Head = []byte{} } iNdEx = postIndex default: @@ -2667,7 +903,7 @@ func (m *SetReplicatorRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *SetReplicatorReply) UnmarshalVT(dAtA []byte) error { +func (m *GetDocGraphRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2690,46 +926,12 @@ func (m *SetReplicatorReply) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SetReplicatorReply: wiretype end group for non-group") + return fmt.Errorf("proto: GetDocGraphRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SetReplicatorReply: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: GetDocGraphRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PeerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PeerID = append(m.PeerID[:0], dAtA[iNdEx:postIndex]...) - if m.PeerID == nil { - m.PeerID = []byte{} - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -2752,7 +954,7 @@ func (m *SetReplicatorReply) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *DeleteReplicatorRequest) UnmarshalVT(dAtA []byte) error { +func (m *GetDocGraphReply) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2772,81 +974,15 @@ func (m *DeleteReplicatorRequest) UnmarshalVT(dAtA []byte) error { break } } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DeleteReplicatorRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteReplicatorRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PeerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PeerID = append(m.PeerID[:0], dAtA[iNdEx:postIndex]...) - if m.PeerID == nil { - m.PeerID = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Collections", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Collections = append(m.Collections, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetDocGraphReply: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetDocGraphReply: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -2869,7 +1005,7 @@ func (m *DeleteReplicatorRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *DeleteReplicatorReply) UnmarshalVT(dAtA []byte) error { +func (m *PushDocGraphRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2892,46 +1028,12 @@ func (m *DeleteReplicatorReply) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: DeleteReplicatorReply: wiretype end group for non-group") + return fmt.Errorf("proto: PushDocGraphRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteReplicatorReply: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PushDocGraphRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PeerID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PeerID = append(m.PeerID[:0], dAtA[iNdEx:postIndex]...) - if m.PeerID == nil { - m.PeerID = []byte{} - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -2954,7 +1056,7 @@ func (m *DeleteReplicatorReply) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *GetAllReplicatorRequest) UnmarshalVT(dAtA []byte) error { +func (m *PushDocGraphReply) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2977,10 +1079,10 @@ func (m *GetAllReplicatorRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GetAllReplicatorRequest: wiretype end group for non-group") + return fmt.Errorf("proto: PushDocGraphReply: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GetAllReplicatorRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PushDocGraphReply: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -3005,7 +1107,7 @@ func (m *GetAllReplicatorRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *GetAllReplicatorReply_Replicators_Info) UnmarshalVT(dAtA []byte) error { +func (m *GetLogRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3028,80 +1130,12 @@ func (m *GetAllReplicatorReply_Replicators_Info) UnmarshalVT(dAtA []byte) error fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GetAllReplicatorReply_Replicators_Info: wiretype end group for non-group") + return fmt.Errorf("proto: GetLogRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GetAllReplicatorReply_Replicators_Info: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: GetLogRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = append(m.Id[:0], dAtA[iNdEx:postIndex]...) - if m.Id == nil { - m.Id = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addrs", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Addrs = append(m.Addrs[:0], dAtA[iNdEx:postIndex]...) - if m.Addrs == nil { - m.Addrs = []byte{} - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -3124,7 +1158,7 @@ func (m *GetAllReplicatorReply_Replicators_Info) UnmarshalVT(dAtA []byte) error } return nil } -func (m *GetAllReplicatorReply_Replicators) UnmarshalVT(dAtA []byte) error { +func (m *GetLogReply) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3147,80 +1181,12 @@ func (m *GetAllReplicatorReply_Replicators) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GetAllReplicatorReply_Replicators: wiretype end group for non-group") + return fmt.Errorf("proto: GetLogReply: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GetAllReplicatorReply_Replicators: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: GetLogReply: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Info == nil { - m.Info = &GetAllReplicatorReply_Replicators_Info{} - } - if err := m.Info.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Schemas", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Schemas = append(m.Schemas, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -3243,7 +1209,7 @@ func (m *GetAllReplicatorReply_Replicators) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *GetAllReplicatorReply) UnmarshalVT(dAtA []byte) error { +func (m *PushLogRequest_Body) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3266,17 +1232,17 @@ func (m *GetAllReplicatorReply) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GetAllReplicatorReply: wiretype end group for non-group") + return fmt.Errorf("proto: PushLogRequest_Body: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GetAllReplicatorReply: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PushLogRequest_Body: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Replicators", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DocKey", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -3286,82 +1252,65 @@ func (m *GetAllReplicatorReply) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Replicators = append(m.Replicators, &GetAllReplicatorReply_Replicators{}) - if err := m.Replicators[len(m.Replicators)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err + m.DocKey = append(m.DocKey[:0], dAtA[iNdEx:postIndex]...) + if m.DocKey == nil { + m.DocKey = []byte{} } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if byteLen < 0 { + return ErrInvalidLength } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AddP2PCollectionsRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: AddP2PCollectionsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AddP2PCollectionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + m.Cid = append(m.Cid[:0], dAtA[iNdEx:postIndex]...) + if m.Cid == nil { + m.Cid = []byte{} + } + iNdEx = postIndex + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Collections", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SchemaID", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -3371,78 +1320,29 @@ func (m *AddP2PCollectionsRequest) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Collections = append(m.Collections, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AddP2PCollectionsReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.SchemaID = append(m.SchemaID[:0], dAtA[iNdEx:postIndex]...) + if m.SchemaID == nil { + m.SchemaID = []byte{} } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: AddP2PCollectionsReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AddP2PCollectionsReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Err", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3470,64 +1370,13 @@ func (m *AddP2PCollectionsReply) UnmarshalVT(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Err = string(dAtA[iNdEx:postIndex]) + m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RemoveP2PCollectionsRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RemoveP2PCollectionsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RemoveP2PCollectionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Collections", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Log", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -3537,23 +1386,27 @@ func (m *RemoveP2PCollectionsRequest) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Collections = append(m.Collections, string(dAtA[iNdEx:postIndex])) + if m.Log == nil { + m.Log = &Document_Log{} + } + if err := m.Log.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -3577,7 +1430,7 @@ func (m *RemoveP2PCollectionsRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *RemoveP2PCollectionsReply) UnmarshalVT(dAtA []byte) error { +func (m *PushLogRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3600,17 +1453,17 @@ func (m *RemoveP2PCollectionsReply) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RemoveP2PCollectionsReply: wiretype end group for non-group") + return fmt.Errorf("proto: PushLogRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RemoveP2PCollectionsReply: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PushLogRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Err", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -3620,23 +1473,27 @@ func (m *RemoveP2PCollectionsReply) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Err = string(dAtA[iNdEx:postIndex]) + if m.Body == nil { + m.Body = &PushLogRequest_Body{} + } + if err := m.Body.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -3660,7 +1517,7 @@ func (m *RemoveP2PCollectionsReply) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *GetAllP2PCollectionsRequest) UnmarshalVT(dAtA []byte) error { +func (m *GetHeadLogRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3683,10 +1540,10 @@ func (m *GetAllP2PCollectionsRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GetAllP2PCollectionsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: GetHeadLogRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GetAllP2PCollectionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: GetHeadLogRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -3711,7 +1568,7 @@ func (m *GetAllP2PCollectionsRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *GetAllP2PCollectionsReply_Collection) UnmarshalVT(dAtA []byte) error { +func (m *PushLogReply) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3734,76 +1591,12 @@ func (m *GetAllP2PCollectionsReply_Collection) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GetAllP2PCollectionsReply_Collection: wiretype end group for non-group") + return fmt.Errorf("proto: PushLogReply: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GetAllP2PCollectionsReply_Collection: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PushLogReply: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) @@ -3826,7 +1619,7 @@ func (m *GetAllP2PCollectionsReply_Collection) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *GetAllP2PCollectionsReply) UnmarshalVT(dAtA []byte) error { +func (m *GetHeadLogReply) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3849,46 +1642,12 @@ func (m *GetAllP2PCollectionsReply) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GetAllP2PCollectionsReply: wiretype end group for non-group") + return fmt.Errorf("proto: GetHeadLogReply: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GetAllP2PCollectionsReply: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: GetHeadLogReply: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Collections", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Collections = append(m.Collections, &GetAllP2PCollectionsReply_Collection{}) - if err := m.Collections[len(m.Collections)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) diff --git a/net/peer.go b/net/peer.go index 26a24a38ae..e24d124210 100644 --- a/net/peer.go +++ b/net/peer.go @@ -32,10 +32,7 @@ import ( "github.com/libp2p/go-libp2p/core/peer" peerstore "github.com/libp2p/go-libp2p/core/peerstore" "github.com/libp2p/go-libp2p/core/routing" - ma "github.com/multiformats/go-multiaddr" "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" "github.com/sourcenetwork/defradb/client" "github.com/sourcenetwork/defradb/core" @@ -86,8 +83,6 @@ type Peer struct { ctx context.Context cancel context.CancelFunc - - pb.UnimplementedCollectionServer } // NewPeer creates a new instance of the DefraDB server as a peer-to-peer node. @@ -97,7 +92,6 @@ func NewPeer( h host.Host, dht routing.Routing, ps *pubsub.PubSub, - tcpAddr ma.Multiaddr, serverOptions []grpc.ServerOption, dialOptions []grpc.DialOption, ) (*Peer, error) { @@ -313,47 +307,33 @@ func (p *Peer) RegisterNewDocument( return p.server.publishLog(p.ctx, schemaID, req) } -func marshalPeerID(id peer.ID) []byte { - b, _ := id.Marshal() // This will never return an error - return b -} - // SetReplicator adds a target peer node as a replication destination for documents in our DB. func (p *Peer) SetReplicator( ctx context.Context, - req *pb.SetReplicatorRequest, -) (*pb.SetReplicatorReply, error) { - addr, err := ma.NewMultiaddrBytes(req.Addr) - if err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - + rep client.Replicator, +) error { txn, err := p.db.NewTxn(ctx, true) if err != nil { - return nil, err + return err } store := p.db.WithTxn(txn) - pid, err := p.setReplicator(ctx, store, addr, req.Collections...) + err = p.setReplicator(ctx, store, rep.Info, rep.Schemas...) if err != nil { txn.Discard(ctx) - return nil, err + return err } - return &pb.SetReplicatorReply{ - PeerID: marshalPeerID(pid), - }, txn.Commit(ctx) + return txn.Commit(ctx) } // setReplicator adds a target peer node as a replication destination for documents in our DB. func (p *Peer) setReplicator( ctx context.Context, store client.Store, - paddr ma.Multiaddr, + info peer.AddrInfo, collectionNames ...string, -) (peer.ID, error) { - var pid peer.ID - +) error { // verify collections collections := []client.Collection{} schemas := []string{} @@ -361,7 +341,7 @@ func (p *Peer) setReplicator( var err error collections, err = store.GetAllCollections(ctx) if err != nil { - return pid, errors.Wrap("failed to get all collections for replicator", err) + return errors.Wrap("failed to get all collections for replicator", err) } for _, col := range collections { schemas = append(schemas, col.SchemaID()) @@ -370,34 +350,19 @@ func (p *Peer) setReplicator( for _, cName := range collectionNames { col, err := store.GetCollectionByName(ctx, cName) if err != nil { - return pid, errors.Wrap("failed to get collection for replicator", err) + return errors.Wrap("failed to get collection for replicator", err) } collections = append(collections, col) schemas = append(schemas, col.SchemaID()) } } - // extra peerID - // Extract peer portion - p2p, err := paddr.ValueForProtocol(ma.P_P2P) - if err != nil { - return pid, err - } - pid, err = peer.Decode(p2p) - if err != nil { - return pid, err - } - // make sure it's not ourselves - if pid == p.host.ID() { - return pid, errors.New("can't target ourselves as a replicator") + if info.ID == p.host.ID() { + return errors.New("can't target ourselves as a replicator") } - - // add peer to peerstore - // Extract the peer ID from the multiaddr. - info, err := peer.AddrInfoFromP2pAddr(paddr) - if err != nil { - return pid, errors.Wrap(fmt.Sprintf("Failed to address info from %s", paddr), err) + if err := info.ID.Validate(); err != nil { + return err } // Add the destination's peer multiaddress in the peerstore. @@ -408,36 +373,36 @@ func (p *Peer) setReplicator( p.mu.Lock() for _, col := range collections { if reps, exists := p.replicators[col.SchemaID()]; exists { - if _, exists := reps[pid]; exists { + if _, exists := reps[info.ID]; exists { p.mu.Unlock() - return pid, errors.New(fmt.Sprintf( + return errors.New(fmt.Sprintf( "Replicator already exists for %s with PeerID %s", col.Name(), - pid, + info.ID, )) } } else { p.replicators[col.SchemaID()] = make(map[peer.ID]struct{}) } // add to replicators list for the collection - p.replicators[col.SchemaID()][pid] = struct{}{} + p.replicators[col.SchemaID()][info.ID] = struct{}{} } p.mu.Unlock() // Persist peer in datastore - err = p.db.SetReplicator(ctx, client.Replicator{ - Info: *info, + err := p.db.SetReplicator(ctx, client.Replicator{ + Info: info, Schemas: schemas, }) if err != nil { - return pid, errors.Wrap("failed to persist replicator", err) + return errors.Wrap("failed to persist replicator", err) } for _, col := range collections { // create read only txn and assign to col txn, err := p.db.NewTxn(ctx, true) if err != nil { - return pid, errors.Wrap("failed to get txn", err) + return errors.Wrap("failed to get txn", err) } col = col.WithTxn(txn) @@ -445,19 +410,19 @@ func (p *Peer) setReplicator( keysCh, err := col.GetAllDocKeys(ctx) if err != nil { txn.Discard(ctx) - return pid, errors.Wrap( + return errors.Wrap( fmt.Sprintf( "Failed to get dockey for replicator %s on %s", - pid, + info.ID, col.Name(), ), err, ) } - p.pushToReplicator(ctx, txn, col, keysCh, pid) + p.pushToReplicator(ctx, txn, col, keysCh, info.ID) } - return pid, nil + return nil } func (p *Peer) pushToReplicator( @@ -529,37 +494,38 @@ func (p *Peer) pushToReplicator( // DeleteReplicator removes a peer node from the replicators. func (p *Peer) DeleteReplicator( ctx context.Context, - req *pb.DeleteReplicatorRequest, -) (*pb.DeleteReplicatorReply, error) { + rep client.Replicator, +) error { log.Debug(ctx, "Received DeleteReplicator request") txn, err := p.db.NewTxn(ctx, true) if err != nil { - return nil, err + return err } store := p.db.WithTxn(txn) - err = p.deleteReplicator(ctx, store, peer.ID(req.PeerID), req.Collections...) + err = p.deleteReplicator(ctx, store, rep.Info, rep.Schemas...) if err != nil { txn.Discard(ctx) - return nil, err + return err } - return &pb.DeleteReplicatorReply{ - PeerID: req.PeerID, - }, txn.Commit(ctx) + return txn.Commit(ctx) } func (p *Peer) deleteReplicator( ctx context.Context, store client.Store, - pid peer.ID, + info peer.AddrInfo, collectionNames ...string, ) error { // make sure it's not ourselves - if pid == p.host.ID() { + if info.ID == p.host.ID() { return ErrSelfTargetForReplicator } + if err := info.ID.Validate(); err != nil { + return err + } // verify collections schemas := []string{} @@ -591,9 +557,9 @@ func (p *Peer) deleteReplicator( totalSchemas := 0 // Lets keep track of how many schemas are left for the replicator. for schema, rep := range p.replicators { - if _, exists := rep[pid]; exists { + if _, exists := rep[info.ID]; exists { if _, toDelete := schemaMap[schema]; toDelete { - delete(p.replicators[schema], pid) + delete(p.replicators[schema], info.ID) } else { totalSchemas++ } @@ -602,42 +568,21 @@ func (p *Peer) deleteReplicator( if totalSchemas == 0 { // Remove the destination's peer multiaddress in the peerstore. - p.host.Peerstore().ClearAddrs(pid) + p.host.Peerstore().ClearAddrs(info.ID) } // Delete peer in datastore return p.db.DeleteReplicator(ctx, client.Replicator{ - Info: peer.AddrInfo{ID: pid}, + Info: peer.AddrInfo{ID: info.ID}, Schemas: schemas, }) } // GetAllReplicators returns all replicators and the schemas that are replicated to them. -func (p *Peer) GetAllReplicators( - ctx context.Context, - req *pb.GetAllReplicatorRequest, -) (*pb.GetAllReplicatorReply, error) { +func (p *Peer) GetAllReplicators(ctx context.Context) ([]client.Replicator, error) { log.Debug(ctx, "Received GetAllReplicators request") - reps, err := p.db.GetAllReplicators(ctx) - if err != nil { - return nil, err - } - - pbReps := []*pb.GetAllReplicatorReply_Replicators{} - for _, rep := range reps { - pbReps = append(pbReps, &pb.GetAllReplicatorReply_Replicators{ - Info: &pb.GetAllReplicatorReply_Replicators_Info{ - Id: []byte(rep.Info.ID), - Addrs: rep.Info.Addrs[0].Bytes(), - }, - Schemas: rep.Schemas, - }) - } - - return &pb.GetAllReplicatorReply{ - Replicators: pbReps, - }, nil + return p.db.GetAllReplicators(ctx) } func (p *Peer) loadReplicators(ctx context.Context) error { @@ -850,50 +795,48 @@ func (p *Peer) rollbackRemovePubSubTopics(topics []string, cause error) error { return cause } -// AddP2PCollections adds the given collectionIDs to the pubsup topics. +// AddP2PCollection adds the given collectionID to the pubsup topics. // -// It will error if any of the given collectionIDs are invalid, in such a case some of the +// It will error if the given collectionID is invalid, in such a case some of the // changes to the server may still be applied. // // WARNING: Calling this on collections with a large number of documents may take a long time to process. func (p *Peer) AddP2PCollections( ctx context.Context, - req *pb.AddP2PCollectionsRequest, -) (*pb.AddP2PCollectionsReply, error) { + collectionIDs []string, +) error { log.Debug(ctx, "Received AddP2PCollections request") txn, err := p.db.NewTxn(p.ctx, false) if err != nil { - return nil, err + return err } defer txn.Discard(p.ctx) store := p.db.WithTxn(txn) // first let's make sure the collections actually exists storeCollections := []client.Collection{} - for _, col := range req.Collections { + for _, col := range collectionIDs { storeCol, err := store.GetCollectionBySchemaID(p.ctx, col) if err != nil { - return nil, err + return err } storeCollections = append(storeCollections, storeCol) } // Ensure we can add all the collections to the store on the transaction // before adding to topics. - for _, col := range req.Collections { - err := store.AddP2PCollection(p.ctx, col) - if err != nil { - return nil, err - } + err = store.AddP2PCollections(p.ctx, collectionIDs) + if err != nil { + return err } // Add pubsub topics and remove them if we get an error. addedTopics := []string{} - for _, col := range req.Collections { + for _, col := range collectionIDs { err = p.server.addPubSubTopic(col, true) if err != nil { - return nil, p.rollbackAddPubSubTopics(addedTopics, err) + return p.rollbackAddPubSubTopics(addedTopics, err) } addedTopics = append(addedTopics, col) } @@ -904,12 +847,12 @@ func (p *Peer) AddP2PCollections( for _, col := range storeCollections { keyChan, err := col.GetAllDocKeys(p.ctx) if err != nil { - return nil, err + return err } for key := range keyChan { err := p.server.removePubSubTopic(key.Key.String()) if err != nil { - return nil, p.rollbackRemovePubSubTopics(removedTopics, err) + return p.rollbackRemovePubSubTopics(removedTopics, err) } removedTopics = append(removedTopics, key.Key.String()) } @@ -917,56 +860,54 @@ func (p *Peer) AddP2PCollections( if err = txn.Commit(p.ctx); err != nil { err = p.rollbackRemovePubSubTopics(removedTopics, err) - return nil, p.rollbackAddPubSubTopics(addedTopics, err) + return p.rollbackAddPubSubTopics(addedTopics, err) } - return &pb.AddP2PCollectionsReply{}, nil + return nil } -// RemoveP2PCollections removes the given collectionIDs from the pubsup topics. +// RemoveP2PCollection removes the given collectionID from the pubsup topics. // -// It will error if any of the given collectionIDs are invalid, in such a case some of the +// It will error if the given collectionID is invalid, in such a case some of the // changes to the server may still be applied. // // WARNING: Calling this on collections with a large number of documents may take a long time to process. func (p *Peer) RemoveP2PCollections( ctx context.Context, - req *pb.RemoveP2PCollectionsRequest, -) (*pb.RemoveP2PCollectionsReply, error) { + collectionIDs []string, +) error { log.Debug(ctx, "Received RemoveP2PCollections request") txn, err := p.db.NewTxn(p.ctx, false) if err != nil { - return nil, err + return err } defer txn.Discard(p.ctx) store := p.db.WithTxn(txn) // first let's make sure the collections actually exists storeCollections := []client.Collection{} - for _, col := range req.Collections { + for _, col := range collectionIDs { storeCol, err := store.GetCollectionBySchemaID(p.ctx, col) if err != nil { - return nil, err + return err } storeCollections = append(storeCollections, storeCol) } // Ensure we can remove all the collections to the store on the transaction // before adding to topics. - for _, col := range req.Collections { - err := store.RemoveP2PCollection(p.ctx, col) - if err != nil { - return nil, err - } + err = store.RemoveP2PCollections(p.ctx, collectionIDs) + if err != nil { + return err } // Remove pubsub topics and add them back if we get an error. removedTopics := []string{} - for _, col := range req.Collections { + for _, col := range collectionIDs { err = p.server.removePubSubTopic(col) if err != nil { - return nil, p.rollbackRemovePubSubTopics(removedTopics, err) + return p.rollbackRemovePubSubTopics(removedTopics, err) } removedTopics = append(removedTopics, col) } @@ -977,12 +918,12 @@ func (p *Peer) RemoveP2PCollections( for _, col := range storeCollections { keyChan, err := col.GetAllDocKeys(p.ctx) if err != nil { - return nil, err + return err } for key := range keyChan { err := p.server.addPubSubTopic(key.Key.String(), true) if err != nil { - return nil, p.rollbackAddPubSubTopics(addedTopics, err) + return p.rollbackAddPubSubTopics(addedTopics, err) } addedTopics = append(addedTopics, key.Key.String()) } @@ -990,17 +931,14 @@ func (p *Peer) RemoveP2PCollections( if err = txn.Commit(p.ctx); err != nil { err = p.rollbackAddPubSubTopics(addedTopics, err) - return nil, p.rollbackRemovePubSubTopics(removedTopics, err) + return p.rollbackRemovePubSubTopics(removedTopics, err) } - return &pb.RemoveP2PCollectionsReply{}, nil + return nil } // GetAllP2PCollections gets all the collectionIDs from the pubsup topics -func (p *Peer) GetAllP2PCollections( - ctx context.Context, - req *pb.GetAllP2PCollectionsRequest, -) (*pb.GetAllP2PCollectionsReply, error) { +func (p *Peer) GetAllP2PCollections(ctx context.Context) ([]string, error) { log.Debug(ctx, "Received GetAllP2PCollections request") txn, err := p.db.NewTxn(p.ctx, false) @@ -1009,26 +947,11 @@ func (p *Peer) GetAllP2PCollections( } store := p.db.WithTxn(txn) - collections, err := p.db.GetAllP2PCollections(p.ctx) + collections, err := store.GetAllP2PCollections(p.ctx) if err != nil { txn.Discard(p.ctx) return nil, err } - pbCols := []*pb.GetAllP2PCollectionsReply_Collection{} - for _, colID := range collections { - col, err := store.GetCollectionBySchemaID(p.ctx, colID) - if err != nil { - txn.Discard(p.ctx) - return nil, err - } - pbCols = append(pbCols, &pb.GetAllP2PCollectionsReply_Collection{ - Id: colID, - Name: col.Name(), - }) - } - - return &pb.GetAllP2PCollectionsReply{ - Collections: pbCols, - }, txn.Commit(p.ctx) + return collections, txn.Commit(p.ctx) } diff --git a/net/peer_test.go b/net/peer_test.go index dc6fbb4793..15a4a2e55a 100644 --- a/net/peer_test.go +++ b/net/peer_test.go @@ -11,7 +11,6 @@ package net import ( - "bytes" "context" "testing" "time" @@ -22,9 +21,7 @@ import ( libp2p "github.com/libp2p/go-libp2p" pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/libp2p/go-libp2p/core/peer" - ma "github.com/multiformats/go-multiaddr" mh "github.com/multiformats/go-multihash" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" rpc "github.com/textileio/go-libp2p-pubsub-rpc" @@ -35,8 +32,6 @@ import ( "github.com/sourcenetwork/defradb/db" "github.com/sourcenetwork/defradb/errors" "github.com/sourcenetwork/defradb/events" - "github.com/sourcenetwork/defradb/logging" - pb "github.com/sourcenetwork/defradb/net/pb" netutils "github.com/sourcenetwork/defradb/net/utils" ) @@ -126,8 +121,6 @@ func newTestNode(ctx context.Context, t *testing.T) (client.DB, *Node) { cfg := config.DefaultConfig() cfg.Net.P2PAddress = randomMultiaddr - cfg.Net.RPCAddress = "0.0.0.0:0" - cfg.Net.TCPAddress = randomMultiaddr n, err := NewNode( ctx, @@ -148,7 +141,7 @@ func TestNewPeer_NoError(t *testing.T) { h, err := libp2p.New() require.NoError(t, err) - _, err = NewPeer(ctx, db, h, nil, nil, nil, nil, nil) + _, err = NewPeer(ctx, db, h, nil, nil, nil, nil) require.NoError(t, err) } @@ -158,7 +151,7 @@ func TestNewPeer_NoDB_NilDBError(t *testing.T) { h, err := libp2p.New() require.NoError(t, err) - _, err = NewPeer(ctx, nil, h, nil, nil, nil, nil, nil) + _, err = NewPeer(ctx, nil, h, nil, nil, nil, nil) require.ErrorIs(t, err, ErrNilDB) } @@ -197,7 +190,7 @@ func TestNewPeer_WithExistingTopic_TopicAlreadyExistsError(t *testing.T) { _, err = rpc.NewTopic(ctx, ps, h.ID(), doc.Key().String(), true) require.NoError(t, err) - _, err = NewPeer(ctx, db, h, nil, ps, nil, nil, nil) + _, err = NewPeer(ctx, db, h, nil, ps, nil, nil) require.ErrorContains(t, err, "topic already exists") } @@ -238,7 +231,7 @@ func TestStart_WithKnownPeer_NoError(t *testing.T) { if err != nil { t.Fatal(err) } - n2.Boostrap(addrs) + n2.Bootstrap(addrs) err = n2.Start() require.NoError(t, err) @@ -274,13 +267,7 @@ func TestStart_WithOfflineKnownPeer_NoError(t *testing.T) { if err != nil { t.Fatal(err) } - n2.Boostrap(addrs) - - b := &bytes.Buffer{} - - log.ApplyConfig(logging.Config{ - Pipe: b, - }) + n2.Bootstrap(addrs) err = n1.Close() require.NoError(t, err) @@ -291,19 +278,6 @@ func TestStart_WithOfflineKnownPeer_NoError(t *testing.T) { err = n2.Start() require.NoError(t, err) - logLines, err := parseLines(b) - if err != nil { - t.Fatal(err) - } - - if len(logLines) != 1 { - t.Fatalf("expecting exactly 1 log line but got %d lines", len(logLines)) - } - assert.Equal(t, "Failure while reconnecting to a known peer", logLines[0]["msg"]) - - // reset logger - log = logging.MustNewLogger("defra.net") - db1.Close(ctx) db2.Close(ctx) } @@ -407,20 +381,17 @@ func TestSetReplicator_NoError(t *testing.T) { }`) require.NoError(t, err) - addr, err := ma.NewMultiaddr("/ip4/0.0.0.0/tcp/0/p2p/QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N") + info, err := peer.AddrInfoFromString("/ip4/0.0.0.0/tcp/0/p2p/QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N") require.NoError(t, err) - _, err = n.Peer.SetReplicator( - ctx, - &pb.SetReplicatorRequest{ - Addr: addr.Bytes(), - Collections: []string{"User"}, - }, - ) + err = n.Peer.SetReplicator(ctx, client.Replicator{ + Info: *info, + Schemas: []string{"User"}, + }) require.NoError(t, err) } -func TestSetReplicator_WithInvalidAddress_InvalidArgumentError(t *testing.T) { +func TestSetReplicator_WithInvalidAddress_EmptyPeerIDError(t *testing.T) { ctx := context.Background() db, n := newTestNode(ctx, t) @@ -430,14 +401,11 @@ func TestSetReplicator_WithInvalidAddress_InvalidArgumentError(t *testing.T) { }`) require.NoError(t, err) - _, err = n.Peer.SetReplicator( - ctx, - &pb.SetReplicatorRequest{ - Addr: []byte("/some/invalid/address"), - Collections: []string{"User"}, - }, - ) - require.ErrorContains(t, err, "InvalidArgument") + err = n.Peer.SetReplicator(ctx, client.Replicator{ + Info: peer.AddrInfo{}, + Schemas: []string{"User"}, + }) + require.ErrorContains(t, err, "empty peer ID") } func TestSetReplicator_WithDBClosed_DatastoreClosedError(t *testing.T) { @@ -446,16 +414,13 @@ func TestSetReplicator_WithDBClosed_DatastoreClosedError(t *testing.T) { db.Close(ctx) - addr, err := ma.NewMultiaddr("/ip4/0.0.0.0/tcp/0/p2p/QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N") + info, err := peer.AddrInfoFromString("/ip4/0.0.0.0/tcp/0/p2p/QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N") require.NoError(t, err) - _, err = n.Peer.SetReplicator( - ctx, - &pb.SetReplicatorRequest{ - Addr: addr.Bytes(), - Collections: []string{"User"}, - }, - ) + err = n.Peer.SetReplicator(ctx, client.Replicator{ + Info: *info, + Schemas: []string{"User"}, + }) require.ErrorContains(t, err, "datastore closed") } @@ -463,16 +428,13 @@ func TestSetReplicator_WithUndefinedCollection_KeyNotFoundError(t *testing.T) { ctx := context.Background() _, n := newTestNode(ctx, t) - addr, err := ma.NewMultiaddr("/ip4/0.0.0.0/tcp/0/p2p/QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N") + info, err := peer.AddrInfoFromString("/ip4/0.0.0.0/tcp/0/p2p/QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N") require.NoError(t, err) - _, err = n.Peer.SetReplicator( - ctx, - &pb.SetReplicatorRequest{ - Addr: addr.Bytes(), - Collections: []string{"User"}, - }, - ) + err = n.Peer.SetReplicator(ctx, client.Replicator{ + Info: *info, + Schemas: []string{"User"}, + }) require.ErrorContains(t, err, "failed to get collection for replicator: datastore: key not found") } @@ -486,15 +448,12 @@ func TestSetReplicator_ForAllCollections_NoError(t *testing.T) { }`) require.NoError(t, err) - addr, err := ma.NewMultiaddr("/ip4/0.0.0.0/tcp/0/p2p/QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N") + info, err := peer.AddrInfoFromString("/ip4/0.0.0.0/tcp/0/p2p/QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N") require.NoError(t, err) - _, err = n.Peer.SetReplicator( - ctx, - &pb.SetReplicatorRequest{ - Addr: addr.Bytes(), - }, - ) + err = n.Peer.SetReplicator(ctx, client.Replicator{ + Info: *info, + }) require.NoError(t, err) } @@ -522,26 +481,7 @@ func TestPushToReplicator_SingleDocumentNoPeer_FailedToReplicateLogError(t *test txn, err := db.NewTxn(ctx, true) require.NoError(t, err) - b := &bytes.Buffer{} - - log.ApplyConfig(logging.Config{ - Pipe: b, - }) - n.pushToReplicator(ctx, txn, col, keysCh, n.PeerID()) - - logLines, err := parseLines(b) - if err != nil { - t.Fatal(err) - } - - if len(logLines) != 1 { - t.Fatalf("expecting exactly 1 log line but got %d lines", len(logLines)) - } - assert.Equal(t, "Failed to replicate log", logLines[0]["msg"]) - - // reset logger - log = logging.MustNewLogger("defra.net") } func TestDeleteReplicator_WithDBClosed_DataStoreClosedError(t *testing.T) { @@ -550,13 +490,10 @@ func TestDeleteReplicator_WithDBClosed_DataStoreClosedError(t *testing.T) { db.Close(ctx) - _, err := n.Peer.DeleteReplicator( - ctx, - &pb.DeleteReplicatorRequest{ - PeerID: []byte(n.PeerID()), - Collections: []string{"User"}, - }, - ) + err := n.Peer.DeleteReplicator(ctx, client.Replicator{ + Info: n.PeerInfo(), + Schemas: []string{"User"}, + }) require.ErrorContains(t, err, "datastore closed") } @@ -564,13 +501,10 @@ func TestDeleteReplicator_WithTargetSelf_SelfTargetForReplicatorError(t *testing ctx := context.Background() _, n := newTestNode(ctx, t) - _, err := n.Peer.DeleteReplicator( - ctx, - &pb.DeleteReplicatorRequest{ - PeerID: []byte(n.PeerID()), - Collections: []string{"User"}, - }, - ) + err := n.Peer.DeleteReplicator(ctx, client.Replicator{ + Info: n.PeerInfo(), + Schemas: []string{"User"}, + }) require.ErrorIs(t, err, ErrSelfTargetForReplicator) } @@ -580,13 +514,10 @@ func TestDeleteReplicator_WithInvalidCollection_KeyNotFoundError(t *testing.T) { _, n2 := newTestNode(ctx, t) - _, err := n.Peer.DeleteReplicator( - ctx, - &pb.DeleteReplicatorRequest{ - PeerID: []byte(n2.PeerID()), - Collections: []string{"User"}, - }, - ) + err := n.Peer.DeleteReplicator(ctx, client.Replicator{ + Info: n2.PeerInfo(), + Schemas: []string{"User"}, + }) require.ErrorContains(t, err, "failed to get collection for replicator: datastore: key not found") } @@ -602,23 +533,14 @@ func TestDeleteReplicator_WithCollectionAndPreviouslySetReplicator_NoError(t *te _, n2 := newTestNode(ctx, t) - addr, err := ma.NewMultiaddr(n2.host.Addrs()[0].String() + "/p2p/" + n2.PeerID().String()) - require.NoError(t, err) - - _, err = n.Peer.SetReplicator( - ctx, - &pb.SetReplicatorRequest{ - Addr: addr.Bytes(), - }, - ) + err = n.Peer.SetReplicator(ctx, client.Replicator{ + Info: n2.PeerInfo(), + }) require.NoError(t, err) - _, err = n.Peer.DeleteReplicator( - ctx, - &pb.DeleteReplicatorRequest{ - PeerID: []byte(n2.PeerID()), - }, - ) + err = n.Peer.DeleteReplicator(ctx, client.Replicator{ + Info: n2.PeerInfo(), + }) require.NoError(t, err) } @@ -628,12 +550,9 @@ func TestDeleteReplicator_WithNoCollection_NoError(t *testing.T) { _, n2 := newTestNode(ctx, t) - _, err := n.Peer.DeleteReplicator( - ctx, - &pb.DeleteReplicatorRequest{ - PeerID: []byte(n2.PeerID()), - }, - ) + err := n.Peer.DeleteReplicator(ctx, client.Replicator{ + Info: n2.PeerInfo(), + }) require.NoError(t, err) } @@ -649,13 +568,10 @@ func TestDeleteReplicator_WithNotSetReplicator_KeyNotFoundError(t *testing.T) { _, n2 := newTestNode(ctx, t) - _, err = n.Peer.DeleteReplicator( - ctx, - &pb.DeleteReplicatorRequest{ - PeerID: []byte(n2.PeerID()), - Collections: []string{"User"}, - }, - ) + err = n.Peer.DeleteReplicator(ctx, client.Replicator{ + Info: n2.PeerInfo(), + Schemas: []string{"User"}, + }) require.ErrorContains(t, err, "datastore: key not found") } @@ -671,30 +587,16 @@ func TestGetAllReplicator_WithReplicator_NoError(t *testing.T) { _, n2 := newTestNode(ctx, t) - addr, err := ma.NewMultiaddr(n2.host.Addrs()[0].String() + "/p2p/" + n2.PeerID().String()) - require.NoError(t, err) - - _, err = n.Peer.SetReplicator( - ctx, - &pb.SetReplicatorRequest{ - Addr: addr.Bytes(), - }, - ) - require.NoError(t, err) - - reps, err := n.Peer.GetAllReplicators( - ctx, - &pb.GetAllReplicatorRequest{}, - ) - require.NoError(t, err) - - info, err := peer.AddrInfoFromP2pAddr(addr) + err = n.Peer.SetReplicator(ctx, client.Replicator{ + Info: n2.PeerInfo(), + }) require.NoError(t, err) - id, err := info.ID.MarshalBinary() + reps, err := n.Peer.GetAllReplicators(ctx) require.NoError(t, err) - require.Equal(t, id, reps.Replicators[0].Info.Id) + require.Len(t, reps, 1) + require.Equal(t, n2.PeerInfo().ID, reps[0].Info.ID) } func TestGetAllReplicator_WithDBClosed_DatastoreClosedError(t *testing.T) { @@ -703,10 +605,7 @@ func TestGetAllReplicator_WithDBClosed_DatastoreClosedError(t *testing.T) { db.Close(ctx) - _, err := n.Peer.GetAllReplicators( - ctx, - &pb.GetAllReplicatorRequest{}, - ) + _, err := n.Peer.GetAllReplicators(ctx) require.ErrorContains(t, err, "datastore closed") } @@ -732,15 +631,9 @@ func TestLoadReplicator_WithReplicator_NoError(t *testing.T) { _, n2 := newTestNode(ctx, t) - addr, err := ma.NewMultiaddr(n2.host.Addrs()[0].String() + "/p2p/" + n2.PeerID().String()) - require.NoError(t, err) - - _, err = n.Peer.SetReplicator( - ctx, - &pb.SetReplicatorRequest{ - Addr: addr.Bytes(), - }, - ) + err = n.Peer.SetReplicator(ctx, client.Replicator{ + Info: n2.PeerInfo(), + }) require.NoError(t, err) err = n.Peer.loadReplicators(ctx) @@ -759,15 +652,9 @@ func TestLoadReplicator_WithReplicatorAndEmptyReplicatorMap_NoError(t *testing.T _, n2 := newTestNode(ctx, t) - addr, err := ma.NewMultiaddr(n2.host.Addrs()[0].String() + "/p2p/" + n2.PeerID().String()) - require.NoError(t, err) - - _, err = n.Peer.SetReplicator( - ctx, - &pb.SetReplicatorRequest{ - Addr: addr.Bytes(), - }, - ) + err = n.Peer.SetReplicator(ctx, client.Replicator{ + Info: n2.PeerInfo(), + }) require.NoError(t, err) n.replicators = make(map[string]map[peer.ID]struct{}) @@ -780,12 +667,7 @@ func TestAddP2PCollections_WithInvalidCollectionID_NotFoundError(t *testing.T) { ctx := context.Background() _, n := newTestNode(ctx, t) - _, err := n.Peer.AddP2PCollections( - ctx, - &pb.AddP2PCollectionsRequest{ - Collections: []string{"invalid_collection"}, - }, - ) + err := n.Peer.AddP2PCollections(ctx, []string{"invalid_collection"}) require.Error(t, err, ds.ErrNotFound) } @@ -802,12 +684,7 @@ func TestAddP2PCollections_NoError(t *testing.T) { col, err := db.GetCollectionByName(ctx, "User") require.NoError(t, err) - _, err = n.Peer.AddP2PCollections( - ctx, - &pb.AddP2PCollectionsRequest{ - Collections: []string{col.SchemaID()}, - }, - ) + err = n.Peer.AddP2PCollections(ctx, []string{col.SchemaID()}) require.NoError(t, err) } @@ -815,12 +692,7 @@ func TestRemoveP2PCollectionsWithInvalidCollectionID(t *testing.T) { ctx := context.Background() _, n := newTestNode(ctx, t) - _, err := n.Peer.RemoveP2PCollections( - ctx, - &pb.RemoveP2PCollectionsRequest{ - Collections: []string{"invalid_collection"}, - }, - ) + err := n.Peer.RemoveP2PCollections(ctx, []string{"invalid_collection"}) require.Error(t, err, ds.ErrNotFound) } @@ -837,12 +709,7 @@ func TestRemoveP2PCollections(t *testing.T) { col, err := db.GetCollectionByName(ctx, "User") require.NoError(t, err) - _, err = n.Peer.RemoveP2PCollections( - ctx, - &pb.RemoveP2PCollectionsRequest{ - Collections: []string{col.SchemaID()}, - }, - ) + err = n.Peer.RemoveP2PCollections(ctx, []string{col.SchemaID()}) require.NoError(t, err) } @@ -850,12 +717,9 @@ func TestGetAllP2PCollectionsWithNoCollections(t *testing.T) { ctx := context.Background() _, n := newTestNode(ctx, t) - cols, err := n.Peer.GetAllP2PCollections( - ctx, - &pb.GetAllP2PCollectionsRequest{}, - ) + cols, err := n.Peer.GetAllP2PCollections(ctx) require.NoError(t, err) - require.Len(t, cols.Collections, 0) + require.Len(t, cols, 0) } func TestGetAllP2PCollections(t *testing.T) { @@ -871,25 +735,12 @@ func TestGetAllP2PCollections(t *testing.T) { col, err := db.GetCollectionByName(ctx, "User") require.NoError(t, err) - _, err = n.Peer.AddP2PCollections( - ctx, - &pb.AddP2PCollectionsRequest{ - Collections: []string{col.SchemaID()}, - }, - ) + err = n.Peer.AddP2PCollections(ctx, []string{col.SchemaID()}) require.NoError(t, err) - cols, err := n.Peer.GetAllP2PCollections( - ctx, - &pb.GetAllP2PCollectionsRequest{}, - ) + cols, err := n.Peer.GetAllP2PCollections(ctx) require.NoError(t, err) - require.Equal(t, &pb.GetAllP2PCollectionsReply{ - Collections: []*pb.GetAllP2PCollectionsReply_Collection{{ - Id: col.SchemaID(), - Name: col.Name(), - }}, - }, cols) + require.ElementsMatch(t, []string{col.SchemaID()}, cols) } func TestHandleDocCreateLog_NoError(t *testing.T) { @@ -1121,15 +972,9 @@ func TestPushLogToReplicator_WithReplicator_FailedPushingLogError(t *testing.T) _, n2 := newTestNode(ctx, t) - addr, err := ma.NewMultiaddr(n2.host.Addrs()[0].String() + "/p2p/" + n2.PeerID().String()) - require.NoError(t, err) - - _, err = n.Peer.SetReplicator( - ctx, - &pb.SetReplicatorRequest{ - Addr: addr.Bytes(), - }, - ) + err = n.Peer.SetReplicator(ctx, client.Replicator{ + Info: n2.PeerInfo(), + }) require.NoError(t, err) col, err := db.GetCollectionByName(ctx, "User") diff --git a/net/server_test.go b/net/server_test.go index 993c12d875..937b4c34b4 100644 --- a/net/server_test.go +++ b/net/server_test.go @@ -11,17 +11,12 @@ package net import ( - "bufio" - "bytes" "context" - "encoding/json" - "io" "testing" "time" "github.com/libp2p/go-libp2p/core/event" "github.com/libp2p/go-libp2p/core/host" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" rpc "github.com/textileio/go-libp2p-pubsub-rpc" grpcpeer "google.golang.org/grpc/peer" @@ -29,7 +24,6 @@ import ( "github.com/sourcenetwork/defradb/client" "github.com/sourcenetwork/defradb/datastore/memory" "github.com/sourcenetwork/defradb/errors" - "github.com/sourcenetwork/defradb/logging" net_pb "github.com/sourcenetwork/defradb/net/pb" ) @@ -79,7 +73,7 @@ func TestNewServerWithCollectionSubscribed(t *testing.T) { col, err := db.GetCollectionByName(ctx, "User") require.NoError(t, err) - err = n.AddP2PCollection(ctx, col.SchemaID()) + err = n.AddP2PCollections(ctx, []string{col.SchemaID()}) require.NoError(t, err) _, err = newServer(n.Peer, db) @@ -190,46 +184,8 @@ func TestNewServerWithEmitterError(t *testing.T) { n.Peer.host = &mockHost{n.Peer.host} - b := &bytes.Buffer{} - - log.ApplyConfig(logging.Config{ - Pipe: b, - }) - _, err = newServer(n.Peer, db) require.NoError(t, err) - - logLines, err := parseLines(b) - if err != nil { - t.Fatal(err) - } - - if len(logLines) != 2 { - t.Fatalf("expecting exactly 2 log line but got %d lines", len(logLines)) - } - assert.Equal(t, "could not create event emitter", logLines[0]["msg"]) - assert.Equal(t, "could not create event emitter", logLines[1]["msg"]) - - // reset logger - log = logging.MustNewLogger("defra.net") -} - -func parseLines(r io.Reader) ([]map[string]any, error) { - fileScanner := bufio.NewScanner(r) - - fileScanner.Split(bufio.ScanLines) - - logLines := []map[string]any{} - for fileScanner.Scan() { - loggedLine := make(map[string]any) - err := json.Unmarshal(fileScanner.Bytes(), &loggedLine) - if err != nil { - return nil, err - } - logLines = append(logLines, loggedLine) - } - - return logLines, nil } func TestGetDocGraph(t *testing.T) { diff --git a/tests/clients/cli/wrapper.go b/tests/clients/cli/wrapper.go index f167b882d8..261561ca8d 100644 --- a/tests/clients/cli/wrapper.go +++ b/tests/clients/cli/wrapper.go @@ -94,17 +94,17 @@ func (w *Wrapper) GetAllReplicators(ctx context.Context) ([]client.Replicator, e return reps, nil } -func (w *Wrapper) AddP2PCollection(ctx context.Context, collectionID string) error { +func (w *Wrapper) AddP2PCollections(ctx context.Context, collectionIDs []string) error { args := []string{"client", "p2p", "collection", "add"} - args = append(args, collectionID) + args = append(args, strings.Join(collectionIDs, ",")) _, err := w.cmd.execute(ctx, args) return err } -func (w *Wrapper) RemoveP2PCollection(ctx context.Context, collectionID string) error { +func (w *Wrapper) RemoveP2PCollections(ctx context.Context, collectionIDs []string) error { args := []string{"client", "p2p", "collection", "remove"} - args = append(args, collectionID) + args = append(args, strings.Join(collectionIDs, ",")) _, err := w.cmd.execute(ctx, args) return err diff --git a/tests/clients/http/wrapper.go b/tests/clients/http/wrapper.go index 10b34129d8..b5ef61c037 100644 --- a/tests/clients/http/wrapper.go +++ b/tests/clients/http/wrapper.go @@ -62,12 +62,12 @@ func (w *Wrapper) GetAllReplicators(ctx context.Context) ([]client.Replicator, e return w.client.GetAllReplicators(ctx) } -func (w *Wrapper) AddP2PCollection(ctx context.Context, collectionID string) error { - return w.client.AddP2PCollection(ctx, collectionID) +func (w *Wrapper) AddP2PCollections(ctx context.Context, collectionIDs []string) error { + return w.client.AddP2PCollections(ctx, collectionIDs) } -func (w *Wrapper) RemoveP2PCollection(ctx context.Context, collectionID string) error { - return w.client.RemoveP2PCollection(ctx, collectionID) +func (w *Wrapper) RemoveP2PCollections(ctx context.Context, collectionIDs []string) error { + return w.client.RemoveP2PCollections(ctx, collectionIDs) } func (w *Wrapper) GetAllP2PCollections(ctx context.Context) ([]string, error) { diff --git a/tests/integration/net/order/utils.go b/tests/integration/net/order/utils.go index 83d01743b9..5470d8aee7 100644 --- a/tests/integration/net/order/utils.go +++ b/tests/integration/net/order/utils.go @@ -16,7 +16,6 @@ import ( "strings" "testing" - ma "github.com/multiformats/go-multiaddr" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -26,7 +25,6 @@ import ( "github.com/sourcenetwork/defradb/errors" "github.com/sourcenetwork/defradb/logging" "github.com/sourcenetwork/defradb/net" - netpb "github.com/sourcenetwork/defradb/net/pb" netutils "github.com/sourcenetwork/defradb/net/utils" testutils "github.com/sourcenetwork/defradb/tests/integration" ) @@ -112,7 +110,7 @@ func setupDefraNode(t *testing.T, cfg *config.Config, seeds []string) (*net.Node return nil, nil, errors.Wrap(fmt.Sprintf("failed to parse bootstrap peers %v", cfg.Net.Peers), err) } log.Info(ctx, "Bootstrapping with peers", logging.NewKV("Addresses", addrs)) - n.Boostrap(addrs) + n.Bootstrap(addrs) } if err := n.Start(); err != nil { @@ -301,16 +299,9 @@ func executeTestCase(t *testing.T, test P2PTestCase) { for i, n := range nodes { if reps, ok := test.NodeReplicators[i]; ok { for _, r := range reps { - addr, err := ma.NewMultiaddr( - fmt.Sprintf("%s/p2p/%s", test.NodeConfig[r].Net.P2PAddress, nodes[r].PeerID()), - ) - require.NoError(t, err) - _, err = n.Peer.SetReplicator( - ctx, - &netpb.SetReplicatorRequest{ - Addr: addr.Bytes(), - }, - ) + err := n.Peer.SetReplicator(ctx, client.Replicator{ + Info: nodes[r].PeerInfo(), + }) require.NoError(t, err) } } @@ -356,12 +347,8 @@ func executeTestCase(t *testing.T, test P2PTestCase) { } } -const randomMultiaddr = "/ip4/0.0.0.0/tcp/0" - func randomNetworkingConfig() *config.Config { cfg := config.DefaultConfig() - cfg.Net.P2PAddress = randomMultiaddr - cfg.Net.RPCAddress = "0.0.0.0:0" - cfg.Net.TCPAddress = randomMultiaddr + cfg.Net.P2PAddress = "/ip4/0.0.0.0/tcp/0" return cfg } diff --git a/tests/integration/net/state/simple/replicator/with_create_update_test.go b/tests/integration/net/state/simple/replicator/with_create_update_test.go index dd3612055d..c62d63b17c 100644 --- a/tests/integration/net/state/simple/replicator/with_create_update_test.go +++ b/tests/integration/net/state/simple/replicator/with_create_update_test.go @@ -141,10 +141,6 @@ func TestP2POneToOneReplicatorDoesNotUpdateDocExistingOnlyOnTarget(t *testing.T) } `, }, - testUtils.ConfigureReplicator{ - SourceNodeID: 0, - TargetNodeID: 1, - }, testUtils.CreateDoc{ // This document is created in all nodes Doc: `{ @@ -152,6 +148,13 @@ func TestP2POneToOneReplicatorDoesNotUpdateDocExistingOnlyOnTarget(t *testing.T) "Age": 21 }`, }, + testUtils.ConfigureReplicator{ + // Replication must happen after creating documents + // on both nodes, or a race condition can occur + // on the second node when creating the document + SourceNodeID: 0, + TargetNodeID: 1, + }, testUtils.CreateDoc{ // This document is created in the second node (target) only NodeID: immutable.Some(1), diff --git a/tests/integration/p2p.go b/tests/integration/p2p.go index 311a088c86..e04e16bb0f 100644 --- a/tests/integration/p2p.go +++ b/tests/integration/p2p.go @@ -14,13 +14,12 @@ import ( "fmt" "time" + "github.com/sourcenetwork/defradb/client" "github.com/sourcenetwork/defradb/config" "github.com/sourcenetwork/defradb/logging" "github.com/sourcenetwork/defradb/net" - pb "github.com/sourcenetwork/defradb/net/pb" netutils "github.com/sourcenetwork/defradb/net/utils" - ma "github.com/multiformats/go-multiaddr" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -59,9 +58,12 @@ type ConfigureReplicator struct { TargetNodeID int } -// NonExistentCollectionID can be used to represent a non-existent collection ID, it will be substituted -// for a non-existent collection ID when used in actions that support this. -const NonExistentCollectionID int = -1 +const ( + // NonExistentCollectionID can be used to represent a non-existent collection ID, it will be substituted + // for a non-existent collection ID when used in actions that support this. + NonExistentCollectionID int = -1 + NonExistentCollectionSchemaID = "NonExistentCollectionID" +) // SubscribeToCollection sets up a subscription on the given node to the given collection. // @@ -142,7 +144,7 @@ func connectPeers( s.t.Fatal(fmt.Sprintf("failed to parse bootstrap peers %v", targetAddress), err) } log.Info(s.ctx, "Bootstrapping with peers", logging.NewKV("Addresses", addrs)) - sourceNode.Boostrap(addrs) + sourceNode.Bootstrap(addrs) // Bootstrap triggers a bunch of async stuff for which we have no good way of waiting on. It must be // allowed to complete before documentation begins or it will not even try and sync it. So for now, we @@ -291,17 +293,10 @@ func configureReplicator( time.Sleep(100 * time.Millisecond) sourceNode := s.nodes[cfg.SourceNodeID] targetNode := s.nodes[cfg.TargetNodeID] - targetAddress := s.nodeAddresses[cfg.TargetNodeID] - addr, err := ma.NewMultiaddr(targetAddress) - require.NoError(s.t, err) - - _, err = sourceNode.Peer.SetReplicator( - s.ctx, - &pb.SetReplicatorRequest{ - Addr: addr.Bytes(), - }, - ) + err := sourceNode.Peer.SetReplicator(s.ctx, client.Replicator{ + Info: targetNode.PeerInfo(), + }) require.NoError(s.t, err) setupReplicatorWaitSync(s, 0, cfg, sourceNode, targetNode) } @@ -394,7 +389,7 @@ func subscribeToCollection( schemaIDs := []string{} for _, collectionIndex := range action.CollectionIDs { if collectionIndex == NonExistentCollectionID { - schemaIDs = append(schemaIDs, "NonExistentCollectionID") + schemaIDs = append(schemaIDs, NonExistentCollectionSchemaID) continue } @@ -402,12 +397,7 @@ func subscribeToCollection( schemaIDs = append(schemaIDs, col.SchemaID()) } - _, err := n.Peer.AddP2PCollections( - s.ctx, - &pb.AddP2PCollectionsRequest{ - Collections: schemaIDs, - }, - ) + err := n.AddP2PCollections(s.ctx, schemaIDs) expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError) assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised) @@ -429,7 +419,7 @@ func unsubscribeToCollection( schemaIDs := []string{} for _, collectionIndex := range action.CollectionIDs { if collectionIndex == NonExistentCollectionID { - schemaIDs = append(schemaIDs, "NonExistentCollectionID") + schemaIDs = append(schemaIDs, NonExistentCollectionSchemaID) continue } @@ -437,12 +427,7 @@ func unsubscribeToCollection( schemaIDs = append(schemaIDs, col.SchemaID()) } - _, err := n.Peer.RemoveP2PCollections( - s.ctx, - &pb.RemoveP2PCollectionsRequest{ - Collections: schemaIDs, - }, - ) + err := n.RemoveP2PCollections(s.ctx, schemaIDs) expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError) assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised) @@ -460,26 +445,17 @@ func getAllP2PCollections( s *state, action GetAllP2PCollections, ) { - expectedCollections := []*pb.GetAllP2PCollectionsReply_Collection{} + expectedCollections := []string{} for _, collectionIndex := range action.ExpectedCollectionIDs { col := s.collections[action.NodeID][collectionIndex] - expectedCollections = append( - expectedCollections, - &pb.GetAllP2PCollectionsReply_Collection{ - Id: col.SchemaID(), - Name: col.Name(), - }, - ) + expectedCollections = append(expectedCollections, col.SchemaID()) } n := s.nodes[action.NodeID] - cols, err := n.Peer.GetAllP2PCollections( - s.ctx, - &pb.GetAllP2PCollectionsRequest{}, - ) + cols, err := n.GetAllP2PCollections(s.ctx) require.NoError(s.t, err) - assert.Equal(s.t, expectedCollections, cols.Collections) + assert.Equal(s.t, expectedCollections, cols) } // waitForSync waits for all given wait channels to receive an item signaling completion. @@ -502,14 +478,10 @@ func waitForSync( } } -const randomMultiaddr = "/ip4/0.0.0.0/tcp/0" - func RandomNetworkingConfig() ConfigureNode { return func() config.Config { cfg := config.DefaultConfig() - cfg.Net.P2PAddress = randomMultiaddr - cfg.Net.RPCAddress = "0.0.0.0:0" - cfg.Net.TCPAddress = randomMultiaddr + cfg.Net.P2PAddress = "/ip4/0.0.0.0/tcp/0" return *cfg } } diff --git a/tests/integration/utils2.go b/tests/integration/utils2.go index 1108608ef8..3354c43561 100644 --- a/tests/integration/utils2.go +++ b/tests/integration/utils2.go @@ -1460,7 +1460,7 @@ func withRetry( nodeID int, action func() error, ) error { - for i := 0; i < nodes[nodeID].MaxTxnRetries(); i++ { + for i := 0; i < nodes[nodeID].DB.MaxTxnRetries(); i++ { err := action() if err != nil && errors.Is(err, badgerds.ErrTxnConflict) { time.Sleep(100 * time.Millisecond)