Ejemplo n.º 1
0
        public IConnectionService CreateConnectionService()
        {
            var config     = NodeBuilder.BuildConfiguration(NodeConfiguration.GetPath("node_server.txt"), NodeConfiguration.GetCertificatesPath(), "node_id.pem");
            var nodes      = P2PServerConfiguration.ToIPEndpoints(new UrlConfiguration(NodeConfiguration.GetPath("nodes.txt")).Lines);
            var connection = new Connections.P2PConnection(config, nodes, 5, 20);

            var connectionService = new ConnectionService(connection, false /*TODO to config ?*/);
            var dispatcher        = new Dispatcher(connectionService.Logger);
            var bockchainChannel  = connectionService.CreateChannel(ConnectionService.BLOCKCHAIN_CHANNEL, dispatcher, new BlockchainApi().JsonMessageFactory, session => true);

            connectionService.SetBlockchainChannel(bockchainChannel);

            return(connectionService);
        }
Ejemplo n.º 2
0
        public virtual ILiveService CreateLiveService()
        {
            var nodes      = new UrlConfiguration(NodeConfiguration.GetPath("validators.txt")).Lines;
            var quorum     = int.Parse(nodes[0]);
            var validators = new List <PublicKey>();

            for (var i = 1; i < nodes.Count; i++)
            {
                validators.Add(new PublicKey(Convert.FromBase64String(nodes[i])));
            }

            var lines   = new UrlConfiguration(NodeConfiguration.GetPath("issuers.txt")).Lines;
            var issuers = new List <Issuer>();

            foreach (var line in lines)
            {
                var splited = line.Split('|');
                issuers.Add(new Issuer(new Address(splited[1].Trim()), Currency.FromSymbol(splited[0].Trim())));
            }

            return(new LiveService(quorum, validators, issuers));
        }
Ejemplo n.º 3
0
 public static string GetDefaultPath()
 {
     return(NodeConfiguration.GetPath("initial.block"));
 }