Esempio n. 1
0
        /// <summary>
        ///     Get all Candidate update records in a chain
        /// </summary>
        /// <param name="chainId"></param>
        /// <param name="pubKey">The public key to verify the data with</param>
        /// <returns></returns>
        public static List <CandidateUpdatedRecord> GetCandidateUpdatedRecords(byte[] chainId, RSAParameters pubKey)
        {
            var entries     = Chain.GetAllChainEntries(chainId);
            var entriesData = entries.Select(e => Entry.GetEntryData(e).Content).ToList();
            var records     = new List <CandidateUpdatedRecord>();

            foreach (var data in entriesData)
            {
                if (Bytes.StartsWith(data, CandidateUpdatedRecord.UpdatedRecordPrefix))
                {
                    records.Add(CandidateUpdatedRecord.Unpack(data, pubKey));
                }
            }
            return(records);
        }
Esempio n. 2
0
        /// <summary>
        ///     Gets the candidates packed bytes from the specified chain
        /// </summary>
        /// <param name="chainId">The id of the chain to get the candidate data from</param>
        /// <returns>The packed candidate data</returns>
        public static byte[] GetPackedCandidate(byte[] chainId)
        {
            var entries     = Chain.GetAllChainEntries(chainId);
            var entriesData = entries.Select(e => Entry.GetEntryData(e).Content).ToList();
            var segments    = new List <DataSegment>();

            foreach (var data in entriesData)
            {
                if (Bytes.StartsWith(data, DataSegment.DataSegmentPrefix))
                {
                    segments.Add(DataSegment.Unpack(data));
                }
            }
            return(DataSegment.Desegmentize(segments));
        }