ipld-eth-server/vendor/github.com/vulcanize/eth-block-extractor/pkg/ipfs/publisher.go
2019-12-02 13:24:46 -06:00

33 lines
577 B
Go

package ipfs
import "fmt"
type Error struct {
msg string
err error
}
func (ie Error) Error() string {
return fmt.Sprintf("%s: %s", ie.msg, ie.err.Error())
}
type Publisher interface {
Write(input interface{}) ([]string, error)
}
type BlockDataPublisher struct {
DagPutter
}
func NewIpfsPublisher(dagPutter DagPutter) *BlockDataPublisher {
return &BlockDataPublisher{DagPutter: dagPutter}
}
func (ip *BlockDataPublisher) Write(input interface{}) ([]string, error) {
cids, err := ip.DagPutter.DagPut(input)
if err != nil {
return nil, err
}
return cids, nil
}