// ////////////////////////////////////// /// <summary> /// Update not allowed for Close History. /// </summary> /// <param name="ledgerCloseData"></param> /// <returns></returns> public DBResponse AddUpdate(LedgerCloseData ledgerCloseData) { SQLiteTransaction st = sqliteConnection.BeginTransaction(); DBResponse resp = AddUpdate(ledgerCloseData, st); st.Commit(); return resp; }
public JS_LedgerInfo(LedgerCloseData ledgerCloseData) { Hash = ledgerCloseData.LedgerHash; TotalTransactions = ledgerCloseData.TotalTransactions; Transactions = ledgerCloseData.Transactions; CloseTimeLong = ledgerCloseData.CloseTime; CloseTime = DateTime.FromFileTimeUtc(ledgerCloseData.CloseTime); SequenceNumber = ledgerCloseData.SequenceNumber; }
public RootDataResponse(ListTreeNode root, LedgerCloseData ledgerCloseData) { RootHash = root.Hash; LeafCount = root.LeafCount; LedgerCloseData = ledgerCloseData; Children = new NodeDataEntity[16]; for (int i = 0; i < 16; i++) { ListTreeNode LTN = root.Children[i]; if(LTN != null) Children[i] = new NodeDataEntity(LTN); } }
private void Init() { RootHash = new Hash(); LeafCount = 0; LedgerCloseData = new LedgerCloseData(); Children = new NodeDataEntity[16]; }
public DBResponse AddUpdate(LedgerCloseData ledgerCloseData, DbTransaction transaction) { bool doUpdate = false; using (SQLiteCommand cmd = new SQLiteCommand("SELECT LedgerHash FROM LedgerInfo WHERE LedgerHash = @ledgerHash;", sqliteConnection, (SQLiteTransaction)transaction)) { cmd.Parameters.Add(new SQLiteParameter("@ledgerHash", ledgerCloseData.LedgerHash)); using (SQLiteDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { doUpdate = true; // Perform update as the entry already exists. } } } DBResponse response = DBResponse.Exception; if (doUpdate) { // ///////////// Perform the UPDATE /////////////// /* using (SQLiteCommand cmd = new SQLiteCommand("UPDATE LedgerInfo SET SequenceNumber = @sequenceNumber, Transactions = @transactions, TotalTransactions = @totalTransactions, CloseTime=@closeTime WHERE LedgerHash = @ledgerHash;", sqliteConnection, (SQLiteTransaction)transaction)) { cmd.Parameters.Add(new SQLiteParameter("@sequenceNumber", ledgerCloseData.SequenceNumber)); cmd.Parameters.Add(new SQLiteParameter("@ledgerHash", ledgerCloseData.LedgerHash)); cmd.Parameters.Add(new SQLiteParameter("@transactions", ledgerCloseData.Transactions)); cmd.Parameters.Add(new SQLiteParameter("@totalTransactions", ledgerCloseData.TotalTransactions)); cmd.Parameters.Add(new SQLiteParameter("@closeTime", ledgerCloseData.CloseTime)); if (cmd.ExecuteNonQuery() != 1) { response = DBResponse.UpdateFailed; } else { response = DBResponse.UpdateSuccess; } }*/ } else { // ///////////// Perform the INSERT /////////////// using (SQLiteCommand cmd = new SQLiteCommand("INSERT INTO LedgerInfo VALUES(@sequenceNumber, @ledgerHash, @transactions, @totalTransactions, @closeTime);", sqliteConnection, (SQLiteTransaction)transaction)) { cmd.Parameters.Add(new SQLiteParameter("@sequenceNumber", ledgerCloseData.SequenceNumber)); cmd.Parameters.Add(new SQLiteParameter("@ledgerHash", ledgerCloseData.LedgerHash)); cmd.Parameters.Add(new SQLiteParameter("@transactions", ledgerCloseData.Transactions)); cmd.Parameters.Add(new SQLiteParameter("@totalTransactions", ledgerCloseData.TotalTransactions)); cmd.Parameters.Add(new SQLiteParameter("@closeTime", ledgerCloseData.CloseTime)); if (cmd.ExecuteNonQuery() != 1) { response = DBResponse.InsertFailed; } else { response = DBResponse.InsertSuccess; } } } return response; }
public bool GetLastRowData(out LedgerCloseData lastCloseData) { bool _found = false; lastCloseData = new LedgerCloseData(); using (SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM LedgerInfo ORDER BY SequenceNumber DESC LIMIT 1;", sqliteConnection)) { using (SQLiteDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { if (reader.Read()) { lastCloseData.SequenceNumber = (long)reader[0]; lastCloseData.LedgerHash = (byte[])reader[1]; lastCloseData.Transactions = (long)reader[2]; lastCloseData.TotalTransactions = (long)reader[3]; lastCloseData.CloseTime = (long)reader[4]; _found = true; } } } } return _found; }
//////////////////////// public DBResponse FetchLCL(out LedgerCloseData ledgerCloseData, long sequenceNumber) { DBResponse response = DBResponse.FetchFailed; using (SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM LedgerInfo WHERE SequenceNumber = @sequenceNumber;", sqliteConnection)) { cmd.Parameters.Add(new SQLiteParameter("@sequenceNumber", sequenceNumber)); using (SQLiteDataReader reader = cmd.ExecuteReader()) { ledgerCloseData = new LedgerCloseData(); if (reader.HasRows) { if (reader.Read()) { ledgerCloseData.SequenceNumber = (long)reader[0]; ledgerCloseData.LedgerHash = (byte[])reader[1]; ledgerCloseData.Transactions = (long)reader[2]; ledgerCloseData.TotalTransactions = (long)reader[3]; ledgerCloseData.CloseTime = (long)reader[4]; response = DBResponse.FetchSuccess; } } } } return response; }