Пример #1
0
        public override void Awake(JToken jd = null)
        {
            try
            {
                transferShow = jd["transferShow"] != null;
                Log.Info($"Consensus.transferShow = {transferShow}");

                if (jd["Run"] != null)
                {
                    bool.TryParse(jd["Run"].ToString(), out bRun);
                }

                if (jd["height"] != null)
                {
                    long height = long.Parse(jd["height"].ToString());
                    long.TryParse(levelDBStore.Get("UndoHeight"), out long height_total);
                    while (height_total > height)
                    {
                        height_total = Math.Max(height_total - 100, height);
                        levelDBStore.UndoTransfers(height_total);
                        Log.Debug($"UndoTransfers height = {height_total}");
                    }
                }

                string aa = BigInt.Div("1000,1000", "1000");
            }
            catch (Exception)
            {
            }
        }
Пример #2
0
        public void OnStats(HttpMessage httpMessage)
        {
            if (!GetParam(httpMessage, "1", "style", out string style))
            {
                style = "";
            }

            string  address = Wallet.GetWallet().GetCurWallet().ToAddress();
            Account account = null;

            using (DbSnapshot dbSnapshot = Entity.Root.GetComponent <LevelDBStore>().GetSnapshot(0))
            {
                account = dbSnapshot.Accounts.Get(address);
            }

            var amount = account != null?BigInt.Div(account.amount, "10000").ToString() : "0";

            long.TryParse(Entity.Root.GetComponent <LevelDBStore>().Get("UndoHeight"), out long UndoHeight);
            long   PoolHeight = Entity.Root.GetComponent <Rule>().height;
            string power1     = Entity.Root.GetComponent <Rule>().calculatePower.GetPower();
            string power2     = Entity.Root.GetComponent <Consensus>().calculatePower.GetPower();

            int NodeCount = Entity.Root.GetComponent <NodeManager>().GetNodeCount();

            if (style == "")
            {
                httpMessage.result = $"      AlppyHeight: {UndoHeight}\n" +
                                     $"       PoolHeight: {PoolHeight}\n" +
                                     $"  Calculate Power: {power1} of {power2}\n" +
                                     $"          Account: {address}, {amount}\n" +
                                     $"             Node: {NodeCount}";
            }
            else
            {
                httpMessage.result = $"H:{UndoHeight} P:{power2}";
            }
        }
Пример #3
0
        public void OnAccount(HttpMessage httpMessage)
        {
            if (!GetParam(httpMessage, "1", "Address", out string address))
            {
                httpMessage.result = "command error! \nexample: account address";
                return;
            }

            using (DbSnapshot dbSnapshot = Entity.Root.GetComponent <LevelDBStore>().GetSnapshot(0))
            {
                Account account = dbSnapshot.Accounts.Get(address);
                if (account != null)
                {
                    httpMessage.result = $"          Account: {account.address}, amount:{BigInt.Div(account.amount , "10000")} , index:{account.index}";
                }
                else
                {
                    httpMessage.result = $"          Account: {address}, amount:0 , index:0";
                }
            }
        }