예제 #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);
        }
예제 #2
0
 // 根据Hash字符串,获取对应的ZoroSystem对象
 public ZoroSystem GetZoroSystem(string hashString)
 {
     if (TryParseChainHash(hashString, out UInt160 chainHash))
     {
         ZoroSystem system = GetZoroSystem(chainHash);
         return(system);
     }
     return(null);
 }
예제 #3
0
        public void StopRootSystem()
        {
            ZoroSystem system = GetZoroSystem(UInt160.Zero);

            if (system != null)
            {
                StopZoroSystem(UInt160.Zero);
                system.WaitingForStop(TimeSpan.FromSeconds(10));
            }
        }
예제 #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;
        }
예제 #5
0
파일: ZoroSystem.cs 프로젝트: ProDog/Zoro
        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);
            }
        }
예제 #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");
        }
예제 #7
0
파일: ZoroSystem.cs 프로젝트: ProDog/Zoro
 public bool GetAppChainSystem(UInt160 chainHash, out ZoroSystem system)
 {
     return(AppChainSystems.TryGetValue(chainHash, out system));
 }
예제 #8
0
 // 根据应用链的Hash,获取应用链的ZoroChain对象
 public bool GetAppSystem(UInt160 chainHash, out ZoroSystem chain)
 {
     return(appSystems.TryGetValue(chainHash, out chain));
 }