示例#1
0
        public async Task <AccountHeightAPIResult> GetAccountHeight(string AccountId, string Signature)
        {
            var result = new AccountHeightAPIResult();

            if (!await VerifyClientAsync(AccountId, Signature))
            {
                result.ResultCode = APIResultCodes.APISignatureValidationFailed;
                return(result);
            }
            try
            {
                if (await BlockChain.Singleton.AccountExistsAsync(AccountId))
                {
                    result.Height     = (await BlockChain.Singleton.FindLatestBlockAsync(AccountId)).Height;
                    result.NetworkId  = Neo.Settings.Default.LyraNode.Lyra.NetworkId;
                    result.SyncHash   = (await BlockChain.Singleton.GetLastConsolidationBlockAsync()).Hash;
                    result.ResultCode = APIResultCodes.Success;
                }
                else
                {
                    result.ResultCode = APIResultCodes.AccountDoesNotExist;
                }
            }
            catch (Exception)
            {
                result.ResultCode = APIResultCodes.UnknownError;
            }
            return(result);
        }
示例#2
0
        public async Task <AccountHeightAPIResult> GetSyncHeight()
        {
            var result = new AccountHeightAPIResult();

            try
            {
                var last_svc_block = await BlockChain.Singleton.GetLastServiceBlockAsync();

                //if(last_svc_block == null)
                //{
                //    // empty database.
                //    throw new Exception("Database empty.");
                //}
                result.Height     = last_svc_block == null ? 0 : last_svc_block.Height;
                result.SyncHash   = last_svc_block == null ? "" : last_svc_block.Hash;
                result.NetworkId  = Neo.Settings.Default.LyraNode.Lyra.NetworkId;
                result.ResultCode = APIResultCodes.Success;
            }
            catch (Exception ex)
            {
                result.ResultCode    = APIResultCodes.UnknownError;
                result.ResultMessage = ex.Message;
            }
            return(result);
        }
示例#3
0
        public Task <AccountHeightAPIResult> GetSyncHeight()
        {
            var result = new AccountHeightAPIResult();

            try
            {
                var last_sync_block = BlockChain.Singleton.GetSyncBlock();
                if (last_sync_block == null)
                {
                    // empty database.
                    throw new Exception("Database empty.");
                }
                result.Height     = last_sync_block.Index;
                result.SyncHash   = last_sync_block.Hash;
                result.NetworkId  = Neo.Settings.Default.LyraNode.Lyra.NetworkId;
                result.ResultCode = APIResultCodes.Success;
            }
            catch (Exception e)
            {
                result.ResultCode = APIResultCodes.UnknownError;
            }
            return(Task.FromResult(result));
        }
示例#4
0
        public Task <AccountHeightAPIResult> GetAccountHeight(string AccountId, string Signature)
        {
            var result = new AccountHeightAPIResult();

            try
            {
                if (BlockChain.Singleton.AccountExists(AccountId))
                {
                    result.Height     = BlockChain.Singleton.FindLatestBlock(AccountId).Index;
                    result.NetworkId  = Neo.Settings.Default.LyraNode.Lyra.NetworkId;
                    result.SyncHash   = BlockChain.Singleton.GetSyncBlock().Hash;
                    result.ResultCode = APIResultCodes.Success;
                }
                else
                {
                    result.ResultCode = APIResultCodes.AccountDoesNotExist;
                }
            }
            catch (Exception e)
            {
                result.ResultCode = APIResultCodes.UnknownError;
            }
            return(Task.FromResult(result));
        }