Skip to content
Snippets Groups Projects
Commit c16f65a9 authored by Jake Taylor's avatar Jake Taylor :lips:
Browse files

Merge branch 'hotfix/ios' into 'release'

Add getprimagesb64

See merge request !87
parents a80f2fd2 b234cffc
No related branches found
No related tags found
2 merge requests!117Release,!87Add getprimagesb64
...@@ -2,8 +2,10 @@ package bindings ...@@ -2,8 +2,10 @@ package bindings
import ( import (
"encoding/json" "encoding/json"
"github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"reflect"
"unsafe"
) )
type PreimageNotification interface { type PreimageNotification interface {
...@@ -22,33 +24,23 @@ func (c *Client) RegisterPreimageCallback(identity []byte, pin PreimageNotificat ...@@ -22,33 +24,23 @@ func (c *Client) RegisterPreimageCallback(identity []byte, pin PreimageNotificat
c.api.GetStorage().GetEdge().AddUpdateCallback(iid, cb) c.api.GetStorage().GetEdge().AddUpdateCallback(iid, cb)
} }
func (c *Client) GetPreimages(identity []byte) (string, error) { func (c *Client) GetPreimages(identity []byte) string {
iid := &id.ID{} iid := &id.ID{}
copy(iid[:], identity) copy(iid[:], identity)
list, exist := c.api.GetStorage().GetEdge().Get(iid) list, exist := c.api.GetStorage().GetEdge().Get(iid)
if !exist { if !exist {
return "", errors.Errorf("Could not find a preimage list for %s", iid) jww.ERROR.Printf("Preimage for %s does not exist", iid.String())
return ""
} }
marshaled, err := json.Marshal(&list) marshaled, err := json.Marshal(&list)
if err != nil {
return string(marshaled), err jww.ERROR.Printf("Error marshaling preimages: %s", err.Error())
} return ""
// hack on getPreimages so it works on iOS per https://github.com/golang/go/issues/46893
func (c *Client) GetPreimagesHack(dummy string, identity []byte) (string, error) {
iid := &id.ID{}
copy(iid[:], identity)
list, exist := c.api.GetStorage().GetEdge().Get(iid)
if !exist {
return "", errors.Errorf("Could not find a preimage list for %s", iid)
} }
marshaled, err := json.Marshal(&list) jww.DEBUG.Printf("Preimages size: %v %v %d",
reflect.TypeOf(marshaled).Align(), unsafe.Sizeof(marshaled), len(marshaled))
return string(marshaled), err return string(marshaled)
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment