コード例 #1
0
ファイル: BlockChain.cs プロジェクト: wizd/LyraNetwork
        public BlockChain(LyraSystem sys)
        {
            if (Singleton != null)
            {
                throw new Exception("Blockchain reinitialization");
            }

            _sys = sys;

            _stateMachine                   = new StateMachine <BlockChainState, BlockChainTrigger>(BlockChainState.Initializing);
            _engageTriggerStartupSync       = _stateMachine.SetTriggerParameters <long>(BlockChainTrigger.ConsensusNodesSynced);
            _engageTriggerConsolidateFailed = _stateMachine.SetTriggerParameters <string>(BlockChainTrigger.LocalNodeOutOfSync);
            CreateStateMachine();

            var nodeConfig = Neo.Settings.Default.LyraNode;

            _store = new MongoAccountCollection();

            //_store = new LiteAccountCollection(Utilities.LyraDataDir);
            _log        = new SimpleLogger("BlockChain").Logger;
            _nodeConfig = nodeConfig;
            NetworkID   = nodeConfig.Lyra.NetworkId;

            Singleton = this;
        }
コード例 #2
0
        public void TestSetup()
        {
            SimpleLogger.Factory = new NullLoggerFactory();

            var probe = CreateTestProbe();
            var ta    = new TestAuthorizer(probe);

            sys = ta.TheDagSystem;
            sys.StartConsensus();
            store = ta.TheDagSystem.Storage;

            af = new AuthorizersFactory();
            af.Init();

            //p2pStacks = new TestProbe[NodesCount];
            //authorizers = new TestAuthorizer[NodesCount];
            //for(int i = 0; i < NodesCount; i++)
            //{
            //    p2pStacks[i] = CreateTestProbe();
            //    authorizers[i] = new TestAuthorizer(p2pStacks[i]);

            //    p2pStacks[i].SetAutoPilot(new DelegateAutoPilot((sender, message) =>
            //    {
            //        var msg = message as LocalNode.SignedMessageRelay;
            //        if (msg != null)
            //        {
            //            // foreach dagsys sender not same tell it
            //        }
            //        sender.Tell(message, ActorRefs.NoSender);
            //        return AutoPilot.KeepRunning;
            //    }));
            //}
        }
コード例 #3
0
        public NodeService(ILogger <NodeService> logger, IHostEnv hostEnv, IAccountCollectionAsync store,
                           IHubContext <LyraEventHub, ILyraEvent> lyraEventContext)
        {
            //if (Instance == null)
            //    Instance = this;
            //else
            //    throw new InvalidOperationException("Should not do this");

            _log              = logger;
            _hostEnv          = hostEnv;
            _store            = store;
            _lyraEventContext = lyraEventContext;
        }
コード例 #4
0
        public BlockChain(DagSystem sys, IAccountCollectionAsync store)
        {
            _sys = sys;

            var nodeConfig = Neo.Settings.Default.LyraNode;

            _store = store; //new MongoAccountCollection();

            //_store = new LiteAccountCollection(Utilities.LyraDataDir);
            _log        = new SimpleLogger("BlockChain").Logger;
            _nodeConfig = nodeConfig;
            NetworkID   = nodeConfig.Lyra.NetworkId;

            Receive <Startup>(_ => { });
            Receive <Idle>(_ => { });
        }
コード例 #5
0
        public void Init(AuthorizersFactory af, IAccountCollectionAsync store)
        {
            if (DynWorkFlows != null)
            {
                return;
            }
            //throw new InvalidOperationException("Already initialized.");

            DynWorkFlows = new Dictionary <string, IDebiWorkFlow>();
            //Bps = new ConcurrentDictionary<string, BrokerBlueprint>();

            foreach (var type in GetTypesWithMyAttribute(Assembly.GetExecutingAssembly()))
            {
                var lyrawf = (WorkFlowBase)Activator.CreateInstance(type);
                AddWorkFlow(af, store, lyrawf);
            }
        }
コード例 #6
0
        //public static ConcurrentDictionary<string, BrokerBlueprint> Bps { get; set; }

        //public static event Action<BrokerBlueprint> OnFinished;

        private void AddWorkFlow(AuthorizersFactory af, IAccountCollectionAsync store, WorkFlowBase workflow)
        {
            var desc = workflow.GetDescription();

            DynWorkFlows.Add(desc.Action, workflow);

            //if(desc.Blocks != null)
            //foreach(var bd in desc.Blocks)
            //{
            //    //if (bd.AuthorizerType != null)
            //    //    af.Register(bd.BlockType, bd.AuthorizerType);

            //    if (bd.TheBlock != null)
            //    {
            //        store?.Register(bd.TheBlock);
            //    }
            //}
        }
コード例 #7
0
ファイル: BlockChain.cs プロジェクト: bluetsys/LyraNetwork
        public BlockChain(LyraSystem sys)
        {
            if (Singleton != null)
            {
                throw new Exception("Blockchain reinitialization");
            }

            _sys = sys;

            var nodeConfig = Neo.Settings.Default.LyraNode;

            _store      = new MongoAccountCollection();
            _log        = new SimpleLogger("BlockChain").Logger;
            _nodeConfig = nodeConfig;
            NetworkID   = nodeConfig.Lyra.NetworkId;

            Singleton = this;
        }
コード例 #8
0
        public DagSystem(IHostEnv hostEnv, IAccountCollectionAsync store, IHubContext <LyraEventHub, ILyraEvent> hub, Wallet posWallet, IActorRef localNode)
        {
            _hostEnv    = hostEnv;
            _log        = new SimpleLogger("DagSystem").Logger;
            FullStarted = false;
            _hub        = hub;

            Storage   = new TracedStorage(store);
            PosWallet = posWallet;

            LocalNode = localNode;
            this.LocalNode.Tell(this);

            if (hostEnv != null)     // for unit test
            {
                TheBlockchain = ActorSystem.ActorOf(BlockChain.Props(this, Storage));
                TaskManager   = ActorSystem.ActorOf(Neo.Network.P2P.TaskManager.Props(this));

                //TradeEngine = new TradeMatchEngine(Storage);
            }

            Singleton = this;
        }
コード例 #9
0
 public static Props Props(DagSystem system, IAccountCollectionAsync store)
 {
     return(Akka.Actor.Props.Create(() => new BlockChain(system, store)).WithMailbox("blockchain-mailbox"));
 }
コード例 #10
0
 public TracedStorage(IAccountCollectionAsync store)
 {
     _store = store;
 }