Esempio n. 1
0
        public static IPrintLedgerReports For(ILedger ledger)
        {
            var reportPrinter = Ioc.Resolve <IPrintLedgerReports>();

            reportPrinter.For = ledger;
            return(reportPrinter);
        }
Esempio n. 2
0
        public CatalystNodePoa(IKeySigner keySigner,
                               IPeerService peer,
                               IConsensus consensus,
                               IDfsService dfsService,
                               ILedger ledger,
                               ILogger logger,
                               IPeerClient peerClient,
                               IPeerSettings peerSettings,
                               IMempool <PublicEntryDao> memPool,
                               ISynchroniser synchronizer,
                               IPeerRepository peerRepository,
                               IContract contract = null)
        {
            Guard.Argument(peerRepository, nameof(peerRepository)).NotNull();

            _peer           = peer;
            _peerClient     = peerClient;
            _peerSettings   = peerSettings;
            Consensus       = consensus;
            _dfsService     = dfsService;
            _ledger         = ledger;
            _keySigner      = keySigner;
            _logger         = logger;
            _memPool        = memPool;
            _contract       = contract;
            _synchronizer   = synchronizer;
            _peerRepository = peerRepository;

            var privateKey = keySigner.KeyStore.KeyStoreDecrypt(KeyRegistryTypes.DefaultKey);

            _publicKey = keySigner.CryptoContext.GetPublicKeyFromPrivateKey(privateKey);
        }
 /// <summary>
 /// constractor.
 /// </summary>
 public SalesInvoiceController(
     ISalesInvoice salesInvoice,
     ILedger ledger,
     ILedgerAddress ledgerAddress,
     ITaxRegister taxRegister,
     ICurrency currency,
     ICurrencyConversion currencyConversion)
 {
     this._salesInvoice       = salesInvoice;
     this._ledger             = ledger;
     this._ledgerAddress      = ledgerAddress;
     this._taxRegister        = taxRegister;
     this._currency           = currency;
     this._currencyConversion = currencyConversion;
 }
Esempio n. 4
0
 public void GlobalSetup()
 {
     this.monitorLedger  = new MonitorLedger(100);
     this.spinLockLedger = new SpinLockLedger(100);
 }
Esempio n. 5
0
 public Account(ILedger transactionLog)
 {
     _transactionLog = transactionLog;
 }
 /// <summary>
 /// constractor.
 /// </summary>
 public SalesInvoiceTaxMasterController(ISalesInvoiceTax salesInvoiceTax, ILedger ledger)
 {
     this._salesInvoiceTax = salesInvoiceTax;
     this._ledger          = ledger;
 }
 public void StartRecordingSession()
 {
     unitOfWork = repository.UnitOfWork;
     LedgerService = new LedgerService(repository);
 }
Esempio n. 8
0
 public DeltaResolver(IDeltaIndexService deltaIndexService, ILedger ledger)
 {
     _deltaIndexService = deltaIndexService;
     _ledger            = ledger;
 }
        public void PrintLastTransaction(ILedger ledger)
        {
            var lastTransaction = ledger.Accept(new LastTransactionVisitor(), null);

            Console.Write("Last transaction: {0}", lastTransaction);
        }
