diff --git a/chain/chain.go b/chain/chain.go index a1eb0742f5..5f4275bb18 100644 --- a/chain/chain.go +++ b/chain/chain.go @@ -22,10 +22,11 @@ var ( // Chain is the blockchain chain configuration type Chain struct { - Name string `json:"name"` - Genesis *Genesis `json:"genesis"` - Params *Params `json:"params"` - Bootnodes []string `json:"bootnodes,omitempty"` + Name string `json:"name"` + Genesis *Genesis `json:"genesis"` + Params *Params `json:"params"` + Bootnodes []string `json:"bootnodes,omitempty"` + Staticnodes []string `json:"staticnodes,omitempty"` } // Genesis specifies the header fields, state of a genesis block diff --git a/command/common.go b/command/common.go index 81bf37d86a..9a7124b0cb 100644 --- a/command/common.go +++ b/command/common.go @@ -6,6 +6,7 @@ const ( IgnoreDiscoverCIDRFlag = "ignore-discover-cidr" - BootnodeFlag = "bootnode" - LogLevelFlag = "log-level" + BootnodeFlag = "bootnode" + StaticnodeFlag = "staticnode" + LogLevelFlag = "log-level" ) diff --git a/command/genesis/genesis.go b/command/genesis/genesis.go index 28ddecf711..a53802ce0a 100644 --- a/command/genesis/genesis.go +++ b/command/genesis/genesis.go @@ -65,6 +65,13 @@ func setFlags(cmd *cobra.Command) { "multiAddr URL for p2p discovery bootstrap. This flag can be used multiple times", ) + cmd.Flags().StringArrayVar( + ¶ms.staticnodes, + command.StaticnodeFlag, + []string{}, + "multiAddr URL for p2p static nodes. This flag can be used multiple times", + ) + // IBFT Validators { cmd.Flags().StringVar( diff --git a/command/genesis/params.go b/command/genesis/params.go index de9c56169d..5e6a2d45bb 100644 --- a/command/genesis/params.go +++ b/command/genesis/params.go @@ -54,6 +54,7 @@ type genesisParams struct { validatorPrefixPath string premine []string bootnodes []string + staticnodes []string ibftValidators []types.Address ibftValidatorsRaw []string @@ -251,7 +252,8 @@ func (p *genesisParams) initGenesisConfig() error { Forks: chain.AllForksEnabled, Engine: p.consensusEngineConfig, }, - Bootnodes: p.bootnodes, + Bootnodes: p.bootnodes, + Staticnodes: p.staticnodes, } // Predeploy ValidatorSet smart contract if needed diff --git a/command/peers/add/params.go b/command/peers/add/params.go index 469122e220..7b6155d08b 100644 --- a/command/peers/add/params.go +++ b/command/peers/add/params.go @@ -21,10 +21,12 @@ var ( ) const ( - addrFlag = "addr" + addrFlag = "addr" + staticFlag = "static" ) type addParams struct { + isStatic bool peerAddresses []string systemClient proto.SystemClient @@ -60,7 +62,7 @@ func (p *addParams) initSystemClient(grpcAddress string) error { func (p *addParams) addPeers() { for _, address := range p.peerAddresses { - if addErr := p.addPeer(address); addErr != nil { + if addErr := p.addPeer(address, p.isStatic); addErr != nil { p.addErrors = append(p.addErrors, addErr.Error()) continue @@ -70,11 +72,12 @@ func (p *addParams) addPeers() { } } -func (p *addParams) addPeer(peerAddress string) error { +func (p *addParams) addPeer(peerAddress string, static bool) error { if _, err := p.systemClient.PeersAdd( context.Background(), &proto.PeersAddRequest{ - Id: peerAddress, + Id: peerAddress, + Static: static, }, ); err != nil { return err diff --git a/command/peers/add/peers_add.go b/command/peers/add/peers_add.go index ecca710f71..224097dfbc 100644 --- a/command/peers/add/peers_add.go +++ b/command/peers/add/peers_add.go @@ -27,6 +27,13 @@ func setFlags(cmd *cobra.Command) { []string{}, "the libp2p addresses of the peers", ) + + cmd.Flags().BoolVar( + ¶ms.isStatic, + staticFlag, + false, + "add the peers as static peers", + ) } func runPreRun(_ *cobra.Command, _ []string) error { diff --git a/e2e/broadcast_test.go b/e2e/broadcast_test.go index 8c6db4d851..ae7f08f45a 100644 --- a/e2e/broadcast_test.go +++ b/e2e/broadcast_test.go @@ -20,16 +20,32 @@ func TestBroadcast(t *testing.T) { numNodes int // Number of nodes that connects to left node numConnectedNodes int + // static peers + static bool }{ { name: "tx should not reach to last node", numNodes: 10, numConnectedNodes: 5, + static: false, }, { name: "tx should reach to last node", numNodes: 10, numConnectedNodes: 10, + static: false, + }, + { + name: "tx should not reach to last node (static node)", + numNodes: 10, + numConnectedNodes: 5, + static: true, + }, + { + name: "tx should reach to last node (static node)", + numNodes: 10, + numConnectedNodes: 10, + static: true, }, } @@ -46,7 +62,7 @@ func TestBroadcast(t *testing.T) { for _, tt := range testCases { t.Run(tt.name, func(t *testing.T) { srvs := framework.NewTestServers(t, tt.numNodes, conf) - framework.MultiJoinSerial(t, srvs[0:tt.numConnectedNodes]) + framework.MultiJoinSerial(t, tt.static, srvs[0:tt.numConnectedNodes]) // Check the connections for i, srv := range srvs { diff --git a/e2e/discovery_test.go b/e2e/discovery_test.go index f8ff12aea6..d1a38fdc4d 100644 --- a/e2e/discovery_test.go +++ b/e2e/discovery_test.go @@ -18,16 +18,32 @@ func TestDiscovery(t *testing.T) { numNodes int // Number of nodes that connects to left node as default numInitConnectNodes int + // static peers + static bool }{ { name: "first 4 nodes should know each other", numNodes: 5, numInitConnectNodes: 4, + static: false, }, { name: "all should know each other", numNodes: 5, numInitConnectNodes: 5, + static: false, + }, + { + name: "first 4 nodes should know each other (static node)", + numNodes: 5, + numInitConnectNodes: 4, + static: true, + }, + { + name: "all should know each other (static node)", + numNodes: 5, + numInitConnectNodes: 5, + static: true, }, } @@ -53,7 +69,8 @@ func TestDiscovery(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() _, err := srv.Operator().PeersAdd(ctx, &proto.PeersAddRequest{ - Id: dest, + Id: dest, + Static: tt.static, }) if err != nil { t.Fatal(err) diff --git a/e2e/framework/config.go b/e2e/framework/config.go index 073815ec8c..3079ef8c1a 100644 --- a/e2e/framework/config.go +++ b/e2e/framework/config.go @@ -39,6 +39,7 @@ type TestServerConfig struct { DevStakers []types.Address Consensus ConsensusType // Consensus MechanismType Bootnodes []string // Bootnode Addresses + Staticnodes []string // Staticnode Addresses PriceLimit *uint64 // Minimum gas price limit to enforce for acceptance into the pool DevInterval int // Dev consensus update interval [s] EpochSize uint64 // The epoch size in blocks for the IBFT layer @@ -141,6 +142,11 @@ func (t *TestServerConfig) SetBootnodes(bootnodes []string) { t.Bootnodes = bootnodes } +// SetStaticnodes sets bootnodes +func (t *TestServerConfig) SetStaticnodes(staticnodes []string) { + t.Staticnodes = staticnodes +} + // SetPriceLimit sets the gas price limit func (t *TestServerConfig) SetPriceLimit(priceLimit *uint64) { t.PriceLimit = priceLimit diff --git a/e2e/framework/helper.go b/e2e/framework/helper.go index 78276c6334..c304d8fc6d 100644 --- a/e2e/framework/helper.go +++ b/e2e/framework/helper.go @@ -121,7 +121,7 @@ func EcrecoverFromBlockhash(hash types.Hash, signature []byte) (types.Address, e return crypto.PubKeyToAddress(pubKey), nil } -func MultiJoinSerial(t *testing.T, srvs []*TestServer) { +func MultiJoinSerial(t *testing.T, static bool, srvs []*TestServer) { t.Helper() dials := []*TestServer{} @@ -130,10 +130,10 @@ func MultiJoinSerial(t *testing.T, srvs []*TestServer) { srv, dst := srvs[i], srvs[i+1] dials = append(dials, srv, dst) } - MultiJoin(t, dials...) + MultiJoin(t, static, dials...) } -func MultiJoin(t *testing.T, srvs ...*TestServer) { +func MultiJoin(t *testing.T, static bool, srvs ...*TestServer) { t.Helper() if len(srvs)%2 != 0 { @@ -157,7 +157,8 @@ func MultiJoin(t *testing.T, srvs ...*TestServer) { dstAddr := strings.Split(dstStatus.P2PAddr, ",")[0] _, err = srcClient.PeersAdd(context.Background(), &proto.PeersAddRequest{ - Id: dstAddr, + Id: dstAddr, + Static: static, }) errCh <- err diff --git a/e2e/framework/ibft.go b/e2e/framework/ibft.go index a901e220d3..d7ed4c8711 100644 --- a/e2e/framework/ibft.go +++ b/e2e/framework/ibft.go @@ -20,6 +20,7 @@ func NewIBFTServersManager( t *testing.T, numNodes int, ibftDirPrefix string, + static bool, callback IBFTServerConfigCallback, ) *IBFTServersManager { t.Helper() @@ -41,6 +42,7 @@ func NewIBFTServersManager( }) bootnodes := make([]string, 0, numNodes) + staticnodes := make([]string, 0, numNodes) genesisValidators := make([]string, 0, numNodes) for i := 0; i < numNodes; i++ { @@ -60,11 +62,18 @@ func NewIBFTServersManager( srvs = append(srvs, srv) bootnodes = append(bootnodes, libp2pAddr) + + if static { + staticnodes = append(staticnodes, libp2pAddr) + } + genesisValidators = append(genesisValidators, res.Address) } srv := srvs[0] srv.Config.SetBootnodes(bootnodes) + // Set static nodes + srv.Config.SetStaticnodes(staticnodes) // Set genesis staking balance for genesis validators for i, v := range genesisValidators { addr := types.StringToAddress(v) diff --git a/e2e/framework/testserver.go b/e2e/framework/testserver.go index efa3a61fa2..f3bfa2d972 100644 --- a/e2e/framework/testserver.go +++ b/e2e/framework/testserver.go @@ -295,6 +295,10 @@ func (t *TestServer) GenerateGenesis() error { args = append(args, "--bootnode", bootnode) } + for _, staticnode := range t.Config.Staticnodes { + args = append(args, "--staticnode", staticnode) + } + // Make sure the correct mechanism is selected if t.Config.IsPos { args = append(args, "--pos") diff --git a/e2e/ibft_test.go b/e2e/ibft_test.go index bd7c27565c..7719467205 100644 --- a/e2e/ibft_test.go +++ b/e2e/ibft_test.go @@ -22,6 +22,7 @@ func TestIbft_Transfer(t *testing.T) { t, IBFTMinNodes, IBFTDirPrefix, + false, func(i int, config *framework.TestServerConfig) { config.Premine(senderAddr, framework.EthToWei(10)) config.SetSeal(true) @@ -58,16 +59,31 @@ func TestIbft_TransactionFeeRecipient(t *testing.T) { name string contractCall bool txAmount *big.Int + static bool }{ { name: "transfer transaction", contractCall: false, txAmount: framework.EthToWei(1), + static: false, }, { name: "contract function execution", contractCall: true, txAmount: big.NewInt(0), + static: false, + }, + { + name: "transfer transaction (static node)", + contractCall: false, + txAmount: framework.EthToWei(1), + static: true, + }, + { + name: "contract function execution (static node)", + contractCall: true, + txAmount: big.NewInt(0), + static: true, }, } @@ -80,9 +96,11 @@ func TestIbft_TransactionFeeRecipient(t *testing.T) { t, IBFTMinNodes, IBFTDirPrefix, + tc.static, func(i int, config *framework.TestServerConfig) { config.Premine(senderAddr, framework.EthToWei(10)) config.SetSeal(true) + config.SetBlockTime(1) }) ctx, cancel := context.WithTimeout(context.Background(), time.Minute) diff --git a/e2e/syncer_test.go b/e2e/syncer_test.go index f0f333bc7c..35253a2310 100644 --- a/e2e/syncer_test.go +++ b/e2e/syncer_test.go @@ -21,7 +21,9 @@ func TestClusterBlockSync(t *testing.T) { ibftManager := framework.NewIBFTServersManager( t, IBFTMinNodes+numNonValidators, - IBFTDirPrefix, func(i int, config *framework.TestServerConfig) { + IBFTDirPrefix, + false, + func(i int, config *framework.TestServerConfig) { if i >= IBFTMinNodes { // Other nodes should not be in the validator set dirPrefix := "dogechain-non-validator-" @@ -29,6 +31,7 @@ func TestClusterBlockSync(t *testing.T) { config.SetIBFTDir(fmt.Sprintf("%s%d", dirPrefix, i)) } config.SetSeal(i < IBFTMinNodes) + config.SetBlockTime(1) }) startContext, startCancelFn := context.WithTimeout(context.Background(), time.Minute) diff --git a/e2e/transaction_test.go b/e2e/transaction_test.go index 450c7f9ab9..2742ec7b2d 100644 --- a/e2e/transaction_test.go +++ b/e2e/transaction_test.go @@ -33,6 +33,7 @@ func TestSignedTransaction(t *testing.T) { t, IBFTMinNodes, IBFTDirPrefix, + false, func(i int, config *framework.TestServerConfig) { config.Premine(senderAddr, preminedAmount) config.SetSeal(true) @@ -511,10 +512,12 @@ func Test_TransactionIBFTLoop(t *testing.T) { t, IBFTMinNodes, IBFTDirPrefix, + false, func(i int, config *framework.TestServerConfig) { config.Premine(sender, defaultBalance) config.SetSeal(true) config.SetBlockLimit(20000000) + config.SetBlockTime(1) }) ctx, cancel := context.WithTimeout(context.Background(), time.Minute) diff --git a/e2e/txpool_test.go b/e2e/txpool_test.go index 6ebcc07de3..0539579a33 100644 --- a/e2e/txpool_test.go +++ b/e2e/txpool_test.go @@ -177,6 +177,7 @@ func TestTxPool_TransactionCoalescing(t *testing.T) { t, 1, IBFTDirPrefix, + false, func(i int, config *framework.TestServerConfig) { config.SetIBFTPoS(true) config.SetValidatorSetOwner(fakeAddr) diff --git a/network/discovery_e2e_test.go b/network/discovery_e2e_test.go index c3fe2ea83a..b512150c66 100644 --- a/network/discovery_e2e_test.go +++ b/network/discovery_e2e_test.go @@ -26,7 +26,7 @@ func TestDiscovery_ConnectedPopulatesRoutingTable(t *testing.T) { closeTestServers(t, servers) }) - joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout) + joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout, false) if joinErr != nil { t.Fatalf("Unable to join peers, %v", joinErr) } @@ -56,7 +56,7 @@ func TestRoutingTable_Connected(t *testing.T) { closeTestServers(t, servers) }) - if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join peers, %v", joinErr) } @@ -101,7 +101,7 @@ func TestRoutingTable_Disconnected(t *testing.T) { }) // connect to peer and make sure peer is in routing table - if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join peers, %v", joinErr) } @@ -166,7 +166,7 @@ func TestRoutingTable_ConnectionFailure(t *testing.T) { // Set a small join timeout, no need to wait ~40s for the connection to fail smallTimeout := time.Second * 10 - if joinErr := JoinAndWait(servers[0], servers[1], smallTimeout+time.Second*5, smallTimeout); joinErr == nil { + if joinErr := JoinAndWait(servers[0], servers[1], smallTimeout+time.Second*5, smallTimeout, false); joinErr == nil { t.Fatalf("should fail to connect to server[1], but connected") } @@ -196,12 +196,12 @@ func TestDiscovery_FullNetwork(t *testing.T) { }) // Server 0 -> Server 1 - if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join peers, %v", joinErr) } // Server 1 -> Server 2 - if joinErr := JoinAndWait(servers[1], servers[2], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[1], servers[2], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join peers, %v", joinErr) } diff --git a/network/e2e_testing.go b/network/e2e_testing.go index cce7ca35b5..a8c5fb7bdb 100644 --- a/network/e2e_testing.go +++ b/network/e2e_testing.go @@ -35,6 +35,7 @@ func JoinAndWait( destination Server, connectTimeout time.Duration, joinTimeout time.Duration, + static bool, ) error { if joinTimeout == 0 { joinTimeout = DefaultJoinTimeout @@ -46,7 +47,7 @@ func JoinAndWait( } // Mark the destination address as ready for dialing - source.JoinPeer(netcommon.AddrInfoToString(destination.AddrInfo())) + source.JoinPeer(netcommon.AddrInfoToString(destination.AddrInfo()), static) connectCtx, cancelFn := context.WithTimeout(context.Background(), connectTimeout) defer cancelFn() @@ -80,7 +81,7 @@ func JoinAndWaitMultiple( go func() { defer wg.Done() - errCh <- JoinAndWait(s1, s2, timeout, timeout) + errCh <- JoinAndWait(s1, s2, timeout, timeout, false) }() } @@ -356,6 +357,7 @@ func MeshJoin(servers ...*DefaultServer) []error { servers[dest], DefaultBufferTimeout, DefaultJoinTimeout, + false, ); joinErr != nil { appendJoinError(fmt.Errorf("unable to join peers, %w", joinErr)) } diff --git a/network/identity_e2e_test.go b/network/identity_e2e_test.go index a3f1ae4c18..f98b328f31 100644 --- a/network/identity_e2e_test.go +++ b/network/identity_e2e_test.go @@ -68,7 +68,7 @@ func TestIdentityHandshake(t *testing.T) { joinTimeout = time.Second * 5 } - joinErr := JoinAndWait(servers[0], servers[1], connectTimeout, joinTimeout) + joinErr := JoinAndWait(servers[0], servers[1], connectTimeout, joinTimeout, false) if shouldSucceed && joinErr != nil { t.Fatalf("Unable to join peer, %v", joinErr) } diff --git a/network/interface.go b/network/interface.go index a664772b5a..f514400da7 100644 --- a/network/interface.go +++ b/network/interface.go @@ -21,7 +21,7 @@ type Network interface { // GetPeerInfo returns the peer info for the given peer ID GetPeerInfo(peerID peer.ID) *peer.AddrInfo // JoinPeer joins a peer to the network - JoinPeer(rawPeerMultiaddr string) error + JoinPeer(rawPeerMultiaddr string, static bool) error // HasPeer returns true if the peer is connected HasPeer(peerID peer.ID) bool // IsConnected returns the node is connecting to the peer associated with the given ID diff --git a/network/server.go b/network/server.go index aaee745c43..b3721958cc 100644 --- a/network/server.go +++ b/network/server.go @@ -23,6 +23,7 @@ import ( "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/peerstore" "github.com/libp2p/go-libp2p-core/protocol" pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/multiformats/go-multiaddr" @@ -48,6 +49,8 @@ const ( MinimumBootNodes int = 1 MinimumPeerConnections int64 = 1 + + DefaultKeepAliveTimer = 10 * time.Second ) var ( @@ -87,6 +90,8 @@ type DefaultServer struct { temporaryDials cmap.ConcurrentMap // map of temporary connections; peerID -> bool bootnodes *bootnodesWrapper // reference of all bootnodes for the node + + staticnodes *staticnodesWrapper // reference of all static nodes for the node } // NewServer returns a new instance of the networking server @@ -167,7 +172,8 @@ func newServer(logger hclog.Logger, config *Config) (*DefaultServer, error) { // start gossip protocol ps, err := pubsub.NewGossipSub( context.Background(), - host, pubsub.WithPeerOutboundQueueSize(peerOutboundBufferSize), + host, + pubsub.WithPeerOutboundQueueSize(peerOutboundBufferSize), pubsub.WithValidateQueueSize(validateBufferSize), ) if err != nil { @@ -256,6 +262,11 @@ func (s *DefaultServer) Start() error { return fmt.Errorf("unable to setup identity, %w", setupErr) } + // Parse the static node data + if setupErr := s.setupStaticnodes(); setupErr != nil { + return fmt.Errorf("unable to parse static node data, %w", setupErr) + } + // Set up the peer discovery mechanism if needed if !s.config.NoDiscover { // Parse the bootnode data @@ -271,6 +282,7 @@ func (s *DefaultServer) Start() error { go s.runDial() go s.keepAliveMinimumPeerConnections() + go s.keepAliveStaticPeerConnections() // watch for disconnected peers s.host.Network().Notify(&network.NotifyBundle{ @@ -283,6 +295,91 @@ func (s *DefaultServer) Start() error { return nil } +// setupStaticnodes setup the static node's connections +func (s *DefaultServer) setupStaticnodes() error { + if s.staticnodes == nil { + s.staticnodes = newStaticnodesWrapper() + } + + if s.config.Chain.Staticnodes == nil || len(s.config.Chain.Staticnodes) == 0 { + return nil + } + + for _, rawAddr := range s.config.Chain.Staticnodes { + staticnode, err := common.StringToAddrInfo(rawAddr) + if err != nil { + s.logger.Error("failed to parse staticnode", "rawAddr", rawAddr, "err", err) + + continue + } + + if staticnode.ID == s.host.ID() { + s.logger.Warn("staticnode is self", "rawAddr", rawAddr) + + continue + } + + s.staticnodes.addStaticnode(staticnode) + } + + s.staticnodes.rangeAddrs(func(addr *peer.AddrInfo) bool { + s.logger.Info("static node", "addr", common.AddrInfoToString(addr)) + + s.markStaticPeer(addr) + + return true + }) + + return nil +} + +// keepAliveStaticPeerConnections keeps the static node connections alive +func (s *DefaultServer) keepAliveStaticPeerConnections() { + if s.staticnodes == nil || s.staticnodes.Len() == 0 { + return + } + + allConnected := false + + delay := time.NewTimer(DefaultKeepAliveTimer) + defer delay.Stop() + + for { + // If all the static nodes are connected, double the delay + if allConnected { + delay.Reset(DefaultKeepAliveTimer * 2) + } else { + delay.Reset(DefaultKeepAliveTimer) + } + + select { + case <-delay.C: + case <-s.closeCh: + return + } + + if s.staticnodes == nil || s.staticnodes.Len() == 0 { + return + } + + allConnected = true + + s.staticnodes.rangeAddrs(func(add *peer.AddrInfo) bool { + if s.host.Network().Connectedness(add.ID) == network.Connected { + return true + } + + if allConnected { + allConnected = false + } + + s.joinPeer(add) + + return true + }) + } +} + // setupBootnodes sets up the node's bootnode connections func (s *DefaultServer) setupBootnodes() error { // Check the bootnode config is present @@ -329,14 +426,11 @@ func (s *DefaultServer) setupBootnodes() error { // keepAliveMinimumPeerConnections will attempt to make new connections // if the active peer count is lesser than the specified limit. func (s *DefaultServer) keepAliveMinimumPeerConnections() { - const duration = 10 * time.Second - - delay := time.NewTimer(duration) + delay := time.NewTimer(DefaultKeepAliveTimer) defer delay.Stop() for { - // TODO: not safe use case - delay.Reset(duration) + delay.Reset(DefaultKeepAliveTimer) select { case <-delay.C: @@ -511,6 +605,21 @@ func (s *DefaultServer) removePeerInfo(peerID peer.ID) *PeerConnInfo { s.peersLock.Lock() defer s.peersLock.Unlock() + // static nodes are not removed from the peers map + if s.staticnodes.isStaticnode(peerID) { + connectionInfo, ok := s.peers[peerID] + if !ok { + // Peer is not present in the peers map + s.logger.Warn( + fmt.Sprintf("Attempted removing missing peer info %s", peerID), + ) + + return nil + } + + return connectionInfo + } + // Remove the peer from the peers map connectionInfo, ok := s.peers[peerID] if !ok { @@ -558,6 +667,12 @@ func (s *DefaultServer) updateBootnodeConnCount(peerID peer.ID, delta int64) { // // Cauction: take care of using this to ignore peer from store, which may break peer discovery func (s *DefaultServer) ForgetPeer(peer peer.ID, reason string) { + if s.staticnodes.isStaticnode(peer) { + s.logger.Debug("forget peer not works for static node", "id", peer, "reason", reason) + + return + } + s.logger.Warn("forget peer", "id", peer, "reason", reason) s.DisconnectFromPeer(peer, reason) @@ -584,6 +699,10 @@ func (s *DefaultServer) DisconnectFromPeer(peer peer.ID, reason string) { return } + if s.staticnodes.isStaticnode(peer) { + return + } + s.logger.Info("closing connection to peer", "id", peer, "reason", reason) if closeErr := s.host.Network().ClosePeer(peer); closeErr != nil { @@ -599,7 +718,7 @@ var ( ) // JoinPeer attempts to add a new peer to the networking server -func (s *DefaultServer) JoinPeer(rawPeerMultiaddr string) error { +func (s *DefaultServer) JoinPeer(rawPeerMultiaddr string, static bool) error { // Parse the raw string to a MultiAddr format parsedMultiaddr, err := multiaddr.NewMultiaddr(rawPeerMultiaddr) if err != nil { @@ -612,12 +731,28 @@ func (s *DefaultServer) JoinPeer(rawPeerMultiaddr string) error { return err } + if peerInfo.ID == s.host.ID() { + return fmt.Errorf("cannot join self") + } + + if static { + s.staticnodes.addStaticnode(peerInfo) + s.markStaticPeer(peerInfo) + } + // Mark the peer as ripe for dialing (async) s.joinPeer(peerInfo) return nil } +// markStaticPeer marks the peer as a static peer +func (s *DefaultServer) markStaticPeer(peerInfo *peer.AddrInfo) { + s.host.Peerstore().AddAddrs(peerInfo.ID, peerInfo.Addrs, peerstore.PermanentAddrTTL) + s.host.ConnManager().TagPeer(peerInfo.ID, "staticnode", 1000) + s.host.ConnManager().Protect(peerInfo.ID, "staticnode") +} + // joinPeer creates a new dial task for the peer (for async joining) func (s *DefaultServer) joinPeer(peerInfo *peer.AddrInfo) { s.logger.Info("Join request", "addr", peerInfo.String()) diff --git a/network/server_discovery.go b/network/server_discovery.go index 1a8407a146..c320c36d20 100644 --- a/network/server_discovery.go +++ b/network/server_discovery.go @@ -85,8 +85,8 @@ func (s *DefaultServer) NewDiscoveryClient(peerID peer.ID) (proto.DiscoveryClien // Discovery protocol streams should be saved, // since they are referenced later on, - // if they are not temporary - if !isTemporaryDial { + // if they are not temporary or static nodes + if !isTemporaryDial || s.staticnodes.isStaticnode(peerID) { s.SaveProtocolStream(common.DiscProto, protoStream, peerID) } @@ -137,8 +137,12 @@ func (s *DefaultServer) AddToPeerStore(peerInfo *peer.AddrInfo) { s.host.Peerstore().AddAddr(peerInfo.ID, peerInfo.Addrs[0], peerstore.AddressTTL) } -// RemoveFromPeerStore removes peer information from the node's peer store +// RemoveFromPeerStore removes peer information from the node's peer store, ignoring static nodes func (s *DefaultServer) RemoveFromPeerStore(peerInfo *peer.AddrInfo) { + if s.staticnodes.isStaticnode(peerInfo.ID) { + return + } + s.host.Peerstore().RemovePeer(peerInfo.ID) } diff --git a/network/server_nonnetwork.go b/network/server_nonnetwork.go index 20524f43fc..aa019051b5 100644 --- a/network/server_nonnetwork.go +++ b/network/server_nonnetwork.go @@ -111,7 +111,7 @@ func (s *NonetworkServer) Close() error { return nil } -func (s *NonetworkServer) JoinPeer(rawPeerMultiaddr string) error { return nil } +func (s *NonetworkServer) JoinPeer(rawPeerMultiaddr string, static bool) error { return nil } func (s *NonetworkServer) HasPeer(peerID peer.ID) bool { return false } diff --git a/network/server_test.go b/network/server_test.go index 3b1ced3759..0fe509984a 100644 --- a/network/server_test.go +++ b/network/server_test.go @@ -44,14 +44,14 @@ func TestConnLimit_Inbound(t *testing.T) { }) // One slot left, Server 0 can connect to Server 1 - if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join servers, %v", joinErr) } // Server 2 tries to connect to Server 1 // but Server 1 is already connected to max inbound peers smallTimeout := time.Second * 5 - if joinErr := JoinAndWait(servers[2], servers[1], smallTimeout, smallTimeout); joinErr == nil { + if joinErr := JoinAndWait(servers[2], servers[1], smallTimeout, smallTimeout, false); joinErr == nil { t.Fatal("Peer join should've failed", joinErr) } @@ -70,7 +70,7 @@ func TestConnLimit_Inbound(t *testing.T) { } // Attempt a connection between Server 2 and Server 1 again - if joinErr := JoinAndWait(servers[2], servers[1], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[2], servers[1], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join servers, %v", joinErr) } } @@ -99,14 +99,14 @@ func TestConnLimit_Outbound(t *testing.T) { }) // One slot left, Server 0 can connect to Server 1 - if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join servers, %v", joinErr) } // Attempt to connect Server 0 to Server 2, but it should fail since // Server 0 already has 1 peer (Server 1) smallTimeout := time.Second * 5 - if joinErr := JoinAndWait(servers[0], servers[2], smallTimeout, smallTimeout); joinErr == nil { + if joinErr := JoinAndWait(servers[0], servers[2], smallTimeout, smallTimeout, false); joinErr == nil { t.Fatalf("Unable to join servers, %v", joinErr) } @@ -310,17 +310,59 @@ func TestJoinWhenAlreadyConnected(t *testing.T) { }) // Server 0 should connect to Server 1 - if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join servers, %v", joinErr) } // Server 1 should attempt to connect to Server 0, but shouldn't error out // if since it's already connected - if joinErr := JoinAndWait(servers[1], servers[0], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[1], servers[0], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join servers, %v", joinErr) } } +func TestJoinStaticNodeWhenAlreadyConnected(t *testing.T) { + defaultConfig := &CreateServerParams{ + ConfigCallback: func(c *Config) { + c.MaxInboundPeers = 2 + c.MaxOutboundPeers = 2 + c.NoDiscover = false + }, + } + + servers, createErr := createServers(2, map[int]*CreateServerParams{ + 0: defaultConfig, + 1: defaultConfig, + }) + + if createErr != nil { + t.Fatalf("Unable to create servers, %v", createErr) + } + + t.Cleanup(func() { + closeTestServers(t, servers) + }) + + // Server 0 should connect to Server 1 as a static node + if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout, true); joinErr != nil { + t.Fatalf("Unable to join servers, %v", joinErr) + } + + // Server 1 joins Server 0 as a static node + if joinErr := JoinAndWait(servers[1], servers[0], DefaultBufferTimeout, DefaultJoinTimeout, true); joinErr != nil { + t.Fatalf("Unable to join servers, %v", joinErr) + } + + servers[0].ForgetPeer(servers[1].host.ID(), "bye") + servers[0].DisconnectFromPeer(servers[1].host.ID(), "bye") + + // Server 0 has a static connection to Server 1, so it should not be disconnected + assert.True(t, true, servers[0].HasPeer(servers[1].host.ID())) + + // Server 1 has a static connection to Server 0, so it should not be disconnected + assert.True(t, true, servers[1].HasPeer(servers[0].host.ID())) +} + func TestNat(t *testing.T) { testIP := "192.0.2.1" testPort := 1500 // important to be less than 2000 because of other tests and more than 1024 because of OS security @@ -446,17 +488,17 @@ func TestPeerReconnection(t *testing.T) { } // connect with the first boot node - if joinErr := JoinAndWait(servers[0], bootnodes[0], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[0], bootnodes[0], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join servers, %v", joinErr) } // connect with the second boot node - if joinErr := JoinAndWait(servers[0], bootnodes[1], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[0], bootnodes[1], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join servers, %v", joinErr) } // Connect with the second server - if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join servers, %v", joinErr) } @@ -523,7 +565,7 @@ func TestReconnectionWithNewIP(t *testing.T) { }) // Server 0 should connect to Server 1 - if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[0], servers[1], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join servers, %v", joinErr) } @@ -543,7 +585,7 @@ func TestReconnectionWithNewIP(t *testing.T) { // servers[0] connects to servers[2] // Server 0 should connect to Server 2 (that has the NAT address set) - if joinErr := JoinAndWait(servers[0], servers[2], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(servers[0], servers[2], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join servers, %v", joinErr) } @@ -642,7 +684,7 @@ func TestRunDial(t *testing.T) { srv, peers := servers[0], servers[1:] for _, p := range peers { - if joinErr := JoinAndWait(srv, p, DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(srv, p, DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Unable to join peer, %v", joinErr) } } @@ -657,12 +699,12 @@ func TestRunDial(t *testing.T) { for idx, p := range peers { if int64(idx) < maxPeers[0] { // Connection should be successful - joinErr := JoinAndWait(srv, p, DefaultBufferTimeout, DefaultJoinTimeout) + joinErr := JoinAndWait(srv, p, DefaultBufferTimeout, DefaultJoinTimeout, false) assert.NoError(t, joinErr) } else { // Connection should fail smallTimeout := time.Second * 5 - joinErr := JoinAndWait(srv, p, smallTimeout, smallTimeout) + joinErr := JoinAndWait(srv, p, smallTimeout, smallTimeout, false) assert.Error(t, joinErr) } } @@ -676,12 +718,12 @@ func TestRunDial(t *testing.T) { // Server 1 can't connect to any peers, so this join should fail smallTimeout := time.Second * 5 - if joinErr := JoinAndWait(srv, peers[0], smallTimeout, smallTimeout); joinErr == nil { + if joinErr := JoinAndWait(srv, peers[0], smallTimeout, smallTimeout, false); joinErr == nil { t.Fatalf("Shouldn't be able to join peer, %v", joinErr) } // Server 0 and Server 2 should connect - if joinErr := JoinAndWait(srv, peers[1], DefaultBufferTimeout, DefaultJoinTimeout); joinErr != nil { + if joinErr := JoinAndWait(srv, peers[1], DefaultBufferTimeout, DefaultJoinTimeout, false); joinErr != nil { t.Fatalf("Couldn't join peer, %v", joinErr) } diff --git a/network/staticnodes.go b/network/staticnodes.go new file mode 100644 index 0000000000..1e4a4115b7 --- /dev/null +++ b/network/staticnodes.go @@ -0,0 +1,59 @@ +package network + +import ( + "sync" + + "github.com/libp2p/go-libp2p-core/peer" +) + +type staticnodesWrapper struct { + mux sync.RWMutex + + peers map[peer.ID]*peer.AddrInfo +} + +func newStaticnodesWrapper() *staticnodesWrapper { + return &staticnodesWrapper{ + peers: make(map[peer.ID]*peer.AddrInfo), + } +} + +func (sw *staticnodesWrapper) Len() int { + sw.mux.RLock() + defer sw.mux.RUnlock() + + return len(sw.peers) +} + +// addStaticnode adds a staticnode to the staticnode list +func (sw *staticnodesWrapper) addStaticnode(addr *peer.AddrInfo) { + sw.mux.Lock() + defer sw.mux.Unlock() + + if addr == nil { + panic("addr is nil") + } + + sw.peers[addr.ID] = addr +} + +func (sw *staticnodesWrapper) rangeAddrs(f func(add *peer.AddrInfo) bool) { + sw.mux.RLock() + defer sw.mux.RUnlock() + + for _, addr := range sw.peers { + if addr != nil { + f(addr) + } + } +} + +// isStaticnode checks if the node ID belongs to a set staticnode +func (sw *staticnodesWrapper) isStaticnode(nodeID peer.ID) bool { + sw.mux.RLock() + defer sw.mux.RUnlock() + + _, ok := sw.peers[nodeID] + + return ok +} diff --git a/protocol/client_test.go b/protocol/client_test.go index 04eef33e66..15e0eaf23a 100644 --- a/protocol/client_test.go +++ b/protocol/client_test.go @@ -84,6 +84,7 @@ func TestGetPeerStatus(t *testing.T) { peerSrv, network.DefaultBufferTimeout, network.DefaultJoinTimeout, + false, ) assert.NoError(t, err) @@ -141,6 +142,7 @@ func TestGetConnectedPeerStatuses(t *testing.T) { peerSrv, network.DefaultBufferTimeout, network.DefaultJoinTimeout, + false, ) expected[idx] = &NoForkPeer{ @@ -195,6 +197,7 @@ func TestStatusPubSub(t *testing.T) { peerSrv, network.DefaultBufferTimeout, network.DefaultJoinTimeout, + false, ) assert.NoError(t, err) @@ -504,6 +507,7 @@ func Test_syncPeerClient_GetBlocks(t *testing.T) { peerSrv, network.DefaultBufferTimeout, network.DefaultJoinTimeout, + false, ) assert.NoError(t, err) @@ -569,6 +573,7 @@ func Test_newSyncPeerClient_forgetNonProtocolPeer(t *testing.T) { peerSrv, network.DefaultBufferTimeout, network.DefaultJoinTimeout, + false, ) assert.NoError(t, err) diff --git a/server/proto/system.pb.go b/server/proto/system.pb.go index ace5018810..814881b5e8 100644 --- a/server/proto/system.pb.go +++ b/server/proto/system.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.27.1 -// protoc v3.19.4 -// source: system.proto +// protoc-gen-go v1.28.1 +// protoc v3.21.12 +// source: server/proto/system.proto package proto @@ -33,7 +33,7 @@ type BlockchainEvent struct { func (x *BlockchainEvent) Reset() { *x = BlockchainEvent{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[0] + mi := &file_server_proto_system_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -46,7 +46,7 @@ func (x *BlockchainEvent) String() string { func (*BlockchainEvent) ProtoMessage() {} func (x *BlockchainEvent) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[0] + mi := &file_server_proto_system_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -59,7 +59,7 @@ func (x *BlockchainEvent) ProtoReflect() protoreflect.Message { // Deprecated: Use BlockchainEvent.ProtoReflect.Descriptor instead. func (*BlockchainEvent) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{0} + return file_server_proto_system_proto_rawDescGZIP(), []int{0} } func (x *BlockchainEvent) GetAdded() []*BlockchainEvent_Header { @@ -90,7 +90,7 @@ type ServerStatus struct { func (x *ServerStatus) Reset() { *x = ServerStatus{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[1] + mi := &file_server_proto_system_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -103,7 +103,7 @@ func (x *ServerStatus) String() string { func (*ServerStatus) ProtoMessage() {} func (x *ServerStatus) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[1] + mi := &file_server_proto_system_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -116,7 +116,7 @@ func (x *ServerStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use ServerStatus.ProtoReflect.Descriptor instead. func (*ServerStatus) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{1} + return file_server_proto_system_proto_rawDescGZIP(), []int{1} } func (x *ServerStatus) GetNetwork() int64 { @@ -160,7 +160,7 @@ type Peer struct { func (x *Peer) Reset() { *x = Peer{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[2] + mi := &file_server_proto_system_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -173,7 +173,7 @@ func (x *Peer) String() string { func (*Peer) ProtoMessage() {} func (x *Peer) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[2] + mi := &file_server_proto_system_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -186,7 +186,7 @@ func (x *Peer) ProtoReflect() protoreflect.Message { // Deprecated: Use Peer.ProtoReflect.Descriptor instead. func (*Peer) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{2} + return file_server_proto_system_proto_rawDescGZIP(), []int{2} } func (x *Peer) GetId() string { @@ -215,13 +215,14 @@ type PeersAddRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Static bool `protobuf:"varint,2,opt,name=static,proto3" json:"static,omitempty"` } func (x *PeersAddRequest) Reset() { *x = PeersAddRequest{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[3] + mi := &file_server_proto_system_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -234,7 +235,7 @@ func (x *PeersAddRequest) String() string { func (*PeersAddRequest) ProtoMessage() {} func (x *PeersAddRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[3] + mi := &file_server_proto_system_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -247,7 +248,7 @@ func (x *PeersAddRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use PeersAddRequest.ProtoReflect.Descriptor instead. func (*PeersAddRequest) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{3} + return file_server_proto_system_proto_rawDescGZIP(), []int{3} } func (x *PeersAddRequest) GetId() string { @@ -257,6 +258,13 @@ func (x *PeersAddRequest) GetId() string { return "" } +func (x *PeersAddRequest) GetStatic() bool { + if x != nil { + return x.Static + } + return false +} + type PeersAddResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -268,7 +276,7 @@ type PeersAddResponse struct { func (x *PeersAddResponse) Reset() { *x = PeersAddResponse{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[4] + mi := &file_server_proto_system_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -281,7 +289,7 @@ func (x *PeersAddResponse) String() string { func (*PeersAddResponse) ProtoMessage() {} func (x *PeersAddResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[4] + mi := &file_server_proto_system_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -294,7 +302,7 @@ func (x *PeersAddResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use PeersAddResponse.ProtoReflect.Descriptor instead. func (*PeersAddResponse) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{4} + return file_server_proto_system_proto_rawDescGZIP(), []int{4} } func (x *PeersAddResponse) GetMessage() string { @@ -315,7 +323,7 @@ type PeersStatusRequest struct { func (x *PeersStatusRequest) Reset() { *x = PeersStatusRequest{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[5] + mi := &file_server_proto_system_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -328,7 +336,7 @@ func (x *PeersStatusRequest) String() string { func (*PeersStatusRequest) ProtoMessage() {} func (x *PeersStatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[5] + mi := &file_server_proto_system_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -341,7 +349,7 @@ func (x *PeersStatusRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use PeersStatusRequest.ProtoReflect.Descriptor instead. func (*PeersStatusRequest) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{5} + return file_server_proto_system_proto_rawDescGZIP(), []int{5} } func (x *PeersStatusRequest) GetId() string { @@ -362,7 +370,7 @@ type PeersListResponse struct { func (x *PeersListResponse) Reset() { *x = PeersListResponse{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[6] + mi := &file_server_proto_system_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -375,7 +383,7 @@ func (x *PeersListResponse) String() string { func (*PeersListResponse) ProtoMessage() {} func (x *PeersListResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[6] + mi := &file_server_proto_system_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -388,7 +396,7 @@ func (x *PeersListResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use PeersListResponse.ProtoReflect.Descriptor instead. func (*PeersListResponse) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{6} + return file_server_proto_system_proto_rawDescGZIP(), []int{6} } func (x *PeersListResponse) GetPeers() []*Peer { @@ -409,7 +417,7 @@ type BlockByNumberRequest struct { func (x *BlockByNumberRequest) Reset() { *x = BlockByNumberRequest{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[7] + mi := &file_server_proto_system_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -422,7 +430,7 @@ func (x *BlockByNumberRequest) String() string { func (*BlockByNumberRequest) ProtoMessage() {} func (x *BlockByNumberRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[7] + mi := &file_server_proto_system_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -435,7 +443,7 @@ func (x *BlockByNumberRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use BlockByNumberRequest.ProtoReflect.Descriptor instead. func (*BlockByNumberRequest) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{7} + return file_server_proto_system_proto_rawDescGZIP(), []int{7} } func (x *BlockByNumberRequest) GetNumber() uint64 { @@ -456,7 +464,7 @@ type BlockResponse struct { func (x *BlockResponse) Reset() { *x = BlockResponse{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[8] + mi := &file_server_proto_system_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -469,7 +477,7 @@ func (x *BlockResponse) String() string { func (*BlockResponse) ProtoMessage() {} func (x *BlockResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[8] + mi := &file_server_proto_system_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -482,7 +490,7 @@ func (x *BlockResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use BlockResponse.ProtoReflect.Descriptor instead. func (*BlockResponse) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{8} + return file_server_proto_system_proto_rawDescGZIP(), []int{8} } func (x *BlockResponse) GetData() []byte { @@ -504,7 +512,7 @@ type ExportRequest struct { func (x *ExportRequest) Reset() { *x = ExportRequest{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[9] + mi := &file_server_proto_system_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -517,7 +525,7 @@ func (x *ExportRequest) String() string { func (*ExportRequest) ProtoMessage() {} func (x *ExportRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[9] + mi := &file_server_proto_system_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -530,7 +538,7 @@ func (x *ExportRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ExportRequest.ProtoReflect.Descriptor instead. func (*ExportRequest) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{9} + return file_server_proto_system_proto_rawDescGZIP(), []int{9} } func (x *ExportRequest) GetFrom() uint64 { @@ -562,7 +570,7 @@ type ExportEvent struct { func (x *ExportEvent) Reset() { *x = ExportEvent{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[10] + mi := &file_server_proto_system_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -575,7 +583,7 @@ func (x *ExportEvent) String() string { func (*ExportEvent) ProtoMessage() {} func (x *ExportEvent) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[10] + mi := &file_server_proto_system_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -588,7 +596,7 @@ func (x *ExportEvent) ProtoReflect() protoreflect.Message { // Deprecated: Use ExportEvent.ProtoReflect.Descriptor instead. func (*ExportEvent) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{10} + return file_server_proto_system_proto_rawDescGZIP(), []int{10} } func (x *ExportEvent) GetFrom() uint64 { @@ -631,7 +639,7 @@ type BlockchainEvent_Header struct { func (x *BlockchainEvent_Header) Reset() { *x = BlockchainEvent_Header{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[11] + mi := &file_server_proto_system_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -644,7 +652,7 @@ func (x *BlockchainEvent_Header) String() string { func (*BlockchainEvent_Header) ProtoMessage() {} func (x *BlockchainEvent_Header) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[11] + mi := &file_server_proto_system_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -657,7 +665,7 @@ func (x *BlockchainEvent_Header) ProtoReflect() protoreflect.Message { // Deprecated: Use BlockchainEvent_Header.ProtoReflect.Descriptor instead. func (*BlockchainEvent_Header) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{0, 0} + return file_server_proto_system_proto_rawDescGZIP(), []int{0, 0} } func (x *BlockchainEvent_Header) GetNumber() int64 { @@ -686,7 +694,7 @@ type ServerStatus_Block struct { func (x *ServerStatus_Block) Reset() { *x = ServerStatus_Block{} if protoimpl.UnsafeEnabled { - mi := &file_system_proto_msgTypes[12] + mi := &file_server_proto_system_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -699,7 +707,7 @@ func (x *ServerStatus_Block) String() string { func (*ServerStatus_Block) ProtoMessage() {} func (x *ServerStatus_Block) ProtoReflect() protoreflect.Message { - mi := &file_system_proto_msgTypes[12] + mi := &file_server_proto_system_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -712,7 +720,7 @@ func (x *ServerStatus_Block) ProtoReflect() protoreflect.Message { // Deprecated: Use ServerStatus_Block.ProtoReflect.Descriptor instead. func (*ServerStatus_Block) Descriptor() ([]byte, []int) { - return file_system_proto_rawDescGZIP(), []int{1, 0} + return file_server_proto_system_proto_rawDescGZIP(), []int{1, 0} } func (x *ServerStatus_Block) GetNumber() int64 { @@ -729,109 +737,111 @@ func (x *ServerStatus_Block) GetHash() string { return "" } -var File_system_proto protoreflect.FileDescriptor - -var file_system_proto_rawDesc = []byte{ - 0x0a, 0x0c, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, - 0x76, 0x31, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0xaf, 0x01, 0x0a, 0x0f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x12, 0x30, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, - 0x69, 0x6e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x05, - 0x61, 0x64, 0x64, 0x65, 0x64, 0x12, 0x34, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x52, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x1a, 0x34, 0x0a, 0x06, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, - 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, - 0x68, 0x22, 0xc3, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x18, 0x0a, 0x07, - 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, - 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x12, 0x30, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, - 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x32, 0x70, 0x41, - 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x32, 0x70, 0x41, 0x64, - 0x64, 0x72, 0x1a, 0x33, 0x0a, 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x6e, - 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, - 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x22, 0x4a, 0x0a, 0x04, 0x50, 0x65, 0x65, 0x72, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x12, 0x14, 0x0a, - 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x61, 0x64, - 0x64, 0x72, 0x73, 0x22, 0x21, 0x0a, 0x0f, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x2c, 0x0a, 0x10, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, - 0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x22, 0x24, 0x0a, 0x12, 0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x33, 0x0a, 0x11, 0x50, 0x65, - 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x1e, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, - 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x22, - 0x2e, 0x0a, 0x14, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, - 0x23, 0x0a, 0x0d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x22, 0x33, 0x0a, 0x0d, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x74, 0x6f, 0x22, 0x5d, 0x0a, 0x0b, 0x45, 0x78, 0x70, - 0x6f, 0x72, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, - 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x74, 0x6f, 0x12, 0x16, 0x0a, 0x06, - 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6c, 0x61, - 0x74, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x8d, 0x03, 0x0a, 0x06, 0x53, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x12, 0x35, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, +var File_server_proto_system_proto protoreflect.FileDescriptor + +var file_server_proto_system_proto_rawDesc = []byte{ + 0x0a, 0x19, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, + 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x76, 0x31, 0x1a, + 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xaf, 0x01, 0x0a, + 0x0f, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x12, 0x30, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x05, 0x61, 0x64, 0x64, + 0x65, 0x64, 0x12, 0x34, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, + 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x1a, 0x34, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, + 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x22, 0xc3, + 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x65, 0x6e, + 0x65, 0x73, 0x69, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x65, 0x6e, 0x65, + 0x73, 0x69, 0x73, 0x12, 0x30, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x07, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x32, 0x70, 0x41, 0x64, 0x64, 0x72, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x32, 0x70, 0x41, 0x64, 0x64, 0x72, 0x1a, + 0x33, 0x0a, 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x68, 0x61, 0x73, 0x68, 0x22, 0x4a, 0x0a, 0x04, 0x50, 0x65, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, + 0x64, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, + 0x22, 0x39, 0x0a, 0x0f, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x22, 0x2c, 0x0a, 0x10, 0x50, + 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x24, 0x0a, 0x12, 0x50, 0x65, 0x65, + 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, + 0x33, 0x0a, 0x11, 0x50, 0x65, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x05, 0x70, + 0x65, 0x65, 0x72, 0x73, 0x22, 0x2e, 0x0a, 0x14, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x4e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x22, 0x23, 0x0a, 0x0d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x33, 0x0a, 0x0d, 0x45, 0x78, 0x70, + 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, + 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, + 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x74, 0x6f, 0x22, 0x5d, + 0x0a, 0x0b, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x66, 0x72, 0x6f, + 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x74, + 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x06, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x8d, 0x03, + 0x0a, 0x06, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x12, 0x35, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x10, 0x2e, + 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x35, 0x0a, 0x08, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x12, 0x13, 0x2e, 0x76, 0x31, + 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x14, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x50, 0x65, 0x65, 0x72, 0x73, 0x4c, + 0x69, 0x73, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x15, 0x2e, 0x76, 0x31, + 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x0b, 0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x16, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x08, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x65, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x10, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x35, 0x0a, 0x08, 0x50, 0x65, - 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x12, 0x13, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, - 0x73, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x76, 0x31, - 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x50, 0x65, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x16, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x15, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, - 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, - 0x0b, 0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x76, - 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x08, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x12, 0x3a, - 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x16, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x1a, 0x13, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x63, 0x68, - 0x61, 0x69, 0x6e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x12, 0x3c, 0x0a, 0x0d, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x76, 0x31, - 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x06, 0x45, 0x78, 0x70, 0x6f, - 0x72, 0x74, 0x12, 0x11, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, - 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x42, 0x0f, 0x5a, 0x0d, 0x2f, 0x73, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x13, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x12, + 0x3c, 0x0a, 0x0d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x18, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x4e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x76, 0x31, 0x2e, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, + 0x06, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x11, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, + 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x76, 0x31, 0x2e, + 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x42, 0x0f, 0x5a, + 0x0d, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_system_proto_rawDescOnce sync.Once - file_system_proto_rawDescData = file_system_proto_rawDesc + file_server_proto_system_proto_rawDescOnce sync.Once + file_server_proto_system_proto_rawDescData = file_server_proto_system_proto_rawDesc ) -func file_system_proto_rawDescGZIP() []byte { - file_system_proto_rawDescOnce.Do(func() { - file_system_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_proto_rawDescData) +func file_server_proto_system_proto_rawDescGZIP() []byte { + file_server_proto_system_proto_rawDescOnce.Do(func() { + file_server_proto_system_proto_rawDescData = protoimpl.X.CompressGZIP(file_server_proto_system_proto_rawDescData) }) - return file_system_proto_rawDescData + return file_server_proto_system_proto_rawDescData } -var file_system_proto_msgTypes = make([]protoimpl.MessageInfo, 13) -var file_system_proto_goTypes = []interface{}{ +var file_server_proto_system_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_server_proto_system_proto_goTypes = []interface{}{ (*BlockchainEvent)(nil), // 0: v1.BlockchainEvent (*ServerStatus)(nil), // 1: v1.ServerStatus (*Peer)(nil), // 2: v1.Peer @@ -847,7 +857,7 @@ var file_system_proto_goTypes = []interface{}{ (*ServerStatus_Block)(nil), // 12: v1.ServerStatus.Block (*emptypb.Empty)(nil), // 13: google.protobuf.Empty } -var file_system_proto_depIdxs = []int32{ +var file_server_proto_system_proto_depIdxs = []int32{ 11, // 0: v1.BlockchainEvent.added:type_name -> v1.BlockchainEvent.Header 11, // 1: v1.BlockchainEvent.removed:type_name -> v1.BlockchainEvent.Header 12, // 2: v1.ServerStatus.current:type_name -> v1.ServerStatus.Block @@ -873,13 +883,13 @@ var file_system_proto_depIdxs = []int32{ 0, // [0:4] is the sub-list for field type_name } -func init() { file_system_proto_init() } -func file_system_proto_init() { - if File_system_proto != nil { +func init() { file_server_proto_system_proto_init() } +func file_server_proto_system_proto_init() { + if File_server_proto_system_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_system_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*BlockchainEvent); i { case 0: return &v.state @@ -891,7 +901,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ServerStatus); i { case 0: return &v.state @@ -903,7 +913,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Peer); i { case 0: return &v.state @@ -915,7 +925,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PeersAddRequest); i { case 0: return &v.state @@ -927,7 +937,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PeersAddResponse); i { case 0: return &v.state @@ -939,7 +949,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PeersStatusRequest); i { case 0: return &v.state @@ -951,7 +961,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PeersListResponse); i { case 0: return &v.state @@ -963,7 +973,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*BlockByNumberRequest); i { case 0: return &v.state @@ -975,7 +985,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*BlockResponse); i { case 0: return &v.state @@ -987,7 +997,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ExportRequest); i { case 0: return &v.state @@ -999,7 +1009,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ExportEvent); i { case 0: return &v.state @@ -1011,7 +1021,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*BlockchainEvent_Header); i { case 0: return &v.state @@ -1023,7 +1033,7 @@ func file_system_proto_init() { return nil } } - file_system_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_server_proto_system_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ServerStatus_Block); i { case 0: return &v.state @@ -1040,18 +1050,18 @@ func file_system_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_proto_rawDesc, + RawDescriptor: file_server_proto_system_proto_rawDesc, NumEnums: 0, NumMessages: 13, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_system_proto_goTypes, - DependencyIndexes: file_system_proto_depIdxs, - MessageInfos: file_system_proto_msgTypes, + GoTypes: file_server_proto_system_proto_goTypes, + DependencyIndexes: file_server_proto_system_proto_depIdxs, + MessageInfos: file_server_proto_system_proto_msgTypes, }.Build() - File_system_proto = out.File - file_system_proto_rawDesc = nil - file_system_proto_goTypes = nil - file_system_proto_depIdxs = nil + File_server_proto_system_proto = out.File + file_server_proto_system_proto_rawDesc = nil + file_server_proto_system_proto_goTypes = nil + file_server_proto_system_proto_depIdxs = nil } diff --git a/server/proto/system.proto b/server/proto/system.proto index e7e929df44..c1fd0de781 100644 --- a/server/proto/system.proto +++ b/server/proto/system.proto @@ -62,6 +62,7 @@ message Peer { message PeersAddRequest { string id = 1; + bool static = 2; } message PeersAddResponse { diff --git a/server/proto/system_grpc.pb.go b/server/proto/system_grpc.pb.go index eba359b689..8d3e190bdd 100644 --- a/server/proto/system_grpc.pb.go +++ b/server/proto/system_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.12 +// source: server/proto/system.proto package proto @@ -383,5 +387,5 @@ var System_ServiceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "system.proto", + Metadata: "server/proto/system.proto", } diff --git a/server/server.go b/server/server.go index 9b45be319b..43391cb821 100644 --- a/server/server.go +++ b/server/server.go @@ -610,8 +610,8 @@ func (s *Server) Chain() *chain.Chain { } // JoinPeer attempts to add a new peer to the networking server -func (s *Server) JoinPeer(rawPeerMultiaddr string) error { - return s.network.JoinPeer(rawPeerMultiaddr) +func (s *Server) JoinPeer(rawPeerMultiaddr string, static bool) error { + return s.network.JoinPeer(rawPeerMultiaddr, static) } // Close closes the server diff --git a/server/system_service.go b/server/system_service.go index 9ee9a57841..287b617757 100644 --- a/server/system_service.go +++ b/server/system_service.go @@ -85,7 +85,7 @@ func (s *systemService) Subscribe(req *empty.Empty, stream proto.System_Subscrib // PeersAdd implements the 'peers add' operator service func (s *systemService) PeersAdd(_ context.Context, req *proto.PeersAddRequest) (*proto.PeersAddResponse, error) { - if joinErr := s.server.JoinPeer(req.Id); joinErr != nil { + if joinErr := s.server.JoinPeer(req.Id, req.Static); joinErr != nil { return &proto.PeersAddResponse{ Message: "Unable to successfully add peer", }, joinErr