示例#1
0
        public void Init()
        {
            _blockChainService   = Services.GetService <IBlockChainService>();
            _difficultyService   = Services.GetService <IDifficultyService>();
            _transactionVerifier = Services.GetService <ITransactionVerifier>();
            _walletService       = Services.GetService <IWalletService>();
            _logger = Services.GetService <ILogger>();

            _eventManager = Services.GetService <IEventManager>();

            _memPoolFullPath = $"{Configurations.CurrentPath}\\BlockChain\\Data\\MemPool.json";
            TryLoadMemPool();
            MemPool.CollectionChanged += MemPool_CollectionChanged;

            CurrentWorkers = new List <Thread>();
            Terminators    = new Dictionary <int, bool>();

            return;

            Task.Run(delegate
            {
                _logger.Log("Starting first miner in 6..");
                Thread.Sleep(3000);
                _logger.Log("Starting first miner in 3..");
                Thread.Sleep(3000);
                TryRestartingWorkers();
            });
        }
示例#2
0
        public void Initialize(
            CommandLineOptions options,
            PrivateKey privateKey,
            Action <bool> callback)
        {
            PrivateKey = privateKey;

            _channel = new Channel(
                options.RpcServerHost,
                options.RpcServerPort,
                ChannelCredentials.Insecure,
                new[]
            {
                new ChannelOption("grpc.max_receive_message_length", -1)
            }
                );
            _lastTipChangedAt = DateTimeOffset.UtcNow;
            _hub     = StreamingHubClient.Connect <IActionEvaluationHub, IActionEvaluationHubReceiver>(_channel, this);
            _service = MagicOnionClient.Create <IBlockChainService>(_channel);

            _genesis = BlockManager.ImportBlock(options.GenesisBlockPath ?? BlockManager.GenesisBlockPath);
            var appProtocolVersion = options.AppProtocolVersion is null
                ? default
                : Libplanet.Net.AppProtocolVersion.FromToken(options.AppProtocolVersion);

            AppProtocolVersion = appProtocolVersion.Version;

            RegisterDisconnectEvent(_hub);
            StartCoroutine(CoTxProcessor());
            StartCoroutine(CoJoin(callback));
        }
示例#3
0
        public BitLevelManager(IUserAuthorization authorizer, IUserContext userContext, IBitLevelQuery query,
                               IPersistenceCommands pcommand, IUserNotifier notifier, IBlockChainService blockChain,
                               ISettingsManager settingsManager, IReferralQuery refQuery,
                               //IEmailPush emailService,
                               IBackgroundOperationScheduler backgroundProcessor,
                               IAppUrlProvider urlProvider)
        {
            ThrowNullArguments(() => userContext,
                               () => query,
                               () => pcommand,
                               () => notifier,
                               () => blockChain,
                               () => settingsManager,
                               () => refQuery,
                               //() => emailService,
                               () => backgroundProcessor,
                               () => urlProvider);

            _query           = query;
            _pcommand        = pcommand;
            _authorizer      = authorizer;
            _notifier        = notifier;
            _blockChain      = blockChain;
            _refQuery        = refQuery;
            _settingsManager = settingsManager;
            //_emailService = emailService;
            _backgroundProcessor = backgroundProcessor;
            _urlProvider         = urlProvider;

            UserContext = userContext;
        }
示例#4
0
 public void Init()
 {
     _transactionVerifier = Services.GetService <ITransactionVerifier>();
     _difficultyService   = Services.GetService <IDifficultyService>();
     _blockChainService   = Services.GetService <IBlockChainService>();
     _minerService        = Services.GetService <IMinerService>();
 }
 public LifetimeEventsHostedService(
     ILogger <LifetimeEventsHostedService> logger,
     IHostApplicationLifetime appLifetime,
     IBlockChainService blockChainService)
 {
     _logger            = logger;
     _appLifetime       = appLifetime;
     _blockChainService = blockChainService;
 }
示例#6
0
        public MineService(ITransactionPool transactionPool, IBlockChainService blockChainService,
                           ITransactionExecutingService transactionExecutingService)
        {
            _transactionPool             = transactionPool;
            _blockChainService           = blockChainService;
            _transactionExecutingService = transactionExecutingService;

            Logger = NullLogger.Instance;
        }
示例#7
0
        public void Init()
        {
            Logger             = Services.GetService <ILogger>();
            _blockChainService = Services.GetService <IBlockChainService>();
            _catchUpService    = Services.GetService <ICatchUpService>();
            ToParseQueue       = new Queue <Action>();
            var parser = new Thread(new ThreadStart(ParserThread));

            parser.Start();
            Start();
        }
