Beispiel #1
0
        public void Initiate(INodeConnector NodeConnector = null, IChainStorageProvider ChainStore = null, Boolean SkipGenesisBlock = false)
        {
            if (ChainStore == null)
            {
                ChainStore = new InMemoryChainStorageProvider();
            }
            ;

            BlockChain = ChainStore;

            BlockChain.initiate();

            if (NodeConnector != null)
            {
                this.NodeConnector = NodeConnector;
                //this.NodeConnector.RegisterNode(this);
            }

            if ((NodeConnector == null || NodeConnector?.TotalNodeCount() == 0) && SkipGenesisBlock != true)
            {
                // This node either has no connector (is therefore independent) or has a connector but
                // is only listening (hasn't connected to an existing network, possibly the first for a new network)
                AddGenesisBlock();
            }
            else
            {
                // This node if part of a network of nodes, populate our blockchain with that
                // of the primary connected node.


                // BlockChain = NodeConnector.RequestInitialBlockChain();
                // if(!(BlockChain?.Count > 0))
                // {
                //     throw new Exception("Unable to retrieve initial blockchain from connected node");
                // }
            }



            Initiated = true;
        }
Beispiel #2
0
 public EthereumNodeClient(NodeConnectionType connectionType, string address)
 {
     _connector = NodeConnectorFactory.Create(connectionType, address);
 }