Esempio n. 1
0
        // 创建一条区块链的顶层Actor对象
        public IActorRef CreateZoroSystem(UInt160 chainHash, Store store)
        {
            IActorRef system = ActorSystem.ActorOf(ZoroSystem.Props(store, chainHash), $"{chainHash.ToString()}");

            chainActors.TryAdd(chainHash, system);

            return(system);
        }
Esempio n. 2
0
 // 根据Hash字符串,获取对应的ZoroSystem对象
 public ZoroSystem GetZoroSystem(string hashString)
 {
     if (TryParseChainHash(hashString, out UInt160 chainHash))
     {
         ZoroSystem system = GetZoroSystem(chainHash);
         return(system);
     }
     return(null);
 }
Esempio n. 3
0
        public void StopRootSystem()
        {
            ZoroSystem system = GetZoroSystem(UInt160.Zero);

            if (system != null)
            {
                StopZoroSystem(UInt160.Zero);
                system.WaitingForStop(TimeSpan.FromSeconds(10));
            }
        }
Esempio n. 4
0
        // 注册应用链的ZoroSystem对象
        public void RegisterAppSystem(UInt160 chainHash, ZoroSystem chain)
        {
            AppChainState state = Blockchain.Root.Store.GetAppChains().TryGet(chainHash);

            if (state == null)
            {
                throw new InvalidOperationException();
            }

            appSystems[chainHash] = chain;
        }
Esempio n. 5
0
        private void FollowAppChain(Blockchain blockchain, string hashString)
        {
            UInt160 chainHash = UInt160.Parse(hashString);

            AppChainState state = blockchain.Store.GetAppChains().TryGet(chainHash);

            if (state != null)
            {
                string path = string.Format(Settings.Default.AppChains.Path, hashString);

                Store appStore = new LevelDBStore(Path.GetFullPath(path));

                ZoroSystem appSystem = new ZoroSystem(chainHash, appStore, ActorSystem);

                AppChainSystems[chainHash] = appSystem;

                appSystem.StartNode(state.TcpPort, state.WsPort);
            }
        }
Esempio n. 6
0
        public ZoroSystem(Store store, UInt160 chainHash)
        {
            ChainHash = chainHash;

            if (chainHash.Equals(UInt160.Zero))
            {
                if (root != null)
                {
                    throw new InvalidOperationException();
                }

                root = this;
            }
            else
            {
                ZoroChainSystem.Singleton.RegisterAppSystem(chainHash, this);
            }

            Blockchain  = Context.ActorOf(Ledger.Blockchain.Props(this, store, chainHash), "Blockchain");
            LocalNode   = Context.ActorOf(Network.P2P.LocalNode.Props(this, chainHash), "LocalNode");
            TaskManager = Context.ActorOf(Network.P2P.TaskManager.Props(this, chainHash), "TaskManager");
        }
Esempio n. 7
0
 public bool GetAppChainSystem(UInt160 chainHash, out ZoroSystem system)
 {
     return(AppChainSystems.TryGetValue(chainHash, out system));
 }
Esempio n. 8
0
 // 根据应用链的Hash,获取应用链的ZoroChain对象
 public bool GetAppSystem(UInt160 chainHash, out ZoroSystem chain)
 {
     return(appSystems.TryGetValue(chainHash, out chain));
 }