core

package
v1.0.0-rc5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2018 License: MIT Imports: 62 Imported by: 0

Documentation

Index

Constants

View Source
const CafeServiceProtocol = protocol.ID("/textile/cafe/1.0.0")
View Source
const DataLinkName = "d"
View Source
const FileLinkName = "f"
View Source
const Version = "1.0.0-rc5"

Version is the core version identifier

Variables

View Source
var ErrAccountRequired = errors.New("account required")

common errors

View Source
var ErrBlockNotFound = errors.New("block not found")

ErrBlockNotFound indicates a block was not found in the index

View Source
var ErrBlockWrongType = errors.New("block type is not the type requested")

ErrBlockWrongType indicates a block was requested as a type other than its own

View Source
var ErrFileNotFound = errors.New("file not found")
View Source
var ErrInvalidFileNode = errors.New("invalid files node")

ErrInvalidFileNode indicates files where added via a nil ipld node

View Source
var ErrInvalidThreadBlock = errors.New("invalid thread block")

ErrInvalidThreadBlock is a catch all error for malformed / invalid blocks

View Source
var ErrInvitesNotAllowed = errors.New("invites not allowed to private thread")

ErrInvitesNotAllowed indicates an invite was attempted on a private thread

View Source
var ErrJsonSchemaRequired = errors.New("thread schema does not allow json files")

ErrJsonSchemaRequired indicates json files where added without a json schema

View Source
var ErrMissingDataLink = errors.New("data link not in node")
View Source
var ErrMissingFileLink = errors.New("file link not in node")
View Source
var ErrOffline = errors.New("node is offline")
View Source
var ErrStarted = errors.New("node is started")
View Source
var ErrStopped = errors.New("node is stopped")
View Source
var ErrThreadInviteNotFound = errors.New("thread invite not found")

ErrThreadInviteNotFound indicates thread invite is not found

View Source
var ErrThreadLoaded = errors.New("thread is loaded")

ErrThreadLoaded indicates the thread is already loaded from the datastore

View Source
var ErrThreadNotFound = errors.New("thread not found")

ErrThreadNotFound indicates thread is not found in the loaded list

View Source
var ErrThreadSchemaRequired = errors.New("thread schema required to add files")

ErrThreadSchemaRequired indicates files where added without a thread schema

Functions

func GetRandomPort

func GetRandomPort() string

GetRandomPort returns a port within the acceptable range

func InitRepo

func InitRepo(conf InitConfig) error

InitRepo initializes a new node repo

func MigrateRepo

func MigrateRepo(conf MigrateConfig) error

MigrateRepo runs _all_ repo migrations, including major

Types

type AddFileConfig

type AddFileConfig struct {
	Input     []byte `json:"input"`
	Use       string `json:"use"`
	Media     string `json:"media"`
	Name      string `json:"name"`
	Plaintext bool   `json:"plaintext"`
}

type AddThreadConfig

type AddThreadConfig struct {
	Key       string          `json:"key"`
	Name      string          `json:"name"`
	Schema    mh.Multihash    `json:"schema"`
	Initiator string          `json:"initiator"`
	Type      repo.ThreadType `json:"type"`
	Join      bool            `json:"join"`
}

AddThreadConfig is used to create a new thread model

type BlockInfo

type BlockInfo struct {
	Id       string    `json:"id"`
	ThreadId string    `json:"thread_id"`
	AuthorId string    `json:"author_id"`
	Username string    `json:"username"`
	Type     string    `json:"type"`
	Date     time.Time `json:"date"`
	Parents  []string  `json:"parents"`
	Target   string    `json:"target,omitempty"`
	Body     string    `json:"body,omitempty"`
}

BlockInfo is a more readable version of repo.Block

type CafeInbox

type CafeInbox struct {
	// contains filtered or unexported fields
}

CafeInbox queues and processes outbound thread messages

func NewCafeInbox

func NewCafeInbox(
	service func() *CafeService,
	threadsService func() *ThreadsService,
	node func() *core.IpfsNode,
	datastore repo.Datastore,
) *CafeInbox

NewCafeInbox creates a new inbox queue

func (*CafeInbox) Add

func (q *CafeInbox) Add(msg *pb.CafeMessage) error

Add adds an inbound message

func (*CafeInbox) CheckMessages

func (q *CafeInbox) CheckMessages() error

CheckMessages asks each active cafe session for new messages

func (*CafeInbox) Flush

func (q *CafeInbox) Flush()

Flush processes pending messages

type CafeOutbox

type CafeOutbox struct {
	// contains filtered or unexported fields
}

CafeOutbox queues and processes outbound cafe requests

func NewCafeOutbox

func NewCafeOutbox(service func() *CafeService, node func() *core.IpfsNode, datastore repo.Datastore) *CafeOutbox

NewCafeOutbox creates a new outbox queue

func (*CafeOutbox) Add

func (q *CafeOutbox) Add(target string, rtype repo.CafeRequestType) error

Add adds a request for each active cafe session

func (*CafeOutbox) Flush

func (q *CafeOutbox) Flush()

Flush processes pending requests

func (*CafeOutbox) InboxRequest

func (q *CafeOutbox) InboxRequest(pid peer.ID, env *pb.Envelope, inboxes []string) error

InboxRequest adds a request for a peer's inbox(es)

type CafeService

type CafeService struct {
	// contains filtered or unexported fields
}

CafeService is a libp2p pinning and offline message service

func NewCafeService

func NewCafeService(
	account *keypair.Full,
	node *core.IpfsNode,
	datastore repo.Datastore,
	inbox *CafeInbox,
) *CafeService

NewCafeService returns a new threads service

func (*CafeService) CheckMessages

func (h *CafeService) CheckMessages(cafe peer.ID) error

CheckMessages asks each session's inbox for new messages

func (*CafeService) DeleteMessages

func (h *CafeService) DeleteMessages(cafe peer.ID) error

DeleteMessages deletes a page of messages from a cafe

func (*CafeService) DeliverMessage

func (h *CafeService) DeliverMessage(mid string, pid peer.ID, cafe peer.ID) error

DeliverMessage delivers a message content id to a peer's cafe inbox TODO: unpin message locally after it's delivered

func (*CafeService) Handle

func (h *CafeService) Handle(pid peer.ID, env *pb.Envelope) (*pb.Envelope, error)

Handle is called by the underlying service handler method

func (*CafeService) Ping

func (h *CafeService) Ping(pid peer.ID) (service.PeerStatus, error)

Ping pings another peer

func (*CafeService) Protocol

func (h *CafeService) Protocol() protocol.ID

Protocol returns the handler protocol

func (*CafeService) Register

func (h *CafeService) Register(cafe peer.ID) error

Register creates a session with a cafe

func (*CafeService) Store

func (h *CafeService) Store(cids []string, cafe peer.ID) ([]string, error)

Store stores (pins) content on a cafe and returns a list of successful cids

func (*CafeService) StoreThread

func (h *CafeService) StoreThread(thrd *repo.Thread, cafe peer.ID) error

StoreThread pushes a thread to a cafe backup

type ContactInfo

type ContactInfo struct {
	Id        string    `json:"id"`
	Address   string    `json:"address"`
	Username  string    `json:"username"`
	ThreadIds []string  `json:"thread_ids"`
	Added     time.Time `json:"added"`
}

ContactInfo display info about a contact

type Directory

type Directory map[string]repo.File

type InitConfig

type InitConfig struct {
	Account     *keypair.Full
	PinCode     string
	RepoPath    string
	SwarmPorts  string
	ApiAddr     string
	CafeApiAddr string
	GatewayAddr string
	IsMobile    bool
	IsServer    bool
	LogLevel    logger.Level
	LogToDisk   bool
	CafeOpen    bool
}

InitConfig is used to setup a textile node

type Keys

type Keys map[string]string

type MigrateConfig

type MigrateConfig struct {
	PinCode  string
	RepoPath string
}

MigrateConfig is used to define options during a major migration

type NotificationInfo

type NotificationInfo struct {
	Id        string    `json:"id"`
	Date      time.Time `json:"date"`
	ActorId   string    `json:"actor_id"`
	Username  string    `json:"username,omitempty"`
	Subject   string    `json:"subject"`
	SubjectId string    `json:"subject_id"`
	BlockId   string    `json:"block_id,omitempty"`
	Target    string    `json:"target,omitempty"`
	Type      string    `json:"type"`
	Body      string    `json:"body"`
	Read      bool      `json:"read"`
}

type Overview

