Documentation ¶
Index ¶
- type Config
- type Info
- type Thread
- func (t *Thread) AddComment(dataId string, body string) (mh.Multihash, error)
- func (t *Thread) AddExternalInvite() (mh.Multihash, []byte, error)
- func (t *Thread) AddInvite(inviteePk libp2pc.PubKey) (mh.Multihash, error)
- func (t *Thread) AddLike(dataId string) (mh.Multihash, error)
- func (t *Thread) AddPhoto(dataId string, caption string, key []byte) (mh.Multihash, error)
- func (t *Thread) Blocks(offsetId string, limit int, btype *repo.BlockType, dataId *string) []repo.Block
- func (t *Thread) Decrypt(data []byte) ([]byte, error)
- func (t *Thread) Encrypt(data []byte) ([]byte, error)
- func (t *Thread) FollowParents(parents []string, from *peer.ID) ([]repo.Peer, error)
- func (t *Thread) GetBlockData(path string, block *repo.Block) ([]byte, error)
- func (t *Thread) GetBlockDataKey(block *repo.Block) ([]byte, error)
- func (t *Thread) GetPhotoMetaData(id string, block *repo.Block) (*util.PhotoMetadata, error)
- func (t *Thread) HandleAnnotationBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, ...) (mh.Multihash, error)
- func (t *Thread) HandleDataBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, ...) (mh.Multihash, error)
- func (t *Thread) HandleExternalInviteMessage(content *pb.ThreadExternalInvite) error
- func (t *Thread) HandleIgnoreBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, ...) (mh.Multihash, error)
- func (t *Thread) HandleInviteMessage(content *pb.ThreadInvite) error
- func (t *Thread) HandleJoinBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, ...) (mh.Multihash, *repo.Peer, error)
- func (t *Thread) HandleLeaveBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, ...) (mh.Multihash, error)
- func (t *Thread) HandleMergeBlock(from *peer.ID, message *pb.Message, signed *pb.SignedThreadBlock, ...) (mh.Multihash, error)
- func (t *Thread) Ignore(blockId string) (mh.Multihash, error)
- func (t *Thread) Info() (*Info, error)
- func (t *Thread) Join(inviterPk libp2pc.PubKey, blockId string) (mh.Multihash, error)
- func (t *Thread) JoinInitial() (mh.Multihash, error)
- func (t *Thread) Leave() (mh.Multihash, error)
- func (t *Thread) Merge(head string) (mh.Multihash, error)
- func (t *Thread) Peers() []repo.Peer
- func (t *Thread) Verify(signed *pb.SignedThreadBlock) error
- type Update
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { RepoPath string Ipfs func() *core.IpfsNode Blocks func() repo.BlockStore Peers func() repo.PeerStore Notifications func() repo.NotificationStore GetHead func() (string, error) UpdateHead func(head string) error Publish func(payload []byte) error Send func(message *pb.Envelope, peerId string, hash *string) error NewEnvelope func(message *pb.Message) (*pb.Envelope, error) PutPinRequest func(id string) error GetUsername func() (*string, error) SendUpdate func(update Update) }
Config is used to construct a Thread
type Info ¶
type Info struct { Head *repo.Block `json:"head,omitempty"` BlockCount int `json:"block_count"` LatestPhoto *repo.Block `json:"latest_photo,omitempty"` PhotoCount int `json:"photo_count"` }
Info reports info about a thread
type Thread ¶
type Thread struct { Id string Name string PrivKey libp2pc.PrivKey GetHead func() (string, error) // contains filtered or unexported fields }
Thread is the primary mechanism representing a collecion of data / files / photos
func (*Thread) AddComment ¶
AddComment adds an outgoing comment block
func (*Thread) AddExternalInvite ¶
AddExternalInvite creates an external invite, which can be retrieved by any peer and does not become part of the hash chain
func (*Thread) AddInvite ¶
AddInvite creates an outgoing invite block, which is sent directly to the recipient and does not become part of the hash chain
func (*Thread) Blocks ¶
func (t *Thread) Blocks(offsetId string, limit int, btype *repo.BlockType, dataId *string) []repo.Block
Blocks paginates blocks from the datastore
func (*Thread) FollowParents ¶
FollowParents tries to follow a list of chains of block ids, processing along the way
func (*Thread) GetBlockData ¶
GetBlockData cats file data from ipfs and tries to decrypt it with the provided block
func (*Thread) GetBlockDataKey ¶
GetBlockDataKey returns the decrypted AES key for a block
func (*Thread) GetPhotoMetaData ¶
GetPhotoMetaData returns photo metadata indexed under a block
func (*Thread) HandleAnnotationBlock ¶
func (t *Thread) HandleAnnotationBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, content *pb.ThreadAnnotation, following bool) (mh.Multihash, error)
HandleAnnotationBlock handles an incoming data block
func (*Thread) HandleDataBlock ¶
func (t *Thread) HandleDataBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, content *pb.ThreadData, following bool) (mh.Multihash, error)
HandleDataBlock handles an incoming data block
func (*Thread) HandleExternalInviteMessage ¶
func (t *Thread) HandleExternalInviteMessage(content *pb.ThreadExternalInvite) error
HandleExternalInviteMessage handles an incoming external invite - this happens right before a join - the invite is not kept on-chain, so we only need to follow parents and update HEAD
func (*Thread) HandleIgnoreBlock ¶
func (t *Thread) HandleIgnoreBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, content *pb.ThreadIgnore, following bool) (mh.Multihash, error)
HandleIgnoreBlock handles an incoming ignore block
func (*Thread) HandleInviteMessage ¶
func (t *Thread) HandleInviteMessage(content *pb.ThreadInvite) error
HandleInviteMessage handles an incoming invite - this happens right before a join - the invite is not kept on-chain, so we only need to follow parents and update HEAD
func (*Thread) HandleJoinBlock ¶
func (t *Thread) HandleJoinBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, content *pb.ThreadJoin, following bool) (mh.Multihash, *repo.Peer, error)
HandleJoinBlock handles an incoming join block
func (*Thread) HandleLeaveBlock ¶
func (t *Thread) HandleLeaveBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, content *pb.ThreadLeave, following bool) (mh.Multihash, error)
HandleLeaveBlock handles an incoming leave block
func (*Thread) HandleMergeBlock ¶
func (t *Thread) HandleMergeBlock(from *peer.ID, message *pb.Message, signed *pb.SignedThreadBlock, content *pb.ThreadMerge, following bool) (mh.Multihash, error)
HandleMergeBlock handles an incoming merge block
func (*Thread) JoinInitial ¶
JoinInitial creates an outgoing join block for an emtpy thread
func (*Thread) Merge ¶
Merge adds a merge block, which are kept local until subsequent updates, avoiding possibly endless echoes