public Blockchain(IBlockCreator blockCreator, IHashCalculator blockHashCalculator, IProofValidator proofValidator, IBlockchainValidator blockchainValidator) { this.blockCreator = blockCreator; this.blockHashCalculator = blockHashCalculator; this.proofValidator = proofValidator; this.blockchainValidator = blockchainValidator; if (chain.Count == 0) { Block firstBlock = blockCreator.CreateBlock(0, new List <Transaction>(), 0, null); chain.Add(firstBlock); } }
public ConsensusService(IHubContext <ConsensusHub, IConsensusClient> consensusHubContext, IEncodedBlocksStorage encodedBlocksStorage, IBlockchainValidator blockchainValidator, IServerNodesStorage serverNodesStorage, IBlockchainService blockchainService, IStatisticService statisticService, IBackgroundQueue backgroundQueue, IConfigurationService configurationService) : base(configurationService) { _consensusHubContext = consensusHubContext; _encodedBlocksStorage = encodedBlocksStorage; _blockchainValidator = blockchainValidator; _serverNodesStorage = serverNodesStorage; _blockchainService = blockchainService; _statisticService = statisticService; _backgroundQueue = backgroundQueue; }
public Blockchain( IBlockchainCreator blockchainCreator, IBlockchainValidator blockchainValidator, IMessageStore messageStore, IQueryHandler <GetBlockQuery, Database.Block> queryHandlerGetBlock, IQueryHandler <GetHeadBlockQuery, Database.Block> queryHandlerGetHeadBlock, IQueryHandler <GetMessagesQuery, IEnumerable <EncryptedMessageStore> > queryHandlerGetMessages, IQueryHandler <AddBlockQuery, bool> queryHandlerAddBlock, IQueryHandler <MarkMainChainQuery, bool> queryHandlerMarkMainChain ) { _blockchainCreator = blockchainCreator; _blockchainValidator = blockchainValidator; _messageStore = messageStore; _queryHandlerGetBlock = queryHandlerGetBlock; _queryHandlerGetHeadBlock = queryHandlerGetHeadBlock; _queryHandlerGetMessages = queryHandlerGetMessages; _queryHandlerAddBlock = queryHandlerAddBlock; _queryHandlerMarkMainChain = queryHandlerMarkMainChain; _hashCash = new BlockchainHashCash(3); }