type Overview struct {
	AccountPeerCount int `json:"account_peer_cnt"`
	ThreadCount      int `json:"thread_cnt"`
	FileCount        int `json:"file_cnt"`
	ContactCount     int `json:"contact_cnt"`
}

Overview is a wallet overview object

type PinResponse

type PinResponse struct {
	Id    string `json:"id,omitempty"`
	Error string `json:"error,omitempty"`
}

PinResponse is the json response from a pin request

type Profile

type Profile struct {
	Address   string   `json:"address"`
	Inboxes   []string `json:"inboxes,omitempty"`
	Username  string   `json:"username,omitempty"`
	AvatarUri string   `json:"avatar_uri,omitempty"`
}

Profile is an account-wide public profile NOTE: any account peer can publish profile entries to the same IPNS key

type RunConfig

type RunConfig struct {
	PinCode  string
	RepoPath string
}

RunConfig is used to define run options for a textile node

type Textile

type Textile struct {
	// contains filtered or unexported fields
}

Textile is the main Textile node structure

func NewTextile

func NewTextile(conf RunConfig) (*Textile, error)

NewTextile runs a node out of an initialized repo

func (*Textile) AcceptExternalThreadInvite

func (t *Textile) AcceptExternalThreadInvite(inviteId string, key []byte) (mh.Multihash, error)

AcceptExternalThreadInvite attemps to download an encrypted thread key from an external invite, adds a new thread, and notifies the inviter of the join

func (*Textile) AcceptThreadInvite

func (t *Textile) AcceptThreadInvite(inviteId string) (mh.Multihash, error)

AcceptThreadInvite adds a new thread, and notifies the inviter of the join

func (*Textile) AcceptThreadInviteViaNotification

func (t *Textile) AcceptThreadInviteViaNotification(id string) (mh.Multihash, error)

AcceptThreadInviteViaNotification uses an invite notification to accept an invite to a thread

func (*Textile) Account

func (t *Textile) Account() *keypair.Full

Account returns account keypair

func (*Textile) AddContact

func (t *Textile) AddContact(id string, address string, username string) error

AddContact adds a contact for the first time Note: Existing contacts will not be overwritten

func (*Textile) AddFile

func (t *Textile) AddFile(mill m.Mill, conf AddFileConfig) (*repo.File, error)

func (*Textile) AddNodeFromDirs

func (t *Textile) AddNodeFromDirs(dirs []Directory) (ipld.Node, Keys, error)

func (*Textile) AddNodeFromFiles

func (t *Textile) AddNodeFromFiles(files []repo.File) (ipld.Node, Keys, error)

func (*Textile) AddSchema

func (t *Textile) AddSchema(jsonstr string, name string) (*repo.File, error)

func (*Textile) AddThread

func (t *Textile) AddThread(sk libp2pc.PrivKey, conf AddThreadConfig) (*Thread, error)

AddThread adds a thread with a given name and secret key

func (*Textile) ApiAddr

func (t *Textile) ApiAddr() string

ApiAddr returns the api address

func (*Textile) Avatar

func (t *Textile) Avatar() (*string, error)

Avatar returns profile avatar

func (*Textile) Block

func (t *Textile) Block(id string) (*repo.Block, error)

Block returns block with id

func (*Textile) BlockInfo

func (t *Textile) BlockInfo(id string) (*BlockInfo, error)

BlockInfo returns block info with id

func (*Textile) Blocks

func (t *Textile) Blocks(offset string, limit int, query string) []repo.Block

GetBlocks paginates blocks

func (*Textile) BlocksByTarget

func (t *Textile) BlocksByTarget(target string) []repo.Block

BlocksByTarget returns block with parent

func (*Textile) CafeApiAddr

func (t *Textile) CafeApiAddr() string

CafeApiAddr returns the cafe api address

func (*Textile) CafeSession

func (t *Textile) CafeSession(peerId string) (*repo.CafeSession, error)

CafeSession returns an active session by id

func (*Textile) CafeSessions

func (t *Textile) CafeSessions() ([]repo.CafeSession, error)

CafeSessions lists active cafe sessions

func (*Textile) CheckCafeMessages

func (t *Textile) CheckCafeMessages() error

CheckCafeMessages fetches new messages from registered cafes

func (*Textile) CloseChns

func (t *Textile) CloseChns()

CloseChns closes update channels

func (*Textile) Config

func (t *Textile) Config() *config.Config

Config returns the textile configuration file

func (*Textile) Contact

func (t *Textile) Contact(id string) *ContactInfo

Contact looks up a contact by peer id

func (*Textile) ContactThreads

func (t *Textile) ContactThreads(id string) ([]ThreadInfo, error)

ContactThreads returns all threads with the given peer

func (*Textile) ContactUsername

func (t *Textile) ContactUsername(id string) string

ContactUsername returns the username for the peer id if known

func (*Textile) Contacts

func (t *Textile) Contacts() ([]ContactInfo, error)

Contacts returns all contacts this peer has interacted with

func (*Textile) CountUnreadNotifications

func (t *Textile) CountUnreadNotifications() int

CountUnreadNotifications counts unread notifications

func (*Textile) DataAtPath

func (t *Textile) DataAtPath(path string) ([]byte, error)

DataAtPath returns raw data behind an ipfs path

func (*Textile) Decrypt

func (t *Textile) Decrypt(input []byte) ([]byte, error)

Decrypt decrypts input with account address

func (*Textile) DeregisterCafe

func (t *Textile) DeregisterCafe(peerId string) error

DeregisterCafe removes the session associated with the given cafe

func (*Textile) DoneCh

func (t *Textile) DoneCh() <-chan struct{}

DoneCh returns the core node done channel

func (*Textile) Encrypt

func (t *Textile) Encrypt(input []byte) ([]byte, error)

Encrypt encrypts input with account address

func (*Textile) File

func (t *Textile) File(hash string) (*repo.File, error)

func (*Textile) FileData

func (t *Textile) FileData(hash string) (io.ReadSeeker, *repo.File, error)

func (*Textile) GetMedia

func (t *Textile) GetMedia(reader io.Reader, mill m.Mill) (string, error)

func (*Textile) GetThreadUpdateListener

func (t *Textile) GetThreadUpdateListener() *broadcast.Listener

GetThreadUpdateListener returns the thread update channel

func (*Textile) IgnoreThreadInvite

func (t *Textile) IgnoreThreadInvite(inviteId string) error

IgnoreThreadInvite deletes the invite and removes the associated notification.

func (*Textile) IgnoreThreadInviteViaNotification

func (t *Textile) IgnoreThreadInviteViaNotification(id string) error

IgnoreThreadInviteViaNotification uses an invite notification to ignore an invite to a thread

func (*Textile) Ipfs

func (t *Textile) Ipfs() *core.IpfsNode

Ipfs returns the underlying ipfs node

func (*Textile) LinksAtPath

func (t *Textile) LinksAtPath(path string) ([]*ipld.Link, error)

LinksAtPath returns ipld links behind an ipfs path

func (*Textile) Mobile

func (t *Textile) Mobile() bool

Mobile returns whether or not node is configured for a mobile device

func (*Textile) NotificationCh

func (t *Textile) NotificationCh() <-chan NotificationInfo

NotificationsCh returns the notifications channel

func (*Textile) NotificationInfo

func (t *Textile) NotificationInfo(note repo.Notification) NotificationInfo

NotificationInfo returns the notification info object

func (*Textile) Notifications

func (t *Textile) Notifications(offset string, limit int) []NotificationInfo

Notifications lists notifications

func (*Textile) Online

func (t *Textile) Online() bool

Online returns node online status

func (*Textile) OnlineCh

func (t *Textile) OnlineCh() <-chan struct{}

OnlineCh returns the online channel

func (*Textile) Overview

func (t *Textile) Overview() (*Overview, error)

Overview returns an overview object

func (*Textile) PeerId

func (t *Textile) PeerId() (peer.ID, error)

PeerId returns peer id

func (*Textile) Ping

func (t *Textile) Ping(pid peer.ID) (service.PeerStatus, error)

Ping pings another peer

func (*Textile) Profile

func (t *Textile) Profile(pid peer.ID) (*Profile, error)

Profile return a model representation of an ipns profile

func (*Textile) PublishProfile

func (t *Textile) PublishProfile() error

PublishProfile publishes the current profile

func (*Textile) ReadAllNotifications

func (t *Textile) ReadAllNotifications() error

ReadAllNotifications marks all notification as read

func (*Textile) ReadNotification

func (t *Textile) ReadNotification(id string) error

ReadNotification marks a notification as read

