mirror of
https://github.com/arnaucube/go-dvote.git
synced 2026-02-28 13:36:47 +01:00
Create new data type for exporting PubSub types
Signed-off-by: p4u <p4u@dabax.net>
This commit is contained in:
12
data/data.go
12
data/data.go
@@ -1,13 +1,18 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"os"
|
||||
"fmt"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
shell "github.com/ipfs/go-ipfs-api"
|
||||
)
|
||||
|
||||
type Record struct {
|
||||
Shell *shell.Message
|
||||
}
|
||||
|
||||
func Publish(object []byte) string {
|
||||
sh := shell.NewShell("localhost:5001")
|
||||
cid, err := sh.Add(bytes.NewBuffer(object))
|
||||
@@ -21,13 +26,12 @@ func Publish(object []byte) string {
|
||||
func Pin(path string) {
|
||||
sh := shell.NewShell("localhost:5001")
|
||||
err := sh.Pin(path)
|
||||
if err != nil{
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func Retrieve(hash string) []byte {
|
||||
sh := shell.NewShell("localhost:5001")
|
||||
reader, err := sh.Cat(hash)
|
||||
|
||||
Reference in New Issue
Block a user