示例#1
0
 private static IEnumerable <TransactionInfo> GetTransactionInfo(IEnumerable <Transaction> transactions)
 {
     return(transactions.Select(p => new TransactionInfo
     {
         Transaction = CoreTransaction.DeserializeFrom(p.RawData),
         Height = p.Height,
         Time = p.Time
     }));
 }
示例#2
0
 public override IEnumerable <T> GetTransactions <T>()
 {
     using (WalletDataContext ctx = new WalletDataContext(DbPath))
     {
         IQueryable <Transaction> transactions = ctx.Transactions;
         if (typeof(T).GetTypeInfo().IsSubclassOf(typeof(CoreTransaction)))
         {
             TransactionType type = (TransactionType)Enum.Parse(typeof(TransactionType), typeof(T).Name);
             transactions = transactions.Where(p => p.Type == type);
         }
         return(transactions.Select(p => p.RawData).ToArray().Select(p => (T)CoreTransaction.DeserializeFrom(p)));
     }
 }
示例#3
0
文件: Block.cs 项目: apvglobal/APV
 /// <summary>
 /// 反序列化
 /// </summary>
 /// <param name="reader">数据来源</param>
 public override void Deserialize(BinaryReader reader)
 {
     base.Deserialize(reader);
     Transactions = new Transaction[reader.ReadVarInt(0x10000)];
     if (Transactions.Length == 0)
     {
         throw new FormatException();
     }
     for (int i = 0; i < Transactions.Length; i++)
     {
         Transactions[i] = Transaction.DeserializeFrom(reader);
     }
     if (MerkleTree.ComputeRoot(Transactions.Select(p => p.Hash).ToArray()) != MerkleRoot)
     {
         throw new FormatException();
     }
 }