CoalesceVersion resolves a block encoding version from a chain of version strings ordered lowest to highest priority. Empty strings are skipped. Falls back to DefaultEncoding if all are empty. Returns the validated VersionedEncoding suitable for writes.
(versions ...string)
| 138 | // Falls back to DefaultEncoding if all are empty. |
| 139 | // Returns the validated VersionedEncoding suitable for writes. |
| 140 | func CoalesceVersion(versions ...string) (VersionedEncoding, error) { |
| 141 | ver := DefaultEncoding().Version() |
| 142 | for _, v := range versions { |
| 143 | if v != "" { |
| 144 | ver = v |
| 145 | } |
| 146 | } |
| 147 | return FromVersionForWrites(ver) |
| 148 | } |
| 149 | |
| 150 | // CopyBlock from one backend to another. It automatically chooses the encoding for the given block. |
| 151 | func CopyBlock(ctx context.Context, meta *backend.BlockMeta, from backend.Reader, to backend.Writer) error { |