initial attempt at modular transports, fails with segfault

This commit is contained in:
imw
2019-02-07 12:06:10 +01:00
parent 0e4c0cb8db
commit 5ce8bb33ee
5 changed files with 211 additions and 58 deletions

View File

@@ -9,8 +9,9 @@ import (
shell "github.com/ipfs/go-ipfs-api"
)
type Record struct {
Shell *shell.Message
type Storage interface {
Publish(o []byte) string
Retrieve(id string) []byte
}
func Publish(object []byte) string {
@@ -46,22 +47,3 @@ func Retrieve(hash string) []byte {
}
return content
}
func PsSubscribe(topic string) *shell.PubSubSubscription {
sh := shell.NewShell("localhost:5001")
sub, err := sh.PubSubSubscribe(topic)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s", err)
os.Exit(1)
}
return sub
}
func PsPublish(topic, data string) error {
sh := shell.NewShell("localhost:5001")
err := sh.PubSubPublish(topic, data)
if err != nil {
return err
}
return nil
}