mirror of
https://github.com/arnaucube/go-dvote.git
synced 2026-02-28 13:36:47 +01:00
initial attempt at modular transports, fails with segfault
This commit is contained in:
24
data/data.go
24
data/data.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user