Esempio n. 10
0
        public void Init()
        {
            _cancellationToken = new CancellationToken();

            _manualResetEventSlim = new ManualResetEventSlim(false);

            _testScheduler = new TestScheduler();
            _hashProvider  = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256"));

            _peerSettings = Substitute.For <IPeerSettings>();
            _peerSettings.PeerId.Returns(PeerIdHelper.GetPeerId());

            _deltaDfsReader = Substitute.For <IDeltaDfsReader>();
            _deltaDfsReader.TryReadDeltaFromDfs(Arg.Any <Cid>(), out Arg.Any <Delta>()).Returns(x => true);

            _deltaCache = Substitute.For <IDeltaCache>();
            _deltaCache.GenesisHash.Returns("bafk2bzacecji5gcdd6lxsoazgnbg46c3vttjwwkptiw27enachziizhhkir2w".ToCid());

            _ledger = Substitute.For <ILedger>();

            _peerService = Substitute.For <IPeerService>();

            _deltaHashProvider = new DeltaHashProvider(_deltaCache, Substitute.For <IDeltaIndexService>(), Substitute.For <ILogger>());

            _deltaIndexService = new DeltaIndexService(new InMemoryRepository <DeltaIndexDao, string>());
            _deltaIndexService.Add(new DeltaIndexDao {
                Cid = _hashProvider.ComputeUtf8MultiHash("0").ToCid(), Height = 0
            });

            _peerClient = Substitute.For <IPeerClient>();
            ModifyPeerClient <LatestDeltaHashRequest>((request, senderPeerIdentifier) =>
            {
                var deltaHeightResponse = new LatestDeltaHashResponse
                {
                    DeltaIndex = new DeltaIndex
                    {
                        Cid = _hashProvider.ComputeUtf8MultiHash(_syncTestHeight.ToString()).ToCid().ToArray()
                              .ToByteString(),
                        Height = (uint)_syncTestHeight
                    }
                };

                _deltaHeightReplaySubject.OnNext(new ObserverDto(Substitute.For <IChannelHandlerContext>(),
                                                                 deltaHeightResponse.ToProtocolMessage(senderPeerIdentifier, CorrelationId.GenerateCorrelationId())));
            });

            ModifyPeerClient <DeltaHistoryRequest>((request, senderPeerIdentifier) =>
            {
                var data = GenerateSampleData((int)request.Height, (int)request.Range, (int)_syncTestHeight);
                _deltaIndexService.Add(data.DeltaIndex.Select(x => DeltaIndexDao.ToDao <DeltaIndex>(x, _mapperProvider)));

                _deltaHistoryReplaySubject.OnNext(new ObserverDto(Substitute.For <IChannelHandlerContext>(),
                                                                  data
                                                                  .ToProtocolMessage(senderPeerIdentifier, CorrelationId.GenerateCorrelationId())));
            });

            _peerRepository = new PeerRepository(new InMemoryRepository <Peer, string>());
            Enumerable.Repeat(new Peer {
                PeerId = PeerIdHelper.GetPeerId()
            }, 5).ToList().ForEach(_peerRepository.Add);

            _deltaHeightReplaySubject  = new ReplaySubject <IObserverDto <ProtocolMessage> >(1);
            _deltaHistoryReplaySubject = new ReplaySubject <IObserverDto <ProtocolMessage> >(1);

            var mergeMessageStreams = _deltaHeightReplaySubject.AsObservable()
                                      .Merge(_deltaHistoryReplaySubject.AsObservable());

            _peerService.MessageStream.Returns(mergeMessageStreams);

            _deltaHashProvider = Substitute.For <IDeltaHashProvider>();
            _deltaHashProvider.TryUpdateLatestHash(Arg.Any <Cid>(), Arg.Any <Cid>()).Returns(true);

            _mapperProvider = new TestMapperProvider();

            _userOutput = Substitute.For <IUserOutput>();

            _deltaHeightWatcher = new DeltaHeightWatcher(_peerClient, _peerRepository, _peerService, minimumPeers: 0);

            var dfsService = Substitute.For <IDfsService>();

            _peerSyncManager = new PeerSyncManager(_peerClient, _peerRepository,
                                                   _peerService, _userOutput, _deltaHeightWatcher, Substitute.For <IDfsService>(), 0.7, 0);
        }
Esempio n. 11
0
 public static IPrintLedgerReports For(ILedger ledger)
 {
     var reportPrinter = Ioc.Resolve<IPrintLedgerReports>();
     reportPrinter.For = ledger;
     return reportPrinter;
 }
Esempio n. 12
0
 /// <summary>
 /// constractor.
 /// </summary>
 public SalesInvoiceTaxDetailController(ISalesInvoiceDetailTax salesInvoiceDetailTax, ILedger ledger)
 {
     this._salesInvoiceDetailTax = salesInvoiceDetailTax;
     this._ledger = ledger;
 }
Esempio n. 13
0
 public void StartRecordingSession()
 {
     unitOfWork    = repository.UnitOfWork;
     LedgerService = new LedgerService(repository);
 }