This commit is contained in:
0xmuralik
2022-10-17 11:55:19 +05:30
parent d35d3c0716
commit ec3e8f7ce3
5 changed files with 14 additions and 12 deletions
+1 -2
View File
@@ -36,7 +36,6 @@ func GenerateHash(json map[string]interface{}) (string, []byte, error) {
return "", nil, err
}
//cid, err := CIDFromJSONBytes(content)
cidString, err := CIDFromJSONBytesUsingIpldPrime(content)
if err != nil {
return "", nil, err
@@ -81,7 +80,7 @@ func CIDFromJSONBytesUsingIpldPrime(content []byte) (string, error) {
// This gathers together any parameters that might be needed when making a link.
// (For CIDs, the version, the codec, and the multihash type are all parameters we'll need.)
// Often, you can probably make this a constant for your whole application.
lp := cidlink.LinkPrototype{Prefix: cid.Prefix{
lp := cidlink.LinkPrototype{Prefix: cid.Prefix{ //nolint:golint
Version: 1, // Usually '1'.
Codec: 0x71, // 0x71 means "dag-cbor" -- See the multicodecs table: https://github.com/multiformats/multicodec/
MhType: 0x12, // 0x12 means "sha2-256" -- See the multicodecs table: https://github.com/multiformats/multicodec/
+1 -1
View File
@@ -16,7 +16,7 @@ func GenerateMnemonic() (string, error) {
return "", err
}
mnemonic, err := bip39.NewMnemonic(entropySeed[:])
mnemonic, err := bip39.NewMnemonic(entropySeed)
if err != nil {
return "", err
}
+6 -3
View File
@@ -12,10 +12,13 @@ import (
set "github.com/deckarep/golang-set"
)
func Int64ToBytes(num int64) []byte {
func Int64ToBytes(num int64) ([]byte, error) {
buf := new(bytes.Buffer)
binary.Write(buf, binary.BigEndian, num)
return buf.Bytes()
if err := binary.Write(buf, binary.BigEndian, num); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func SetToSlice(set set.Set) []string {