Skip to content

Commit

Permalink
Merge pull request #5 from dwyl/constants-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
LuchoTurtle authored Jun 22, 2023
2 parents 9b452a2 + 0a9d00d commit 36fb7ef
Show file tree
Hide file tree
Showing 6 changed files with 553 additions and 357 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ we would get access to the following info.
"code": 0x12,
"length": 32,
"digest": [165, 145, 166, 212, 11, 244, 32, 64, 74, 1, 23, 51, 207, 183, 177, 144, 214, 44, 101, 191, 11, 205, 163, 43, 87, 178, 119, 217, 173, 159, 20, 110],
"hashFunctionname": "sha2-256",
"name": "sha2-256",
}
```

Expand Down Expand Up @@ -90,7 +90,7 @@ how to improve this package,
don't hesitate and
[open an issue](https://github.com/dwyl/dart_multihash/issues).

# Recomended reading
# Recommended reading

If you are wanting to know more about Multihashing
why it is needed and how the format works,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/multihash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Multihash {
}

// Function convention info
HashFunctionConvention hashInfo = hashTable.firstWhere((obj) => obj.hashFunctionName == hashType);
Codec hashInfo = codecTable.firstWhere((obj) => obj.name == hashType);

// Check if length of digest is correctly defined.
length ??= digest.length;
Expand Down Expand Up @@ -62,8 +62,8 @@ class Multihash {
}

// Fetch name of hash function type referring to the code
String hashName = hashTable.firstWhere((obj) => obj.code == decodedCode.res).hashFunctionName;
String hashName = codecTable.firstWhere((obj) => obj.code == decodedCode.res).name;

return MultihashInfo(code: decodedCode.res, length: decodedLen.res, hashFunctionName: hashName, digest: bytes);
return MultihashInfo(code: decodedCode.res, length: decodedLen.res, name: hashName, digest: bytes);
}
}
Loading

0 comments on commit 36fb7ef

Please sign in to comment.