func (*Textile) RefreshCafeSession

func (t *Textile) RefreshCafeSession(peerId string) (*repo.CafeSession, error)

RefreshCafeSession attempts to refresh a token with a cafe

func (*Textile) RegisterCafe

func (t *Textile) RegisterCafe(peerId string) (*repo.CafeSession, error)

RegisterCafe registers this account with another peer (the "cafe"), which provides a session token for the service

func (*Textile) RemoveThread

func (t *Textile) RemoveThread(id string) (mh.Multihash, error)

RemoveThread removes a thread

func (*Textile) RepoPath

func (t *Textile) RepoPath() string

RepoPath returns the node's repo path

func (*Textile) ResolveProfile

func (t *Textile) ResolveProfile(name peer.ID) (*path.Path, error)

ResolveProfile looks up a profile on ipns

func (*Textile) SetAvatar

func (t *Textile) SetAvatar(hash string) error

SetAvatar updates profile with a new avatar at the given file hash.

func (*Textile) SetUsername

func (t *Textile) SetUsername(username string) error

SetUsername updates profile with a new username

func (*Textile) Sign

func (t *Textile) Sign(input []byte) ([]byte, error)

Sign signs input with account seed

func (*Textile) Start

func (t *Textile) Start() error

Start creates an ipfs node and starts textile services

func (*Textile) StartApi

func (t *Textile) StartApi(addr string)

StartApi starts the host instance

func (*Textile) Started

func (t *Textile) Started() bool

Started returns node started status

func (*Textile) Stop

func (t *Textile) Stop() error

Stop destroys the ipfs node and shutsdown textile services

func (*Textile) StopApi

func (t *Textile) StopApi() error

StopApi starts the host instance

func (*Textile) TargetNodeKeys

func (t *Textile) TargetNodeKeys(node ipld.Node) (Keys, error)

func (*Textile) Thread

func (t *Textile) Thread(id string) *Thread

Thread get a thread by id from loaded threads

func (*Textile) ThreadByKey

func (t *Textile) ThreadByKey(key string) *Thread

ThreadByKey get a thread by key from loaded threads

func (*Textile) ThreadComment

func (t *Textile) ThreadComment(block repo.Block) (*ThreadCommentInfo, error)

func (*Textile) ThreadComments

func (t *Textile) ThreadComments(target string) ([]ThreadCommentInfo, error)

func (*Textile) ThreadFile

func (t *Textile) ThreadFile(blockId string) (*ThreadFilesInfo, error)

func (*Textile) ThreadFiles

func (t *Textile) ThreadFiles(offset string, limit int, threadId string) ([]ThreadFilesInfo, error)

func (*Textile) ThreadInfo

func (t *Textile) ThreadInfo(id string) (*ThreadInfo, error)

ThreadInfo gets thread info

func (*Textile) ThreadInvites

func (t *Textile) ThreadInvites() []ThreadInviteInfo

ThreadInvites lists info on all pending invites

func (*Textile) ThreadLike

func (t *Textile) ThreadLike(block repo.Block) (*ThreadLikeInfo, error)

func (*Textile) ThreadLikes

func (t *Textile) ThreadLikes(target string) ([]ThreadLikeInfo, error)

func (*Textile) ThreadMessage

func (t *Textile) ThreadMessage(block repo.Block) (*ThreadMessageInfo, error)

func (*Textile) ThreadMessages

func (t *Textile) ThreadMessages(offset string, limit int, threadId string) ([]ThreadMessageInfo, error)

func (*Textile) Threads

func (t *Textile) Threads() []Thread

Threads lists loaded threads

func (*Textile) UpdateCh

func (t *Textile) UpdateCh() <-chan Update

UpdateCh returns the node update channel

func (*Textile) Username

func (t *Textile) Username() (*string, error)

Username returns profile username

func (*Textile) Verify

func (t *Textile) Verify(input []byte, sig []byte) error

Verify verifies input with account address

func (*Textile) Writer

func (t *Textile) Writer() io.Writer

Writer returns the output writer (logger / stdout)

type Thread

type Thread struct {
	Id     string
	Key    string // app key, usually UUID
	Name   string
	Type   repo.ThreadType
	Schema *schema.Node
	// contains filtered or unexported fields
}

Thread is the primary mechanism representing a collecion of data / files / photos

func NewThread

