/// <summary> /// Initializes a new instance of the <see cref="StatsHandler"/> class. /// </summary> public StatsHandler(SyncConnection connection, IStorage storage, IOptions <IndexerSettings> configuration, IOptions <ChainSettings> chainConfiguration) { this.storage = storage; syncConnection = connection; this.configuration = configuration.Value; this.chainConfiguration = chainConfiguration.Value; }
public MongoStorageOperations(IStorage storage, IOptions <IndexerSettings> configuration, SyncConnection syncConnection) { data = (MongoData)storage; this.configuration = configuration.Value; this.storage = storage; this.syncConnection = syncConnection; }
private SyncPoolTransactions FindPoolInternal(SyncConnection connection, SyncingBlocks syncingBlocks) { watch.Restart(); BitcoinClient client = CryptoClientFactory.Create(connection.ServerDomain, connection.RpcAccessPort, connection.User, connection.Password, connection.Secure); IEnumerable <string> memPool = client.GetRawMemPool(); var currentMemoryPool = new HashSet <string>(memPool); var currentTable = new HashSet <string>(syncingBlocks.CurrentPoolSyncing); var newTransactions = currentMemoryPool.Except(currentTable).ToList(); var deleteTransaction = currentTable.Except(currentMemoryPool).ToList(); //var newTransactionsLimited = newTransactions.Count() < 1000 ? newTransactions : newTransactions.Take(1000).ToList(); syncingBlocks.CurrentPoolSyncing.AddRange(newTransactions); deleteTransaction.ForEach(t => syncingBlocks.CurrentPoolSyncing.Remove(t)); watch.Stop(); log.LogDebug($"SyncPool: Seconds = {watch.Elapsed.TotalSeconds} - New Transactions = {newTransactions.Count()}"); return(new SyncPoolTransactions { Transactions = newTransactions }); }
/// <summary> /// Initializes a new instance of the <see cref="StatsHandler"/> class. /// </summary> public CommandHandler(SyncConnection connection, ILogger <CommandHandler> logger, IStorageOperations storageOperations, ICryptoClientFactory clientFactory) { log = logger; this.storageOperations = storageOperations; this.clientFactory = clientFactory; syncConnection = connection; }
private SyncPoolTransactions FindPoolInternal(SyncConnection connection, SyncingBlocks syncingBlocks) { var stoper = Stopwatch.Start(); var client = CryptoClientFactory.Create(connection.ServerDomain, connection.RpcAccessPort, connection.User, connection.Password, connection.Secure); var memPool = client.GetRawMemPool(); var currentMemoryPool = new HashSet <string>(memPool); var currentTable = new HashSet <string>(syncingBlocks.CurrentPoolSyncing); var newTransactions = currentMemoryPool.Except(currentTable).ToList(); var deleteTransaction = currentTable.Except(currentMemoryPool).ToList(); //var newTransactionsLimited = newTransactions.Count() < 1000 ? newTransactions : newTransactions.Take(1000).ToList(); syncingBlocks.CurrentPoolSyncing.AddRange(newTransactions); deleteTransaction.ForEach(t => syncingBlocks.CurrentPoolSyncing.Remove(t)); stoper.Stop(); this.tracer.DetailedTrace("SyncPool", string.Format("Seconds = {0} - New Transactions = {1}", stoper.Elapsed.TotalSeconds, newTransactions.Count())); return(new SyncPoolTransactions { Transactions = newTransactions }); }
public CirrusMongoData( ILogger <MongoDb> dbLogger, SyncConnection connection, IOptions <ChainSettings> chainConfiguration, GlobalState globalState, IMapMongoBlockToStorageBlock mongoBlockToStorageBlock, ICryptoClientFactory clientFactory, IScriptInterpeter scriptInterpeter, IMongoDatabase mongoDatabase, ICirrusMongoDb db, IComputeSmartContractService <NonFungibleTokenComputedTable> smartContractService) : base( dbLogger, connection, chainConfiguration, globalState, mongoBlockToStorageBlock, clientFactory, scriptInterpeter, mongoDatabase, db) { mongoDb = db; this.smartContractService = smartContractService; }
/// <summary> /// Initializes a new instance of the <see cref="BlockStore"/> class. /// </summary> public BlockStore(IOptions <NakoConfiguration> configuration, ILogger <BlockStore> logger, IStorageOperations storageOperations, SyncConnection syncConnection) : base(configuration, logger) { this.storageOperations = storageOperations; this.syncConnection = syncConnection; this.log = logger; }
/// <summary> /// Initializes a new instance of the <see cref="BlockReorger"/> class. /// </summary> public BlockReorger(Tracer tracer, ISyncOperations syncOperations, SyncConnection syncConnection) : base(tracer) { this.connection = syncConnection; this.operations = syncOperations; this.tracer = tracer; }
/// <summary> /// Initializes a new instance of the <see cref="BlockReorger"/> class. /// </summary> public BlockReorger(ILogger <BlockReorger> logger, ISyncOperations syncOperations, SyncConnection syncConnection) : base(logger) { connection = syncConnection; operations = syncOperations; log = logger; }
public async Task <SyncBlockInfo> RewindToBestChain(SyncConnection connection) { IBlockchainClient client = clientFactory.Create(connection); while (true) { SyncBlockInfo block = storage.GetLatestBlock(); if (block == null) { return(null); } string currentHash = await client.GetblockHashAsync(block.BlockIndex); if (currentHash == block.BlockHash) { return(block); } log.LogDebug($"Rewinding block {block.BlockIndex}({block.BlockHash})"); await storage.DeleteBlockAsync(block.BlockHash); } }
public async Task <string> SendTransaction(string transactionHex) { // todo: consider adding support for retries. // todo: check how a failure is porpageted SyncConnection connection = syncConnection; Transaction trx = null; // parse the trx; trx = connection.Network.Consensus.ConsensusFactory.CreateTransaction(transactionHex); trx.PrecomputeHash(false, true); IBlockchainClient client = clientFactory.Create(connection); string trxid = await client.SentRawTransactionAsync(transactionHex); if (trx.GetHash().ToString() != trxid) { throw new Exception($"node trxid = {trxid}, serialized trxid = {trx.GetHash().ToString()}"); } storageOperations.InsertMempoolTransactions(new SyncBlockTransactionsOperation { Transactions = new List <Transaction> { trx } }); return(trxid); }
/// <summary> /// Initializes a new instance of the <see cref="BlockSyncer"/> class. /// </summary> public BlockSyncer(NakoApplication application, NakoConfiguration config, ISyncOperations syncOperations, SyncConnection syncConnection, Tracer tracer) : base(application, config, tracer) { this.tracer = tracer; this.syncConnection = syncConnection; this.syncOperations = syncOperations; this.config = config; }
/// <summary> /// Initializes a new instance of the <see cref="BlockStore"/> class. /// </summary> public BlockStore(IOptions <IndexerSettings> configuration, ILogger <BlockStore> logger, IStorageOperations storageOperations, SyncConnection syncConnection) : base(configuration, logger) { this.storageOperations = storageOperations; this.syncConnection = syncConnection; log = logger; watch = Stopwatch.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="MongoStorageOperations"/> class. /// </summary> public MongoStorageOperations(IStorage storage, ILogger <MongoStorageOperations> logger, IOptions <NakoConfiguration> configuration, SyncConnection syncConnection) { this.data = (MongoData)storage; this.configuration = configuration.Value; this.log = logger; this.syncConnection = syncConnection; this.storage = storage; }
private SyncBlockTransactionsOperation SyncPoolInternal(SyncConnection connection, SyncPoolTransactions poolTransactions) { IBlockchainClient client = clientFactory.Create(connection); SyncBlockTransactionsOperation returnBlock = SyncBlockTransactions(client, connection, poolTransactions.Transactions, false); return(returnBlock); }
/// <summary> /// Initializes a new instance of the <see cref="QueryController"/> class. /// </summary> public InsightController(IPagingHelper paging, IStorage storage, IMemoryCache cache, IOptions <InsightSettings> insightConfiguration, SyncConnection connection) { this.paging = paging; this.storage = storage; this.cache = cache; this.insightConfiguration = insightConfiguration.Value; syncConnection = connection; }
/// <summary> /// Initializes a new instance of the <see cref="PoolFinder"/> class. /// </summary> public PoolFinder(IOptions <NakoConfiguration> configuration, ISyncOperations syncOperations, SyncConnection syncConnection, ILogger <PoolFinder> logger) : base(configuration, logger) { this.log = logger; this.syncConnection = syncConnection; this.syncOperations = syncOperations; this.config = configuration.Value; }
/// <summary> /// Initializes a new instance of the <see cref="BlockFinder"/> class. /// </summary> public BlockFinder(IOptions <IndexerSettings> configuration, ISyncOperations syncOperations, SyncConnection syncConnection, ILogger <BlockFinder> logger) : base(configuration, logger) { log = logger; this.syncConnection = syncConnection; this.syncOperations = syncOperations; config = configuration.Value; watch = Stopwatch.Start(); }
public MongoData(Tracer tracer, SyncConnection connection, NakoConfiguration nakoConfiguration) { this.syncConnection = connection; this.tracer = tracer; this.configuration = nakoConfiguration; this.mongoClient = new MongoClient(nakoConfiguration.ConnectionString); this.mongoDatabase = this.mongoClient.GetDatabase("Blockchain"); this.MemoryTransactions = new ConcurrentDictionary <string, DecodedRawTransaction>(); }
public CirrusClient(SyncConnection connection) : base(string.Format("{0}://{1}:{2}", connection.Secure ? "https" : "http", connection.ServerDomain, connection.RpcAccessPort), new NetworkCredential(connection.User, connection.Password)) { this.connection = connection; string url = string.Format("{0}://{1}:{2}", connection.Secure ? "https" : "http", connection.ServerDomain, connection.ApiAccessPort); ApiUrl = new Uri(url); }
public async Task <string> SendTransaction(string transactionHex) { // todo: consider adding support for retries. // todo: check how a failure is porpageted SyncConnection connection = syncConnection; BitcoinClient client = CryptoClientFactory.Create(connection.ServerDomain, connection.RpcAccessPort, connection.User, connection.Password, connection.Secure); string trxid = await client.SentRawTransactionAsync(transactionHex); return(trxid); }
public async Task <StatsConnection> StatsConnection() { SyncConnection connection = syncConnection; IBlockchainClient client = clientFactory.Create(connection); int clientConnection = await client.GetConnectionCountAsync(); return(new StatsConnection { Connections = clientConnection }); }
public async Task <StatsConnection> StatsConnection() { SyncConnection connection = syncConnection; BitcoinClient client = CryptoClientFactory.Create(connection.ServerDomain, connection.RpcAccessPort, connection.User, connection.Password, connection.Secure); int clientConnection = await client.GetConnectionCountAsync(); return(new StatsConnection { Connections = clientConnection }); }
public NftComputationService(ILogger <NftComputationService> logger, ICirrusMongoDb mongoDb, ISmartContractHandlersFactory <NonFungibleTokenComputedTable> logReaderFactory, ICryptoClientFactory clientFactory, SyncConnection connection) { this.logger = logger; this.mongoDb = mongoDb; this.logReaderFactory = logReaderFactory; cirrusClient = (CirrusClient)clientFactory.Create(connection); }
public MongoData(ILogger <MongoStorageOperations> logger, SyncConnection connection, IOptions <NakoConfiguration> nakoConfiguration) { this.syncConnection = connection; this.log = logger; this.configuration = nakoConfiguration.Value; this.mongoClient = new MongoClient(this.configuration.ConnectionStringActual); var dbName = this.configuration.DatabaseNameSubfix ? "Blockchain" + this.configuration.CoinTag : "Blockchain"; this.mongoDatabase = this.mongoClient.GetDatabase(dbName); this.MemoryTransactions = new ConcurrentDictionary <string, NBitcoin.Transaction>(); }
/// <summary> /// Initializes a new instance of the <see cref="MongoStorageOperations"/> class. /// </summary> public MongoStorageOperations(IStorage storage, MongoData mongoData, Tracer tracer, NakoConfiguration nakoConfiguration, SyncConnection syncConnection) { this.data = mongoData; this.configuration = nakoConfiguration; this.tracer = tracer; this.storage = storage; this.syncConnection = syncConnection; }
public ComputeSmartContractService(ILogger <ComputeSmartContractService <T> > logger, ICirrusMongoDb db, ISmartContractHandlersFactory <T> logReaderFactory, ICryptoClientFactory clientFactory, SyncConnection connection, IMongoDatabase mongoDatabase) { this.logger = logger; mongoDb = db; this.logReaderFactory = logReaderFactory; this.mongoDatabase = mongoDatabase; cirrusClient = (CirrusClient)clientFactory.Create(connection); emptyContract = new T(); }
private SyncBlockTransactionsOperation SyncPoolInternal(SyncConnection connection, SyncPoolTransactions poolTransactions) { var stoper = Stopwatch.Start(); var client = CryptoClientFactory.Create(connection.ServerDomain, connection.RpcAccessPort, connection.User, connection.Password, connection.Secure); var returnBlock = this.SyncBlockTransactions(client, connection, poolTransactions.Transactions, false); stoper.Stop(); this.tracer.DetailedTrace("SyncPool", string.Format("Seconds = {0} - Transactions = {1}", stoper.Elapsed.TotalSeconds, returnBlock.Transactions.Count())); return(returnBlock); }
public MongoData(ILogger <MongoDb> dbLogger, SyncConnection connection, IOptions <ChainSettings> chainConfiguration, GlobalState globalState, IMapMongoBlockToStorageBlock mongoBlockToStorageBlock, ICryptoClientFactory clientFactory, IScriptInterpeter scriptInterpeter, IMongoDatabase mongoDatabase, IMongoDb db) { log = dbLogger; this.chainConfiguration = chainConfiguration.Value; this.globalState = globalState; syncConnection = connection; this.mongoBlockToStorageBlock = mongoBlockToStorageBlock; this.clientFactory = clientFactory; this.scriptInterpeter = scriptInterpeter; this.mongoDatabase = mongoDatabase; mongoDb = db; }
/// <summary> /// Initializes a new instance of the <see cref="MempoolPuller"/> class. /// </summary> public MempoolPuller( IOptions <IndexerSettings> configuration, ISyncOperations syncOperations, SyncConnection syncConnection, ILogger <MempoolPuller> logger, IStorageOperations storageOperations) : base(configuration, logger) { log = logger; this.storageOperations = storageOperations; this.syncConnection = syncConnection; this.syncOperations = syncOperations; config = configuration.Value; watch = Stopwatch.Start(); }