Пример #1
0
 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());
     }
 }
Пример #2
0
 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));
     }
 }
Пример #3
0
 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));
     }
 }
Пример #4
0
 public static bool TryReadSignedLedger(GetSignedLedgerResponse response, out SignedLedger signed)
 {
     try
     {
         signed = LedgerCompressionEngine.ReadZippedLedger(Convert.FromBase64String(response.Ledger));
     }
     catch
     {
         signed = null;
         return(false);
     }
     return(true);
 }
Пример #5
0
        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());
            }
        }
Пример #6
0
 public SignedLedger GetLedgerFromRaw(long height)
 {
     return(LedgerCompressionEngine.ReadZippedLedger(GetRawLedger(height)));
 }