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); }
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); }
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)); }
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)); }