Ejemplo n.º 1
0
 public Peers(INode node, IPeerChannel channel, ILogger <Peers> logger)
 {
     this.node    = node;
     this.channel = channel;
     this.logger  = logger;
 }
Ejemplo n.º 2
0
        public Node(NodeOptions options, IBlockBuilder blockBuilder, ILoggerFactory loggerFactory, IPeerChannel channel)
        {
            this.options = options;
            this.logger  = loggerFactory.CreateLogger <Node>();

            logger.LogInformation($"Configuración del nodo:\n" +
                                  $"NodeId: {options.NodeId}\n" +
                                  $"NodeName: {options.NodeName}\n" +
                                  $"NodePublicUrl: {options.NodePublicUrl}\n" +
                                  $"PeerUrl: {options.PeerUrl}\n" +
                                  $"MinerAddress: {options.MinerAddress}\n" +
                                  $"BlockchainDificulty: {options.BlockchainDificulty}");

            Host = new Peer
            {
                Id        = options.NodeId,
                Name      = options.NodeName,
                PublicUrl = options.NodePublicUrl
            };

            Peers = new Peers(this, channel, loggerFactory.CreateLogger <Peers>());

            Blockchain = new Blockchain(new Miner(AddressRewards), blockBuilder, options.BlockchainDificulty);

            var path = "genesis.block";

            Blockchain.LoadGenesisBlock(path);

            pendings = new Dictionary <string, BlockItem>();
        }