public LedgerManager(Settings settings, IXICore ixicore, IXISettings ixisettings)
        {
            Settings = settings;

            _ixiSettings = ixisettings;
            _ixiSettings.SetNodeAddress(settings.NodeList.First());

            _ixiCore = ixicore;
        }
        public ThreadManager(Block latestBlock, IXICore ixicore, IXISettings ixisettings)
        {
            LatestBlock  = latestBlock;
            CoinName     = latestBlock.CoinName;
            _ixiCore     = ixicore;
            _ixiSettings = ixisettings;

            //Start All needed Threads
            //Start POW
            POWsource = StartPOWThreads();

            //Start construction block
            constructBlockSource = ConstructBlockThread();

            //Start Get newest DATA thread
            latestBlocksource = GetLatestBlockThread();
        }
        public static IXICore SimpleSetup(this IXICore core, string coinName, IXISettings settings)
        {
            var builder = new ContainerBuilder();

            builder.RegisterInstance(new CoinName(coinName));
            builder.RegisterInstance(settings);
            builder.RegisterType <SimpleTangleAccessor>().As <ITangleAccessor>().InstancePerLifetimeScope();
            builder.RegisterType <SimpleDataAccessor>().As <IDataAccessor>().InstancePerLifetimeScope();
            builder.RegisterType <SimpleConsensus>().As <IConsensus>().InstancePerLifetimeScope();

            builder.RegisterType <IXICore>().AsSelf().InstancePerLifetimeScope();

            var container = builder.Build();

            using (var scope = container.BeginLifetimeScope())
            {
                return(scope.Resolve <IXICore>());
            }
        }
        public void Scenario(IXICore ixiCore)
        {
            //we need to create chainsettings first!
            ChainSettings cSett = new ChainSettings(1000, 0, 0, 2, 30, 1000, 5);

            //create genesis transaction
            Transaction genTrans = new Transaction("ME", -1, Utils.GetTransactionPoolAddress(0, _coinName));

            genTrans.SetGenesisInformation(cSett)
            .Final(_settings)
            .Upload();

            //create genesis block
            Block genBlock = new Block(0, Utils.GenerateRandomString(81), _coinName);

            genBlock.Add(genTrans)
            .Final(_settings)
            .GenerateProofOfWork(ixiCore)
            .Upload();

            var result0 = ixiCore.DownloadChain(genBlock.SendTo, genBlock.Hash);

            result0.Should().NotBeNull();
            result0.Should().Be(genBlock);

            Console.WriteLine("=============================================================\n\n");
            //now creating block height 1

            //get pool addr
            string poolAddr = Utils.GetTransactionPoolAddress(1, _coinName, cSett.TransactionPoolInterval);

            //upload simple transaction on 1. block
            Transaction simpleTrans = new Transaction(_settings.PublicKey, 1, poolAddr);

            simpleTrans.AddFee(0)
            .Final(_settings)
            .Upload();

            //add smartcontract
            Smartcontract smart = CreateSmartcontract("cool contract", poolAddr)
                                  .Final(_settings)
                                  .Upload();

            Block block1 = new Block(genBlock.Height + 1, genBlock.NextAddress, _coinName);

            block1.Add(simpleTrans)
            .Add(smart)
            .Final(_settings)
            .GenerateProofOfWork(ixiCore)
            .Upload();

            var result1 = ixiCore.DownloadChain(block1.SendTo, block1.Hash);

            result1.Should().NotBeNull();
            result1.Should().Be(block1);

            Console.WriteLine("=============================================================\n\n");

            //now creating second block to trigger stuff!
            Transaction triggerTrans = new Transaction(_settings.PublicKey, 2, poolAddr);

            triggerTrans.AddFee(0)
            .AddOutput(100, smart.ReceivingAddress)
            .AddData("PayIn")
            .AddData("Str_0x14D57d59E7f2078A2b8dD334040C10468D2b5ddF")
            .Final(_settings)
            .Upload();

            Block block2 = new Block(2, block1.NextAddress, _coinName);

            block2.Add(triggerTrans)
            .Final(_settings)
            .GenerateProofOfWork(ixiCore)
            .Upload();

            var result2 = ixiCore.DownloadChain(block2.SendTo, block2.Hash);

            result2.Should().NotBeNull();
            result2.Should().Be(block2);

            Console.WriteLine("=============================================================\n\n");

            //now we add another block and trigger smartcontract again!
            //first create transaction
            Transaction triggerTrans2 = new Transaction(_settings.PublicKey, 2, poolAddr);

            triggerTrans2.AddFee(0)
            .AddOutput(100, smart.ReceivingAddress)
            .AddData("PayIn")
            .AddData("Str_0x14D57d59E7f2078A2b8dD334040C10468D2b5ddF")
            .Final(_settings)
            .Upload();

            Block block3 = new Block(3, block2.NextAddress, _coinName);

            block3.Add(triggerTrans2)
            .Final(_settings)
            .GenerateProofOfWork(ixiCore)
            .Upload();

            var latest = ixiCore.DownloadChain(block3.SendTo, block3.Hash);

            latest.Should().NotBeNull();
            latest.Should().Be(block3);

            Console.WriteLine("=============================================================\n\n");

            var maybeSmartcontract = ixiCore.GetSmartcontract(smart.ReceivingAddress);

            Console.WriteLine("Coinname: " + _coinName);
            Console.WriteLine("GenesisAddress: " + genBlock.SendTo);
            Console.WriteLine("GenesisHash: " + genBlock.Hash);

            maybeSmartcontract.HasValue.Should().BeTrue();
            maybeSmartcontract.Value.Code.Variables.Values.Select(x => x.GetValueAs <string>()).Should().Contain("2");

            ixiCore.GetBalance(smart.ReceivingAddress).Should().Be(198);
            ixiCore.GetBalance("0x14D57d59E7f2078A2b8dD334040C10468D2b5ddF").Should().Be(2);
        }