Skip to content

Commit

Permalink
Merge pull request #9 from DarkLord017/fix/Implement-config-utils-go-#6
Browse files Browse the repository at this point in the history
Implemented-utils-go-#6
  • Loading branch information
star-gazer111 authored Aug 25, 2024
2 parents 3bfd432 + 4d5e093 commit c89be79
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions config/utils.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
package config

import (
"encoding/hex"
"encoding/json"

func bytes_serialise(){
"github.com/BlocSoc-iitr/selene/common"
)

func bytes_serialise(bytes []byte) ([]byte, error) {

if bytes == nil {
return json.Marshal(nil)
}
bytesString := hex.EncodeToString(bytes)
result, err := json.Marshal(bytesString)
if err != nil {
return nil, err
}
return result, nil

}

func bytes_deserialise(data []byte) ([]byte, error) {
var bytesOpt *string
if err := json.Unmarshal(data, &bytesOpt); err != nil {
return nil, err
}

if bytesOpt == nil {
return nil, nil
} else {
bytes, err := common.Hex_str_to_bytes(*bytesOpt)
if err != nil {
return nil, err
}
return bytes, nil
}

}
func bytes_deserialise(){

}

0 comments on commit c89be79

Please sign in to comment.