func NewThread(model *repo.Thread, conf *ThreadConfig) (*Thread, error)

NewThread create a new Thread from a repo model and config

func (*Thread) AddComment

func (t *Thread) AddComment(target string, body string) (mh.Multihash, error)

AddComment adds an outgoing comment block

func (*Thread) AddExternalInvite

func (t *Thread) AddExternalInvite() (mh.Multihash, []byte, error)

AddExternalInvite creates an external invite, which can be retrieved by any peer and does not become part of the hash chain

func (*Thread) AddFiles

func (t *Thread) AddFiles(node ipld.Node, caption string, keys Keys) (mh.Multihash, error)

AddFile adds an outgoing files block

func (*Thread) AddFlag

func (t *Thread) AddFlag(block string) (mh.Multihash, error)

AddFlag adds an outgoing flag block targeted at another block to flag

func (*Thread) AddIgnore

func (t *Thread) AddIgnore(block string) (mh.Multihash, error)

AddIgnore adds an outgoing ignore block targeted at another block to ignore

func (*Thread) AddInvite

func (t *Thread) AddInvite(inviteeId peer.ID) (mh.Multihash, error)

AddInvite creates an outgoing invite block, which is sent directly to the recipient and does not become part of the hash chain

func (*Thread) AddLike

func (t *Thread) AddLike(target string) (mh.Multihash, error)

AddLike adds an outgoing like block

func (*Thread) AddMessage

func (t *Thread) AddMessage(body string) (mh.Multihash, error)

AddMessage adds an outgoing message block

func (*Thread) AddPeer

func (t *Thread) AddPeer(id string) error

AddPeer directly adds a peer to a thread Note: This is really just tmp here for the 1.0 migration

func (*Thread) Decrypt

func (t *Thread) Decrypt(data []byte) ([]byte, error)

Decrypt data with thread secret key

func (*Thread) Encrypt

func (t *Thread) Encrypt(data []byte) ([]byte, error)

Encrypt data with thread public key

func (*Thread) Head

func (t *Thread) Head() (string, error)

Head returns content id of the latest update

func (*Thread) Info

func (t *Thread) Info() (*ThreadInfo, error)

Info returns thread info

func (*Thread) Peers

func (t *Thread) Peers() []repo.ThreadPeer

Peers returns locally known peers in this thread

func (*Thread) State

func (t *Thread) State() (repo.ThreadState, error)

State returns the current thread state

type ThreadCommentInfo

type ThreadCommentInfo struct {
	Id       string    `json:"id"`
	Date     time.Time `json:"date"`
	AuthorId string    `json:"author_id"`
	Username string    `json:"username,omitempty"`
	Body     string    `json:"body"`
}

type ThreadConfig

type ThreadConfig struct {
	RepoPath      string
	Config        *config.Config
	Node          func() *core.IpfsNode
	Datastore     repo.Datastore
	Service       func() *ThreadsService
	ThreadsOutbox *ThreadsOutbox
	CafeOutbox    *CafeOutbox
	SendUpdate    func(update ThreadUpdate)
}

ThreadConfig is used to construct a Thread

type ThreadFileInfo

type ThreadFileInfo struct {
	Index int        `json:"index"`
	File  *repo.File `json:"file,omitempty"`
	Links Directory  `json:"links,omitempty"`
}

type ThreadFilesInfo

type ThreadFilesInfo struct {
	Block    string              `json:"block"`
	Target   string              `json:"target"`
	Date     time.Time           `json:"date"`
	AuthorId string              `json:"author_id"`
	Username string              `json:"username,omitempty"`
	Caption  string              `json:"caption,omitempty"`
	Files    []ThreadFileInfo    `json:"files"`
	Comments []ThreadCommentInfo `json:"comments"`
	Likes    []ThreadLikeInfo    `json:"likes"`
	Threads  []string            `json:"threads"`
}

type ThreadInfo

type ThreadInfo struct {
	Id         string       `json:"id"`
	Key        string       `json:"key"`
	Name       string       `json:"name"`
	Schema     *schema.Node `json:"schema,omitempty"`
	SchemaId   string       `json:"schema_id,omitempty"`
	Initiator  string       `json:"initiator"`
	Type       string       `json:"type"`
	State      string       `json:"state"`
	Head       *BlockInfo   `json:"head,omitempty"`
	PeerCount  int          `json:"peer_cnt"`
	BlockCount int          `json:"block_cnt"`
	FileCount  int          `json:"file_cnt"`
}

