Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Blockchain"/> class.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="storage"/> is <c>null</c>.
        /// </exception>
        public Blockchain(IBlockchainStorage storage)
        {
            if (storage == null)
            {
                throw new ArgumentNullException(nameof(storage));
            }

            this.storage = storage;
        }
Ejemplo n.º 2
0
        public BitcoinNode(IBlockchainStorage storage)
        {
            this.storage = storage;
            this.blockchain = new Blockchain(storage);

            services.AddFactory(new NodeDiscoveryServiceFactory());
            services.AddFactory(new BlockHeaderDownloadServiceFactory());
            services.AddFactory(new BlockContentDownloadServiceFactory());
            services.AddFactory(new BlockValidationServiceFactory());
        }
Ejemplo n.º 3
0
            static UInt256 GetAssetId(IBlockchainStorage blockchain, string asset)
            {
                if (string.Compare("neo", asset, true) == 0)
                {
                    return(blockchain.GoverningTokenHash);
                }

                if (string.Compare("gas", asset, true) == 0)
                {
                    return(blockchain.UtilityTokenHash);
                }

                return(UInt256.Parse(asset));
            }
 public InternalBlockchain(IBlockchainStorage storage)
 {
     this.storage = storage;
     transactionalResource = new TransactionalResource(OnCommit, OnRollback);
 }
Ejemplo n.º 5
0
 public Blockchain(IBlockchainStorage storage)
 {
     CachingBlockchainStorage cache = new CachingBlockchainStorage(storage);
     blockchain = new InternalBlockchain(cache);
 }