示例#8
0
        protected BlockChain(IBlockChainService blockChainService)
        {
            _blockChainService = blockChainService;

            if (_blockChainService.Blocks.Count() == 0)
            {
                CreateGenesisBlock();
            }

            MiningAsync();
        }
示例#9
0
 public DocumentService(IBlockChainService blockChainService, IStorageService storageService, ICryptoService cryptoService,
                        IDataService dataService, ILogger <DocumentService> logger)
 {
     this.blockChainService = blockChainService ??
                              throw new System.ArgumentNullException(nameof(blockChainService));
     this.storageService = storageService ??
                           throw new System.ArgumentNullException(nameof(storageService));
     this.cryptoService = cryptoService ??
                          throw new System.ArgumentNullException(nameof(cryptoService));
     this.dataService = dataService ??
                        throw new System.ArgumentNullException(nameof(dataService));
     this.logger = logger ??
                   throw new System.ArgumentNullException(nameof(logger));
 }
示例#10
0
        public static BlockChain Instance(IBlockChainService blockChainService)
        {
            if (instance == null)
            {
                lock (syncRoot)
                {
                    if (instance == null)
                    {
                        instance = new BlockChain(blockChainService);
                    }
                }
            }

            return(instance);
        }
示例#11
0
        public void Init()
        {
            _logger            = Services.GetService <ILogger>();
            _unspentDbFullPath = $"{Configurations.CurrentPath}\\BlockChain\\Data\\Unspent.sqlite";

            var ev = Services.GetService <IEventManager>();

            ev.RegisterEventListener(OnNewBlock, EventTypes.EventType.NewVerifiedBlock);
            ev.RegisterEventListener(OnNewTransaction, EventTypes.EventType.NewTransaction);

            _blockChainService = Services.GetService <IBlockChainService>();
            _minerService      = Services.GetService <IMinerService>();
            _mappingService    = Services.GetService <IMappingService>();

            TryConnectToUnspentDB();

            if (!IsLoadedIn(_blockChainService.Info.EndOfLongestChain))
            {
                _logger.Log("Need to backload the Unspent db for some reasons");
                LoadEveryNewBlock();
            }
        }
示例#12
0
        public void Init()
        {
            _logger            = Services.GetService <ILogger>();
            _mappingService    = Services.GetService <IMappingService>();
            _server            = Services.GetService <IP2PServer>();
            _minerService      = Services.GetService <IMinerService>();
            _eventManager      = Services.GetService <IEventManager>();
            _blockChainService = Services.GetService <IBlockChainService>();

            _catchDataFullPath = $"{Configurations.CurrentPath}\\BlockChain\\Catchup";
            _logger.Log("Ketchup started to flow ....", 1);
            CaughtUp               = false;
            bufferedTransactions   = new List <Transaction>();
            bufferedBlockInfos     = new List <BlockInfo>();
            supposedLongestBlockId = "";
            shouldTryEnd           = false;
            LastGotResponse        = DateTime.UtcNow;

            if (!Directory.Exists(_catchDataFullPath))
            {
                Directory.CreateDirectory(_catchDataFullPath);
            }
        }
 public BalanceController(ILogger <BalanceController> logger, IBlockChainService blockChainService)
 {
     this.Logger            = logger;
     this.BlockChainService = blockChainService;
 }
示例#14
0
 public HomeController(ILogger <HomeController> logger, IBlockChainService blockChain)
 {
     _logger     = logger;
     _blockChain = blockChain;
 }
示例#15
0
        public BlockChainController(IBlockChainService blockChain)
        {
            ThrowNullArguments(() => blockChain);

            this._blockChain = blockChain;
        }
示例#16
0
 public BlockChainController(IBlockChainService blockChainService)
 {
     _blockChainService = blockChainService;
 }
示例#17
0
 public void Init()
 {
     _blockChainService = Services.GetService <IBlockChainService>();
 }
示例#18
0
 public CabinetController()
 {
     _serviceUsers      = new UserService(new ModelStateWrapper(ModelState), new UserRepository());
     _blockChainService = new BlockChainService(new ModelStateWrapper(ModelState), new BlockChainRepository());
     _blockChain        = BlockChain.Instance(_blockChainService);
 }
 public BlockChainController(ILogger <BlockChainController> logger, IBlockChainService blockChainService, NetworkSimulator networkSimulator)
 {
     _logger            = logger;
     _blockChainService = blockChainService;
     _networkSimulator  = networkSimulator;
 }
 public StateController(ILogger <StateController> logger, IBlockChainService blockChainService)
 {
     this.Logger            = logger;
     this.BlockChainService = blockChainService;
 }
示例#21
0
 public WebServiceController()
 {
     _transactionVerifier = Services.GetService <ITransactionVerifier>();
     _eventManager        = Services.GetService <IEventManager>();
     _blockChainService   = Services.GetService <IBlockChainService>();
 }