ThreadInfo reports info about a thread

type ThreadInviteInfo

type ThreadInviteInfo struct {
	Id      string    `json:"id"`
	Name    string    `json:"name"`
	Inviter string    `json:"inviter"`
	Date    time.Time `json:"date"`
}

ThreadInviteInfo reports info about a thread

type ThreadLikeInfo

type ThreadLikeInfo struct {
	Id       string    `json:"id"`
	Date     time.Time `json:"date"`
	AuthorId string    `json:"author_id"`
	Username string    `json:"username,omitempty"`
}

type ThreadMessageInfo

type ThreadMessageInfo struct {
	Id       string    `json:"id"`
	Date     time.Time `json:"date"`
	AuthorId string    `json:"author_id"`
	Username string    `json:"username,omitempty"`
	Body     string    `json:"body"`
}

type ThreadUpdate

type ThreadUpdate struct {
	Block      BlockInfo   `json:"block"`
	ThreadId   string      `json:"thread_id"`
	ThreadName string      `json:"thread_name"`
	Info       interface{} `json:"info,omitempty"`
}

ThreadUpdate is used to notify listeners about updates in a thread

type ThreadsOutbox

type ThreadsOutbox struct {
	// contains filtered or unexported fields
}

ThreadsOutbox queues and processes outbound thread messages

func NewThreadsOutbox

func NewThreadsOutbox(
	service func() *ThreadsService,
	node func() *core.IpfsNode,
	datastore repo.Datastore,
	cafeOutbox *CafeOutbox,
) *ThreadsOutbox

NewThreadsOutbox creates a new outbox queue

func (*ThreadsOutbox) Add

func (q *ThreadsOutbox) Add(pid peer.ID, env *pb.Envelope) error

Add adds an outbound message

func (*ThreadsOutbox) Flush

func (q *ThreadsOutbox) Flush()

Flush processes pending messages

type ThreadsService

type ThreadsService struct {
	// contains filtered or unexported fields
}

ThreadService is a libp2p service for orchestrating a collection of files with annotations amongst a group of peers

func NewDummyThreadsService

func NewDummyThreadsService(account *keypair.Full, node *core.IpfsNode) *ThreadsService

NewDummyThreadsService is used to create message envelopes _before_ the node is able to go online

func NewThreadsService

func NewThreadsService(
	account *keypair.Full,
	node *core.IpfsNode,
	datastore repo.Datastore,
	getThread func(id string) *Thread,
	addThread func(sk libp2pc.PrivKey, conf AddThreadConfig) (*Thread, error),
	sendNotification func(note *repo.Notification) error,
) *ThreadsService

NewThreadsService returns a new threads service

func (*ThreadsService) Handle

func (h *ThreadsService) Handle(pid peer.ID, env *pb.Envelope) (*pb.Envelope, error)

Handle is called by the underlying service handler method

func (*ThreadsService) NewEnvelope

func (h *ThreadsService) NewEnvelope(threadId string, hash mh.Multihash, ciphertext []byte) (*pb.Envelope, error)

NewEnvelope signs and wraps an encypted block for transport

func (*ThreadsService) Ping

func (h *ThreadsService) Ping(pid peer.ID) (service.PeerStatus, error)

Ping pings another peer

func (*ThreadsService) Protocol

func (h *ThreadsService) Protocol() protocol.ID

Protocol returns the handler protocol

func (*ThreadsService) SendMessage

func (h *ThreadsService) SendMessage(pid peer.ID, env *pb.Envelope) error

SendMessage sends a message to a peer

type Update

type Update struct {
	Id   string     `json:"id"`
	Name string     `json:"name"`
	Type UpdateType `json:"type"`
}

Update is used to notify UI listeners of changes

type UpdateType

type UpdateType int

UpdateType indicates a type of node update

const (
	// ThreadAdded is emitted when a thread is added
	ThreadAdded UpdateType = iota
	// ThreadRemoved is emitted when a thread is removed
	ThreadRemoved
	// AccountPeerAdded is emitted when an account peer (device) is added
	AccountPeerAdded
	// AccountPeerRemoved is emitted when an account peer (device) is removed
	AccountPeerRemoved
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL