public List <SignedLedger> GetLedgersFromHeight(long startHeight) { using (var entities = new BlockchainEntities()) { var rawLedgers = entities.ledgers.Where(_ => _.height >= startHeight).ToList(); return(rawLedgers.Select(_ => LedgerCompressionEngine.ReadZippedLedger(_.raw)).ToList()); } }
public SignedLedger GetLastLedgerFromRaw() { using (var entities = new BlockchainEntities()) { var max = entities.ledgers.OrderByDescending(ledger => ledger.height).FirstOrDefault(); Debug.Assert(max == null || max.raw != null && max.raw.Length != 0); return(LedgerCompressionEngine.ReadZippedLedger(max?.raw)); } }
public SignedLedger GetLedgerByHash(LedgerHash hash) { using (var entities = new BlockchainEntities()) { var ledger = entities.ledgers.FirstOrDefault(_ => _.hash == hash.Bytes); var raw = ledger?.raw; return(LedgerCompressionEngine.ReadZippedLedger(raw)); } }
public static bool TryReadSignedLedger(GetSignedLedgerResponse response, out SignedLedger signed) { try { signed = LedgerCompressionEngine.ReadZippedLedger(Convert.FromBase64String(response.Ledger)); } catch { signed = null; return(false); } return(true); }
public List <SignedLedgerState> GetLedgersWithStateFromHeight(long startHeight) { using (var entities = new BlockchainEntities()) { var rawLedgers = entities.ledgers.Where(_ => _.height >= startHeight).ToList(); var readedLedgers = rawLedgers.Select(_ => LedgerCompressionEngine.ReadZippedLedger(_.raw)); var rawStateChanges = entities.ledgerstatechanges.Where(_ => _.ledger_height >= startHeight).ToList(); var readedStateChanges = rawStateChanges.Select(_ => ReadStateChange(_.ledger_height, _.raw)); var results = from ledger in readedLedgers join state in readedStateChanges on ledger.Ledger.LedgerLight.Height equals state.Item1 select new SignedLedgerState(ledger, state.Item2); return(results.ToList()); } }
public SignedLedger GetLedgerFromRaw(long height) { return(LedgerCompressionEngine.ReadZippedLedger(GetRawLedger(height))); }