Пример #1
0
        internal void Start()
        {
            LoadState();
            transactionGenerator = new TransactionGenerator(node.User.UserAddress, node.User.Keys.PrivateKey);
            node.LoadChain();

            server = new Server
            {
                Services = { PublisherServer.BindService(new PublisherServerImpl(node, node, serverSettings)) },
                Ports    = { new ServerPort(serverSettings.Ip, serverSettings.Port, ServerCredentials.Insecure) }
            };
            server.Start();

            RequestChainDelta();
            UpdateKnownNodes();

            StartPublishing();
        }
Пример #2
0
        internal bool ChangeServerAddress(string newIp, int newPort)
        {
            //Test whether settings work
            try
            {
                var newServer = new Server
                {
                    Services = { PublisherServer.BindService(new PublisherServerImpl(node, node, serverSettings)) },
                    Ports    = { new ServerPort(newIp, newPort, ServerCredentials.Insecure) }
                };
                newServer.Start();
                newServer.ShutdownAsync().Wait();
            } catch (RpcException)
            {
                return(false);
            }

            //If settings are valid, shut down current server instance, start new one and update server settings
            server.ShutdownAsync().Wait();

            serverSettings = new ServerAddress()
            {
                Ip = newIp
                ,
                Port = newPort
            };
            node.SetSelfAddress(serverSettings);

            server = new Server
            {
                Services = { PublisherServer.BindService(new PublisherServerImpl(node, node, serverSettings)) },
                Ports    = { new ServerPort(newIp, newPort, ServerCredentials.Insecure) }
            };
            server.Start();

            return(true);
        }