(r io.Reader)
| 83 | } |
| 84 | |
| 85 | func (this *ExportBlockMetadata) Deserialize(r io.Reader) error { |
| 86 | metadata := make([]byte, EXPORT_BLOCK_METADATA_LEN, EXPORT_BLOCK_METADATA_LEN) |
| 87 | _, err := io.ReadFull(r, metadata) |
| 88 | if err != nil { |
| 89 | return err |
| 90 | } |
| 91 | if metadata[0] != EXPORT_BLOCK_METADATA_VERSION { |
| 92 | return fmt.Errorf("version unmatch") |
| 93 | } |
| 94 | reader := bytes.NewBuffer(metadata) |
| 95 | ver, err := serialization.ReadByte(reader) |
| 96 | if err != nil { |
| 97 | return err |
| 98 | } |
| 99 | this.Version = ver |
| 100 | compressType, err := serialization.ReadByte(reader) |
| 101 | if err != nil { |
| 102 | return err |
| 103 | } |
| 104 | this.CompressType = compressType |
| 105 | height, err := serialization.ReadUint32(reader) |
| 106 | if err != nil { |
| 107 | return err |
| 108 | } |
| 109 | this.StartBlockHeight = height |
| 110 | height, err = serialization.ReadUint32(reader) |
| 111 | if err != nil { |
| 112 | return err |
| 113 | } |
| 114 | this.EndBlockHeight = height |
| 115 | return nil |
| 116 | } |
| 117 | |
| 118 | func CompressBlockData(data []byte, compressType byte) ([]byte, error) { |
| 119 | switch compressType { |
no test coverage detected