Skip to content

Commit 4874d0b

Browse files
committed
Minor improvements
1 parent d5ccb59 commit 4874d0b

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ byte[] decoded = decoder.decode(encoded);
5656

5757
/* or check if encoding is supported */
5858
byte[] decoded = decoder.getCodec(encoded)
59-
.map(codec -> codec.decode(encoded))
60-
.orElseThrow(() -> new IllegalArgumentException("Unsupported codec."));
59+
.map(codec -> codec.decode(encoded))
60+
.orElseThrow(() -> new IllegalArgumentException("Unsupported codec."));
6161

6262
/* or directly when only one codec is supported */
6363
byte[] decoded = KeyCodec.P521_PUBLIC_KEY.decode(encoded);

src/main/java/com/apicatalog/multihash/Multihash.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,18 @@ public byte[] decode(byte[] encoded, int index, int length) {
215215
"The requested decode length (" + length + ") is greater than the available bytes (" + (encoded.length - index) + ").");
216216
}
217217

218-
long size = digestLength(encoded, index, length);
219-
int sizeVarintLength = UVarInt.byteLength(size);
218+
long digestLength = digestLength(encoded, index, length);
219+
int varintDigestLength = UVarInt.byteLength(digestLength);
220220

221-
if (size != (length - codeVarint.length - sizeVarintLength)) {
221+
if (digestLength != (length - codeVarint.length - varintDigestLength)) {
222222
throw new IllegalArgumentException(
223-
"Digest size mismatch: declared size is " + size + " bytes, but the actual digest size is " +
224-
(length - codeVarint.length - sizeVarintLength) + " bytes.");
223+
"Digest size mismatch: declared size is " + digestLength + " bytes, but the actual digest size is " +
224+
(length - codeVarint.length - varintDigestLength) + " bytes.");
225225
}
226226

227227
// Extract digest
228228
return Arrays.copyOfRange(encoded,
229-
index + codeVarint.length + sizeVarintLength,
229+
index + codeVarint.length + varintDigestLength,
230230
length + index);
231231
}
232232

0 commit comments

Comments
 (0)