示例#1
0
        public static EntryBlockDataStringFormat ConvertByteFormatToStringFormat(EntryBlockData block)
        {
            var blockStringFormat = new EntryBlockDataStringFormat();
            var len = block.EntryList.Length;
            blockStringFormat.EntryList = new EntryBlockDataStringFormat.EntryData[len];

            for (var i = 0; i < len; i++) {
                blockStringFormat.EntryList[i] = new EntryBlockDataStringFormat.EntryData {
                    EntryHash = Arrays.ByteArrayToHex(block.EntryList[i].EntryHash),
                    Timestamp = block.EntryList[i].Timestamp
                };
            }

            blockStringFormat.Header.BlockSequenceNumber = block.Header.BlockSequenceNumber;
            blockStringFormat.Header.ChainId = Arrays.ByteArrayToHex(block.Header.ChainId);
            blockStringFormat.Header.PrevKeyMr = Arrays.ByteArrayToHex(block.Header.PrevKeyMr);
            blockStringFormat.Header.Timestamp = block.Header.Timestamp;

            return blockStringFormat;
        }
示例#2
0
        public static EntryBlockData ConvertStringFormatToByteFormat(EntryBlockDataStringFormat blockStringFormat)
        {
            var block = new EntryBlockData {Header = new EntryBlockData.HeaderData()};

            var len = blockStringFormat.EntryList.Length;
            block.EntryList = new EntryBlockData.EntryData[len];

            for (var i = 0; i < len; i++) {
                block.EntryList[i] = new EntryBlockData.EntryData {
                    EntryHash = Strings.DecodeHexIntoBytes(blockStringFormat.EntryList[i].EntryHash),
                    Timestamp = blockStringFormat.EntryList[i].Timestamp
                };
            }

            block.Header.BlockSequenceNumber = blockStringFormat.Header.BlockSequenceNumber;
            block.Header.ChainId = Strings.DecodeHexIntoBytes(blockStringFormat.Header.ChainId);
            block.Header.PrevKeyMr = Strings.DecodeHexIntoBytes(blockStringFormat.Header.PrevKeyMr);
            block.Header.Timestamp = blockStringFormat.Header.Timestamp;

            return block;
        }