Documentation ¶
Index ¶
- Variables
- func RMGroupListToGCEntry(gc *rpc.RMGroupList, entry *GCAddressBookEntry)
- type AddressBookEntry
- type ChunkID
- type ChunkState
- type ChunkUpload
- type Config
- type DB
- func (db *DB) AddChunkUploadInvoice(tx ReadWriteTx, uid UserID, fid FileID, cid ChunkID, index int, invoice string) error
- func (db *DB) AddGCInvite(tx ReadWriteTx, user UserID, invite rpc.RMGroupInvite) (uint64, error)
- func (db *DB) AddInitialKXAction(tx ReadWriteTx, initialRV zkidentity.ShortID, action PostKXAction) error
- func (db *DB) AddKXSearchQuery(tx ReadWriteTx, target UserID, search rpc.RMKXSearch, query KXSearchQuery) error
- func (db *DB) AddPostKXAction(tx ReadWriteTx, target UserID, action PostKXAction) error
- func (db *DB) AddPostStatus(tx ReadWriteTx, postFrom, statusFrom UserID, pid PostID, ...) error
- func (db *DB) AddPostStatusUpdate(tx ReadWriteTx, from UserID, p rpc.PostMetadata) (UserID, rpc.PostMetadataStatus, error)
- func (db *DB) AddToGCBlockList(tx ReadWriteTx, gcid zkidentity.ShortID, uid UserID) error
- func (db *DB) AddToSendQueue(tx ReadWriteTx, typ string, dests []UserID, msg []byte, priority uint) (SendQID, error)
- func (db *DB) AddUniquePostKXAction(tx ReadWriteTx, target UserID, action PostKXAction) error
- func (db *DB) AddressBookEntryExists(tx ReadTx, id UserID) bool
- func (db *DB) CancelFileDownload(tx ReadWriteTx, fid FileID) error
- func (db *DB) CleanupPaidRVs(tx ReadWriteTx, expirationDays int) error
- func (db *DB) CleanupPushPaymentAttempts(tx ReadWriteTx, limit time.Time) error
- func (db *DB) ClearPayStats(tx ReadWriteTx, user *UserID) error
- func (db *DB) CreatePost(tx ReadWriteTx, post, descr string, fname string, extraAttrs map[string]string, ...) (PostSummary, rpc.PostMetadata, error)
- func (db *DB) DelAllInvitesToGC(tx ReadWriteTx, gcid zkidentity.ShortID) error
- func (db *DB) DelGCInvite(tx ReadWriteTx, inviteID uint64) error
- func (db *DB) DeleteGC(tx ReadWriteTx, gcID zkidentity.ShortID) error
- func (db *DB) DeleteKX(tx ReadWriteTx, initialRV RawRVID) error
- func (db *DB) DeletePushPaymentAttempt(tx ReadWriteTx, rv ratchet.RVPoint) error
- func (db *DB) DeleteTransResetHalfKX(tx ReadWriteTx, id UserID) error
- func (db *DB) FindAcceptedGCInvite(tx ReadTx, gcID, uid zkidentity.ShortID) (rpc.RMGroupInvite, uint64, error)
- func (db *DB) FindGCInvite(tx ReadTx, gcID zkidentity.ShortID, token uint64) (rpc.RMGroupInvite, UserID, uint64, error)
- func (db *DB) FindSharedFileID(tx ReadTx, fname string) (FileID, error)
- func (db *DB) GetAddressBookEntry(tx ReadTx, id UserID, localID *zkidentity.FullIdentity) (*AddressBookEntry, error)
- func (db *DB) GetFileChunkUpload(tx ReadTx, uid UserID, fid FileID, cid ChunkID) (ChunkUpload, error)
- func (db *DB) GetGC(tx ReadTx, id zkidentity.ShortID) (rpc.RMGroupList, error)
- func (db *DB) GetGCAliases(tx ReadTx) (map[string]zkidentity.ShortID, error)
- func (db *DB) GetGCBlockList(tx ReadTx, gcid zkidentity.ShortID) (GCBlockList, error)
- func (db *DB) GetGCInvite(tx ReadTx, inviteID uint64) (rpc.RMGroupInvite, UserID, error)
- func (db *DB) GetKX(tx ReadTx, initialRV RawRVID) (KXData, error)
- func (db *DB) GetKXSearch(tx ReadTx, target UserID) (KXSearch, error)
- func (db *DB) GetSharedFile(tx ReadTx, uid *UserID, fid FileID) (SharedFile, rpc.FileMetadata, error)
- func (db *DB) GetSharedFileChunkData(tx ReadTx, sf *SharedFile, chunkIdx int) ([]byte, error)
- func (db *DB) GetSharedFileForUpload(tx ReadTx, uid UserID, fid FileID) (SharedFile, rpc.FileMetadata, error)
- func (db *DB) HasAnyRecentMediateID(tx ReadTx, target UserID, recentThreshold time.Duration) (bool, error)
- func (db *DB) HasDownloadedFile(tx ReadTx, fid zkidentity.ShortID) (string, error)
- func (db *DB) HasDownloadedFiles(tx ReadTx, user string, uid UserID, files []rpc.FileMetadata) ([]RemoteFile, error)
- func (db *DB) HasMediateID(tx ReadTx, mediator, target UserID) (MediateIDRequest, error)
- func (db *DB) HasPushPaymentAttempt(tx ReadTx, rv ratchet.RVPoint) (string, time.Time, error)
- func (db *DB) InitialToPostKXActions(tx ReadWriteTx, initialRV, target zkidentity.ShortID) error
- func (db *DB) IsBlocked(tx ReadTx, id UserID) bool
- func (db *DB) IsPostSubscriber(tx ReadTx, uid UserID) (bool, error)
- func (db *DB) IsPostSubscription(tx ReadTx, uid UserID) (bool, error)
- func (db *DB) IsRVPaid(tx ReadWriteTx, rv ratchet.RVPoint, expirationDays int) (bool, error)
- func (db *DB) ListAllSharedFiles(tx ReadTx) ([]SharedFileAndShares, error)
- func (db *DB) ListGCInvites(tx ReadTx, gc *zkidentity.ShortID) ([]*GCInvite, error)
- func (db *DB) ListGCs(tx ReadTx) ([]rpc.RMGroupList, error)
- func (db *DB) ListKXSearches(tx ReadTx) ([]UserID, error)
- func (db *DB) ListKXs(tx ReadTx) ([]KXData, error)
- func (db *DB) ListMediateIDs(tx ReadTx) ([]MediateIDRequest, error)
- func (db *DB) ListOutstandingDownloads(tx ReadTx) ([]FileDownload, error)
- func (db *DB) ListOutstandingUploads(tx ReadTx) ([]ChunkUpload, error)
- func (db *DB) ListPayStats(tx ReadTx) (map[UserID]UserPayStats, error)
- func (db *DB) ListPostKXActions(tx ReadTx, target UserID) ([]PostKXAction, error)
- func (db *DB) ListPostRelayers(tx ReadTx, post PostID) ([]UserID, error)
- func (db *DB) ListPostStatusUpdates(tx ReadTx, from UserID, post PostID) ([]rpc.PostMetadataStatus, error)
- func (db *DB) ListPostSubscribers(tx ReadTx) ([]UserID, error)
- func (db *DB) ListPostSubscriptions(tx ReadTx) ([]PostSubscription, error)
- func (db *DB) ListPosts(tx ReadTx) ([]PostSummary, error)
- func (db *DB) ListSendQueue(tx ReadTx) ([]SendQueueElement, error)
- func (db *DB) ListSharedFiles(tx ReadTx, uid *UserID) ([]rpc.FileMetadata, error)
- func (db *DB) ListUnackedUserRMs(tx ReadTx) ([]UnackedRM, error)
- func (db *DB) ListUserPosts(tx ReadTx, from UserID) ([]rpc.PostMetadata, error)
- func (db *DB) LoadAddressBook(tx ReadTx, localID *zkidentity.FullIdentity) ([]*AddressBookEntry, error)
- func (db *DB) LoadTransResetHalfKX(tx ReadTx, id UserID, localID *zkidentity.FullIdentity) (*ratchet.Ratchet, error)
- func (db *DB) LocalID(tx ReadTx) (*zkidentity.FullIdentity, error)
- func (db *DB) LogGCMsg(tx ReadWriteTx, gcName string, gcID zkidentity.ShortID, internal bool, ...) error
- func (db *DB) LogPM(tx ReadWriteTx, uid UserID, internal bool, from, msg string, ts time.Time) error
- func (db *DB) MarkChunkUploadInvoiceExpired(tx ReadWriteTx, uid UserID, fid FileID, cid ChunkID, index int, invoice string) error
- func (db *DB) MarkChunkUploadInvoiceSent(tx ReadWriteTx, uid UserID, fid FileID, cid ChunkID, index int) error
- func (db *DB) MarkChunkUploadPaid(tx ReadWriteTx, uid UserID, fid FileID, cid ChunkID, index int, invoice string) error
- func (db *DB) MarkChunkUploadSent(tx ReadWriteTx, uid UserID, fid FileID, cid ChunkID, index int) error
- func (db *DB) MarkGCInviteAccepted(tx ReadWriteTx, inviteID uint64) error
- func (db *DB) MarkRVUnpaid(tx ReadWriteTx, rv ratchet.RVPoint) error
- func (db *DB) MissingFileDownloadChunks(tx ReadTx, fd *FileDownload) []int
- func (db *DB) PostExists(tx ReadTx, from UserID, post PostID) (bool, error)
- func (db *DB) ReadFileDownload(tx ReadTx, uid UserID, fid FileID) (FileDownload, error)
- func (db *DB) ReadPost(tx ReadTx, from UserID, post PostID) (rpc.PostMetadata, error)
- func (db *DB) RecordUserPayEvent(tx ReadWriteTx, user UserID, event string, amount, payFee int64) error
- func (db *DB) RemoveFromGCBlockList(tx ReadWriteTx, gcid zkidentity.ShortID, uid UserID) error
- func (db *DB) RemoveFromSendQueue(tx ReadWriteTx, id SendQID, dest UserID) error
- func (db *DB) RemoveInitialKXActions(tx ReadWriteTx, initialRV zkidentity.ShortID) error
- func (db *DB) RemoveKXSearch(tx ReadWriteTx, target UserID) error
- func (db *DB) RemoveMediateID(tx ReadWriteTx, mediator, target UserID) error
- func (db *DB) RemovePostKXActions(tx ReadWriteTx, target UserID) error
- func (db *DB) RemoveRelayedPostCopies(author UserID, pid PostID) error
- func (db *DB) RemoveUser(tx ReadWriteTx, id UserID, block bool) error
- func (db *DB) RemoveUserUnackedRMWithRV(tx ReadWriteTx, uid UserID, rv RawRVID) (bool, error)
- func (db *DB) ReplaceFileDownloadChunkState(tx ReadWriteTx, fd *FileDownload, chunkIdx int, chunkState ChunkState) error
- func (db *DB) ReplaceFileDownloadInvoices(tx ReadWriteTx, fd *FileDownload, invoices map[int]string) error
- func (db *DB) ReplaceLastConnDate(tx ReadWriteTx, date time.Time) (time.Time, error)
- func (db *DB) Run(ctx context.Context) error
- func (db *DB) RunStarted() <-chan struct{}
- func (db *DB) SaveFileDownloadChunk(tx ReadWriteTx, user string, fd *FileDownload, chunkIdx int, data []byte) (string, error)
- func (db *DB) SaveGC(tx ReadWriteTx, gc rpc.RMGroupList) error
- func (db *DB) SaveKX(tx ReadWriteTx, kx KXData) error
- func (db *DB) SaveRVPaid(tx ReadWriteTx, rv ratchet.RVPoint) error
- func (db *DB) SaveReceivedPost(tx ReadWriteTx, from UserID, p rpc.PostMetadata) (PostID, PostSummary, error)
- func (db *DB) ServerID(tx ReadTx) ([]byte, zkidentity.PublicIdentity, error)
- func (db *DB) SetGCAlias(tx ReadWriteTx, gcID zkidentity.ShortID, name string) (map[string]zkidentity.ShortID, error)
- func (db *DB) ShareFile(tx ReadWriteTx, fname string, uid *UserID, cost uint64, descr string, ...) (SharedFile, rpc.FileMetadata, error)
- func (db *DB) StartFileDownload(tx ReadWriteTx, uid UserID, fid FileID, isSentFile bool) (FileDownload, error)
- func (db *DB) StoreMediateIDRequested(tx ReadWriteTx, mediator, target UserID) error
- func (db *DB) StorePostSubscription(tx ReadWriteTx, to UserID) error
- func (db *DB) StorePostUnsubscription(tx ReadWriteTx, to UserID) error
- func (db *DB) StorePushPaymentAttempt(tx ReadWriteTx, rv ratchet.RVPoint, invoice string, time time.Time) error
- func (db *DB) StoreTransResetHalfKX(tx ReadWriteTx, r *ratchet.Ratchet, theirID zkidentity.ShortID) error
- func (db *DB) StoreUserUnackedRM(tx ReadWriteTx, uid UserID, encrypted []byte, rv RawRVID, payEvent string) error
- func (db *DB) SubscribeToPosts(tx ReadWriteTx, user UserID) error
- func (db *DB) SummarizeUserPayStats(tx ReadTx, uid UserID) ([]PayStatsSummary, error)
- func (db *DB) UnshareFile(tx ReadWriteTx, fid FileID, uid *UserID) error
- func (db *DB) UnsubscribeToPosts(tx ReadWriteTx, user UserID) error
- func (db *DB) Update(ctx context.Context, f func(tx ReadWriteTx) error) error
- func (db *DB) UpdateAddressBookEntry(tx ReadWriteTx, id *zkidentity.PublicIdentity, myResetRV, theirResetRV RawRVID, ...) error
- func (db *DB) UpdateFileDownloadMetadata(tx ReadWriteTx, fd *FileDownload, md rpc.FileMetadata) error
- func (db *DB) UpdateLocalID(tx ReadWriteTx, id *zkidentity.FullIdentity) error
- func (db *DB) UpdateRatchet(tx ReadWriteTx, r *ratchet.Ratchet, theirID zkidentity.ShortID) error
- func (db *DB) UpdateServerID(tx ReadWriteTx, tlsCert []byte, pid *zkidentity.PublicIdentity) error
- func (db *DB) View(ctx context.Context, f func(tx ReadTx) error) error
- type FileDownload
- type FileID
- type GCAddressBookEntry
- type GCBlockList
- type GCInvite
- type KXData
- type KXSearch
- type KXSearchQuery
- type KXStage
- type MediateIDRequest
- type PayStatEvent
- type PayStatsSummary
- type PostID
- type PostKXAction
- type PostKXActionType
- type PostSubscription
- type PostSummary
- type RawRVID
- type ReadTx
- type ReadWriteTx
- type RemoteFile
- type SendQID
- type SendQueueElement
- type SharedFile
- type SharedFileAndShares
- type UnackedRM
- type UserID
- type UserPayStats
Constants ¶
This section is empty.
Variables ¶
var ( LocalIDEmptyError = errors.New("local ID is not initialized") ServerIDEmptyError = errors.New("server ID is not known") ErrNotFound = errors.New("entry not found") ErrAlreadySubscribed = errors.New("already subscribed") ErrNotSubscribed = errors.New("not subscribed") ErrPostStatusValidation = errors.New("invalid post status update") ErrAlreadyExists = errors.New("already exists") ErrDuplicatePostStatus = errors.New("duplicate post status") )
Functions ¶
func RMGroupListToGCEntry ¶
func RMGroupListToGCEntry(gc *rpc.RMGroupList, entry *GCAddressBookEntry)
Types ¶
type AddressBookEntry ¶
type AddressBookEntry struct { ID *zkidentity.PublicIdentity `json:"id"` R *ratchet.Ratchet `json:"r"` MyResetRV RawRVID `json:"myResetRV"` TheirResetRV RawRVID `json:"theirResetRV"` Ignored bool `json:"ignored"` }
type ChunkID ¶
type ChunkID = clientintf.ID
type ChunkState ¶
type ChunkState string
const ( ChunkStateHasInvoice ChunkState = "has_invoice" ChunkStatePayingInvoice ChunkState = "paying_invoice" ChunkStateSentInvoice ChunkState = "sent_invoice" ChunkStateRequestedChunk ChunkState = "requested_chunk" ChunkStatePaid ChunkState = "paid" ChunkStateUploaded ChunkState = "uploaded" ChunkStateDownloaded ChunkState = "downloaded" )
type ChunkUpload ¶
type Config ¶
type Config struct { // Root is where the db data is stored. Root string // MsgsRoot is where the logged messages (PMs, GC Msgs, etc) are // stored. MsgsRoot string // LocalID is used to initialize the DB with an ID if one does not yet // exist. If nil, a new, random ID is created. Unused if the DB is // already initialized. LocalIDInitier func() zkidentity.FullIdentity Logger slog.Logger // ChunkSize is the size to use when chunking files. Values <= 0 means // no chunking. ChunkSize int // DownloadsRoot is where to put final downloaded files. DownloadsRoot string }
type DB ¶
func (*DB) AddChunkUploadInvoice ¶
func (db *DB) AddChunkUploadInvoice(tx ReadWriteTx, uid UserID, fid FileID, cid ChunkID, index int, invoice string) error
AddChunkUploadInvoice registers the given invoice as one intended to pay for the upload of a file chunk.
func (*DB) AddGCInvite ¶
func (db *DB) AddGCInvite(tx ReadWriteTx, user UserID, invite rpc.RMGroupInvite) (uint64, error)
func (*DB) AddInitialKXAction ¶ added in v0.1.6
func (db *DB) AddInitialKXAction(tx ReadWriteTx, initialRV zkidentity.ShortID, action PostKXAction) error
AddInitialKXAction adds an action to be taken after kx completes with the given initial rendezvous.
func (*DB) AddKXSearchQuery ¶
func (db *DB) AddKXSearchQuery(tx ReadWriteTx, target UserID, search rpc.RMKXSearch, query KXSearchQuery) error
AddKXSearchQuery updates the search for a given KX opportunity with the target user and adds the specified query to the list of attempted queries.
func (*DB) AddPostKXAction ¶
func (db *DB) AddPostKXAction(tx ReadWriteTx, target UserID, action PostKXAction) error
AddPostKXAction adds an action to be taken after kx completes with the given target user.
func (*DB) AddPostStatus ¶
func (db *DB) AddPostStatus(tx ReadWriteTx, postFrom, statusFrom UserID, pid PostID, pms *rpc.PostMetadataStatus) error
AddPostStatus adds a status update to a post. postFrom is the relayer of the post, while statusFrom is who sent the status update.
func (*DB) AddPostStatusUpdate ¶
func (db *DB) AddPostStatusUpdate(tx ReadWriteTx, from UserID, p rpc.PostMetadata) (UserID, rpc.PostMetadataStatus, error)
AddPostStatusUpdate saves the specified post metadata as a status update for the given post.
func (*DB) AddToGCBlockList ¶
func (db *DB) AddToGCBlockList(tx ReadWriteTx, gcid zkidentity.ShortID, uid UserID) error
AddToGCBlocklist adds the given UID to the block list of the specified GC.
func (*DB) AddToSendQueue ¶
func (db *DB) AddToSendQueue(tx ReadWriteTx, typ string, dests []UserID, msg []byte, priority uint) (SendQID, error)
AddToSendQueue creates a new send queue element to send the given msg to the specified destinations.
func (*DB) AddUniquePostKXAction ¶
func (db *DB) AddUniquePostKXAction(tx ReadWriteTx, target UserID, action PostKXAction) error
AddUniquePostKXAction adds a post-kx action unless an action of the same type and data already exists.
func (*DB) CancelFileDownload ¶
func (db *DB) CancelFileDownload(tx ReadWriteTx, fid FileID) error
CancelFileDownload removes the in-progress download from the DB.
func (*DB) CleanupPaidRVs ¶
func (db *DB) CleanupPaidRVs(tx ReadWriteTx, expirationDays int) error
CleanupPaidRVs cleans up the paid RVs dir.
func (*DB) CleanupPushPaymentAttempts ¶ added in v0.1.4
func (db *DB) CleanupPushPaymentAttempts(tx ReadWriteTx, limit time.Time) error
CleanupPushPaymentAttempts removes all registered attempts to pay to push to RVs if they are older than the passed limit time.
func (*DB) ClearPayStats ¶
func (db *DB) ClearPayStats(tx ReadWriteTx, user *UserID) error
ClearPayStats removes pay stats for the given user or for all users if user equals nil.
func (*DB) CreatePost ¶
func (db *DB) CreatePost(tx ReadWriteTx, post, descr string, fname string, extraAttrs map[string]string, me *zkidentity.FullIdentity) (PostSummary, rpc.PostMetadata, error)
CreatePost creates the given post in the local DB.
Note that the optional file specified in fname is **copied** to the post.
func (*DB) DelAllInvitesToGC ¶ added in v0.1.6
func (db *DB) DelAllInvitesToGC(tx ReadWriteTx, gcid zkidentity.ShortID) error
DelAllInvitesToGC removes all invites to the given GC.
func (*DB) DelGCInvite ¶
func (db *DB) DelGCInvite(tx ReadWriteTx, inviteID uint64) error
func (*DB) DeleteGC ¶
func (db *DB) DeleteGC(tx ReadWriteTx, gcID zkidentity.ShortID) error
func (*DB) DeletePushPaymentAttempt ¶ added in v0.1.4
func (db *DB) DeletePushPaymentAttempt(tx ReadWriteTx, rv ratchet.RVPoint) error
DeletePushPaymentAttempt removes the attempt to pay to push to the specified RV.
func (*DB) DeleteTransResetHalfKX ¶
func (db *DB) DeleteTransResetHalfKX(tx ReadWriteTx, id UserID) error
DeleteTransResetHalfKX removes the trans reset half-ratchet associated with the given ID.
It returns the contents of the trans reset ratchet file.
func (*DB) FindAcceptedGCInvite ¶ added in v0.1.6
func (db *DB) FindAcceptedGCInvite(tx ReadTx, gcID, uid zkidentity.ShortID) (rpc.RMGroupInvite, uint64, error)
FindAcceptedGCInvite looks for an invite to a GC sent by the specified user that has been previously marked as accepted.
func (*DB) FindGCInvite ¶
func (db *DB) FindGCInvite(tx ReadTx, gcID zkidentity.ShortID, token uint64) (rpc.RMGroupInvite, UserID, uint64, error)
FindGCInvite looks for an invite to a GC with a given token.
func (*DB) FindSharedFileID ¶
FindSharedFileID is used to find the file ID of a file shared with the given filename.
func (*DB) GetAddressBookEntry ¶
func (db *DB) GetAddressBookEntry(tx ReadTx, id UserID, localID *zkidentity.FullIdentity) (*AddressBookEntry, error)
func (*DB) GetFileChunkUpload ¶
func (db *DB) GetFileChunkUpload(tx ReadTx, uid UserID, fid FileID, cid ChunkID) (ChunkUpload, error)
GetFileChunkUpload returns an existing chunk upload info.
func (*DB) GetGC ¶
func (db *DB) GetGC(tx ReadTx, id zkidentity.ShortID) (rpc.RMGroupList, error)
func (*DB) GetGCAliases ¶
func (*DB) GetGCBlockList ¶
func (db *DB) GetGCBlockList(tx ReadTx, gcid zkidentity.ShortID) (GCBlockList, error)
GetGCBlockList returns the block list of the specified GC. Returns nil if there is no block list.
func (*DB) GetGCInvite ¶
func (*DB) GetKXSearch ¶
GetKXSearch returns the KX search for a given target, if it exists.
func (*DB) GetSharedFile ¶
func (db *DB) GetSharedFile(tx ReadTx, uid *UserID, fid FileID) (SharedFile, rpc.FileMetadata, error)
GetSharedFile returns information about the given shared file. If uid is nil, then it's assumed the shared file is on the global dir.
func (*DB) GetSharedFileChunkData ¶
GetSharedFileChunkData returns the actual chunk data for a given shared file.
func (*DB) GetSharedFileForUpload ¶
func (db *DB) GetSharedFileForUpload(tx ReadTx, uid UserID, fid FileID) (SharedFile, rpc.FileMetadata, error)
GetSharedFileForUpload returns information about the given file if the user is allowed to fetch it (either by the file having been shared with the user or if the file is globally shared)
func (*DB) HasAnyRecentMediateID ¶
func (db *DB) HasAnyRecentMediateID(tx ReadTx, target UserID, recentThreshold time.Duration) (bool, error)
HasAnyRecentMediateID looks if there are any attempts to mediate identity to the given target user with any mediator that is no older than the specified recentThreshold.
func (*DB) HasDownloadedFile ¶
HasDownloadedFile returns the path to the completed downloaded file (if it exists).
func (*DB) HasDownloadedFiles ¶
func (db *DB) HasDownloadedFiles(tx ReadTx, user string, uid UserID, files []rpc.FileMetadata) ([]RemoteFile, error)
HasDownloadedFiles converts the given list of file metadata (possibly received) from a remote user into a list of files that we may have already downloaded.
func (*DB) HasMediateID ¶
func (db *DB) HasMediateID(tx ReadTx, mediator, target UserID) (MediateIDRequest, error)
HasMediateID returns info about a request to mediate ID made to a mediator for introduction to a target.
func (*DB) HasPushPaymentAttempt ¶ added in v0.1.4
HasPushPaymentAttempt returns the data for an attempt to pay to push to the specified RV, if one exists. It returns an empty invoice with a nil error if there is no attempt.
func (*DB) InitialToPostKXActions ¶ added in v0.1.6
func (db *DB) InitialToPostKXActions(tx ReadWriteTx, initialRV, target zkidentity.ShortID) error
InitialToPostKXAction converts an action based on initial rendezvous to a known user id.
func (*DB) IsPostSubscriber ¶
IsPostSubscriber returns whether the given uid is a subscriber to the local client's posts.
func (*DB) IsPostSubscription ¶
IsPostSubscription returns true if the local client is subscribed to the posts of the given user.
func (*DB) ListAllSharedFiles ¶
func (db *DB) ListAllSharedFiles(tx ReadTx) ([]SharedFileAndShares, error)
ListAllSharedFiles lists both globally and user shared files for all files.
func (*DB) ListGCInvites ¶
ListGCInvites lists the GC invites. If gc is specified, lists only invites for the specified GCID.
func (*DB) ListKXSearches ¶
ListKXSearches lists the IDs of all outstanding users being KX searched for.
func (*DB) ListMediateIDs ¶
func (db *DB) ListMediateIDs(tx ReadTx) ([]MediateIDRequest, error)
ListMediateIDs lists all existing mediate id requests.
func (*DB) ListOutstandingDownloads ¶
func (db *DB) ListOutstandingDownloads(tx ReadTx) ([]FileDownload, error)
func (*DB) ListOutstandingUploads ¶
func (db *DB) ListOutstandingUploads(tx ReadTx) ([]ChunkUpload, error)
func (*DB) ListPayStats ¶
func (db *DB) ListPayStats(tx ReadTx) (map[UserID]UserPayStats, error)
ListPayStats lists the global (per-user) payment stats.
func (*DB) ListPostKXActions ¶
func (db *DB) ListPostKXActions(tx ReadTx, target UserID) ([]PostKXAction, error)
ListPostKXActions lists the post-kx actions registered for the given target user.
func (*DB) ListPostRelayers ¶
ListPostRelayers lists everyone that has relayed (to us) the specified post.
func (*DB) ListPostStatusUpdates ¶
func (db *DB) ListPostStatusUpdates(tx ReadTx, from UserID, post PostID) ([]rpc.PostMetadataStatus, error)
ListPostStatusUpdates lists the status updates of the currently received posts.
func (*DB) ListPostSubscribers ¶
ListSubscribers lists all users that are subscribed to our posts.
func (*DB) ListPostSubscriptions ¶
func (db *DB) ListPostSubscriptions(tx ReadTx) ([]PostSubscription, error)
ListPostSubscriptions returns a list of posts this user has subscribed to.
func (*DB) ListPosts ¶
func (db *DB) ListPosts(tx ReadTx) ([]PostSummary, error)
ListPosts returns a summary of all received posts.
func (*DB) ListSendQueue ¶
func (db *DB) ListSendQueue(tx ReadTx) ([]SendQueueElement, error)
ListSendQueue lists all send queues registered.
func (*DB) ListSharedFiles ¶
ListSharedFile lists the files shared with a given user or shared files with all users.
func (*DB) ListUnackedUserRMs ¶
ListUnackedtUserRMs lists unacked RMs from all users.
func (*DB) ListUserPosts ¶
ListUserPosts lists all posts made by the given user.
func (*DB) LoadAddressBook ¶
func (db *DB) LoadAddressBook(tx ReadTx, localID *zkidentity.FullIdentity) ([]*AddressBookEntry, error)
LoadAddressBook returns the full client address book. Note that invalid or otherwise incomplete entries do not cause the addressbook loading to fail, only diagnostic messages are returned in that case.
func (*DB) LoadTransResetHalfKX ¶
func (db *DB) LoadTransResetHalfKX(tx ReadTx, id UserID, localID *zkidentity.FullIdentity) (*ratchet.Ratchet, error)
LoadTransResetHalfKX returns the existing trans reset half kx.
func (*DB) LocalID ¶
func (db *DB) LocalID(tx ReadTx) (*zkidentity.FullIdentity, error)
func (*DB) LogGCMsg ¶
func (db *DB) LogGCMsg(tx ReadWriteTx, gcName string, gcID zkidentity.ShortID, internal bool, from, msg string, ts time.Time) error
LogGCMsg logs a GC message sent in the given GC.
func (*DB) LogPM ¶
func (db *DB) LogPM(tx ReadWriteTx, uid UserID, internal bool, from, msg string, ts time.Time) error
LogPM logs a PM message from the given user.
func (*DB) MarkChunkUploadInvoiceExpired ¶
func (db *DB) MarkChunkUploadInvoiceExpired(tx ReadWriteTx, uid UserID, fid FileID, cid ChunkID, index int, invoice string) error
MarkChunkUploadInvoiceExpired registers the given invoice as expired and thus unusable to pay for a chunk upload.
func (*DB) MarkChunkUploadInvoiceSent ¶
func (db *DB) MarkChunkUploadInvoiceSent(tx ReadWriteTx, uid UserID, fid FileID, cid ChunkID, index int) error
MarkChunkUploadInvoiceSent registers the given upload chunk as having had its latest invoice sent to the remote user.
func (*DB) MarkChunkUploadPaid ¶
func (db *DB) MarkChunkUploadPaid(tx ReadWriteTx, uid UserID, fid FileID, cid ChunkID, index int, invoice string) error
MarkChunkUploadPaid registers the given invoice as having been paid for the given chunk upload.
func (*DB) MarkChunkUploadSent ¶
func (db *DB) MarkChunkUploadSent(tx ReadWriteTx, uid UserID, fid FileID, cid ChunkID, index int) error
MarkChunkUploadSent registers the given upload as having been sent to the remote user.
func (*DB) MarkGCInviteAccepted ¶
func (db *DB) MarkGCInviteAccepted(tx ReadWriteTx, inviteID uint64) error
func (*DB) MarkRVUnpaid ¶
func (db *DB) MarkRVUnpaid(tx ReadWriteTx, rv ratchet.RVPoint) error
MarkRVUnpaid forcefully marks the given RV as unpaid.
func (*DB) MissingFileDownloadChunks ¶
func (db *DB) MissingFileDownloadChunks(tx ReadTx, fd *FileDownload) []int
func (*DB) PostExists ¶
PostExists verifies whether the given received post already exists.
func (*DB) ReadFileDownload ¶
func (*DB) RecordUserPayEvent ¶
func (db *DB) RecordUserPayEvent(tx ReadWriteTx, user UserID, event string, amount, payFee int64) error
RecordUserPayEvent records the given amount as a payment event. If amount is < 0, then this means a payment was made related to this user. If amount > 0 this means a payment was received from this user.
The amount is recorded in Milli-atoms.
func (*DB) RemoveFromGCBlockList ¶
func (db *DB) RemoveFromGCBlockList(tx ReadWriteTx, gcid zkidentity.ShortID, uid UserID) error
RemoveFromGCBlockList removes the given UID from the block list of the specified GC.
func (*DB) RemoveFromSendQueue ¶
func (db *DB) RemoveFromSendQueue(tx ReadWriteTx, id SendQID, dest UserID) error
RemoveFromSendQueue marks the given destination as sent on the specified queue. If the queue is now empty, it is removed from the db.
func (*DB) RemoveInitialKXActions ¶ added in v0.1.6
func (db *DB) RemoveInitialKXActions(tx ReadWriteTx, initialRV zkidentity.ShortID) error
RemoveInitialKXActions removes the initial-kx actions registered for the given initial rendezvous.
func (*DB) RemoveKXSearch ¶
func (db *DB) RemoveKXSearch(tx ReadWriteTx, target UserID) error
RemoveKXSearch removes the kx search for the given target if it exists.
func (*DB) RemoveMediateID ¶
func (db *DB) RemoveMediateID(tx ReadWriteTx, mediator, target UserID) error
RemoveMediateID removes the given request to mediate an ID.
func (*DB) RemovePostKXActions ¶
func (db *DB) RemovePostKXActions(tx ReadWriteTx, target UserID) error
RemovePostKXActions removes the post-kx actions registered for the given target user.
func (*DB) RemoveRelayedPostCopies ¶ added in v0.1.6
RemoveRelayedPostCopies removes all copies of the post that may have been relayed, except the one by the specified user, which should be the post author.
func (*DB) RemoveUser ¶
func (db *DB) RemoveUser(tx ReadWriteTx, id UserID, block bool) error
RemoveUser deletes the user from the database
func (*DB) RemoveUserUnackedRMWithRV ¶
RemoveUserUnackedRMWithRV removes the unacked rm of the specified user if one exists wth the specified RV. It does not return an error if the unacked RM did not exist. The return bool indicates whether the unacked rm existed.
func (*DB) ReplaceFileDownloadChunkState ¶
func (db *DB) ReplaceFileDownloadChunkState(tx ReadWriteTx, fd *FileDownload, chunkIdx int, chunkState ChunkState) error
func (*DB) ReplaceFileDownloadInvoices ¶
func (db *DB) ReplaceFileDownloadInvoices(tx ReadWriteTx, fd *FileDownload, invoices map[int]string) error
func (*DB) ReplaceLastConnDate ¶ added in v0.1.4
ReplaceLastConnDate replaces the last connection date of the local client to the server with the specified one. Returns the old connection date.
func (*DB) RunStarted ¶
func (db *DB) RunStarted() <-chan struct{}
func (*DB) SaveFileDownloadChunk ¶
func (db *DB) SaveFileDownloadChunk(tx ReadWriteTx, user string, fd *FileDownload, chunkIdx int, data []byte) (string, error)
func (*DB) SaveGC ¶
func (db *DB) SaveGC(tx ReadWriteTx, gc rpc.RMGroupList) error
func (*DB) SaveRVPaid ¶
func (db *DB) SaveRVPaid(tx ReadWriteTx, rv ratchet.RVPoint) error
SaveRVPaid marks the given RV as paid.
func (*DB) SaveReceivedPost ¶
func (db *DB) SaveReceivedPost(tx ReadWriteTx, from UserID, p rpc.PostMetadata) (PostID, PostSummary, error)
func (*DB) ServerID ¶
func (db *DB) ServerID(tx ReadTx) ([]byte, zkidentity.PublicIdentity, error)
func (*DB) SetGCAlias ¶
func (db *DB) SetGCAlias(tx ReadWriteTx, gcID zkidentity.ShortID, name string) ( map[string]zkidentity.ShortID, error)
SetGCAlias sets the alias for the specified GC ID as the name. If gcID is empty, the name is removed from the alias map. If gcID is filled but name is empty, the entry that points to the specified gcID is removed.
func (*DB) ShareFile ¶
func (db *DB) ShareFile(tx ReadWriteTx, fname string, uid *UserID, cost uint64, descr string, sign func([]byte) ([]byte, error)) (SharedFile, rpc.FileMetadata, error)
ShareFile registers the given file as a shared file.
If uid is nil, then the file is registered as shared among all users.
func (*DB) StartFileDownload ¶
func (db *DB) StartFileDownload(tx ReadWriteTx, uid UserID, fid FileID, isSentFile bool) (FileDownload, error)
func (*DB) StoreMediateIDRequested ¶
func (db *DB) StoreMediateIDRequested(tx ReadWriteTx, mediator, target UserID) error
StoreMediateIDRequested marks that a mediate id request was made on mediator to invite us to target.
func (*DB) StorePostSubscription ¶
func (db *DB) StorePostSubscription(tx ReadWriteTx, to UserID) error
StorePostSubscription stores that the local user has subscribed to the posts of the given user.
func (*DB) StorePostUnsubscription ¶
func (db *DB) StorePostUnsubscription(tx ReadWriteTx, to UserID) error
StorePostUnsubscription stores that the local user has unsubscribed to the posts of the given remote user.
func (*DB) StorePushPaymentAttempt ¶ added in v0.1.4
func (db *DB) StorePushPaymentAttempt(tx ReadWriteTx, rv ratchet.RVPoint, invoice string, time time.Time) error
StorePushPaymentAttempt stores that there's an inflight payment attempt to pay for pushing to the specified RV with the passed invoice. time refers to the time the attempt started.
func (*DB) StoreTransResetHalfKX ¶
func (db *DB) StoreTransResetHalfKX(tx ReadWriteTx, r *ratchet.Ratchet, theirID zkidentity.ShortID) error
StoreTransResetHalfKX stores the given ratchet as a half-ratchet used for a transitive reset call with the given user.
func (*DB) StoreUserUnackedRM ¶ added in v0.1.4
func (db *DB) StoreUserUnackedRM(tx ReadWriteTx, uid UserID, encrypted []byte, rv RawRVID, payEvent string) error
StoreUserUnackedRM stores the passed RM as unacked for the given user.
func (*DB) SubscribeToPosts ¶
func (db *DB) SubscribeToPosts(tx ReadWriteTx, user UserID) error
SubscribeToPosts registers the given remote user as subscribed to posts of the local user.
func (*DB) SummarizeUserPayStats ¶
func (db *DB) SummarizeUserPayStats(tx ReadTx, uid UserID) ([]PayStatsSummary, error)
SummarizeUserPayStats returns a summary of the payments recorded for the given user. These are grouped by the first level.
func (*DB) UnshareFile ¶
func (db *DB) UnshareFile(tx ReadWriteTx, fid FileID, uid *UserID) error
Unshare the file with the given user or globally. If the file is no longer noted as shared with anyone, the content is removed.
func (*DB) UnsubscribeToPosts ¶
func (db *DB) UnsubscribeToPosts(tx ReadWriteTx, user UserID) error
UnsubscribeToPosts removes the subscription of the given user from the posts of the local user.
func (*DB) UpdateAddressBookEntry ¶
func (db *DB) UpdateAddressBookEntry(tx ReadWriteTx, id *zkidentity.PublicIdentity, myResetRV, theirResetRV RawRVID, ignored bool) error
func (*DB) UpdateFileDownloadMetadata ¶
func (db *DB) UpdateFileDownloadMetadata(tx ReadWriteTx, fd *FileDownload, md rpc.FileMetadata) error
func (*DB) UpdateLocalID ¶
func (db *DB) UpdateLocalID(tx ReadWriteTx, id *zkidentity.FullIdentity) error
func (*DB) UpdateRatchet ¶
func (db *DB) UpdateRatchet(tx ReadWriteTx, r *ratchet.Ratchet, theirID zkidentity.ShortID) error
func (*DB) UpdateServerID ¶
func (db *DB) UpdateServerID(tx ReadWriteTx, tlsCert []byte, pid *zkidentity.PublicIdentity) error
type FileDownload ¶
type FileDownload struct { UID UserID `json:"uid"` FID FileID `json:"fid"` CompletedName string `json:"completed_name"` Metadata *rpc.FileMetadata `json:"metadata"` Invoices map[int]string `json:"invoices"` // Key is chunk index ChunkStates map[int]ChunkState `json:"chunkstates"` ChunkUpdatedTime map[int]time.Time `json:"chunkupdttimes"` IsSentFile bool `json:"is_sent_file"` }
func (*FileDownload) CountChunks ¶
func (fd *FileDownload) CountChunks(atState ChunkState) int
CountChunks returns how many chunks there are at the given chunk state.
func (*FileDownload) GetChunkInvoice ¶
func (fd *FileDownload) GetChunkInvoice(chunkIdx int) string
func (*FileDownload) GetChunkState ¶
func (fd *FileDownload) GetChunkState(chunkIdx int) ChunkState
type FileID ¶
type FileID = clientintf.ID
type GCAddressBookEntry ¶
type GCAddressBookEntry struct { ID zkidentity.ShortID `json:"id"` Members []UserID `json:"members"` }
type GCBlockList ¶
type GCBlockList map[string]struct{}
func (GCBlockList) FilterMembers ¶
func (gcbl GCBlockList) FilterMembers(members []UserID) []UserID
FilterMembers filters the list of members, removing any that is in the block list.
func (GCBlockList) IsBlocked ¶
func (gcbl GCBlockList) IsBlocked(uid UserID) bool
IsBlocked returns true if the given UID is part of the blocklist.
type GCInvite ¶
type GCInvite struct { Invite rpc.RMGroupInvite User UserID ID uint64 Accepted bool }
type KXData ¶
type KXData struct { // Public is the identity of the remote user. This is empty for the // source user and filled with the source user's public id on the // target user. Public zkidentity.PublicIdentity `json:"public"` // InitialRV is the random RV generated by the source user. InitialRV RawRVID `json:"initial_rv"` // Step3RV is the random RV generated by the target user. Step3RV RawRVID `json:"step3_rv"` // HalfRatchet is filled by the target user, after accepting the invite // but before the source user replied with their half ratchet in // Step3RV. HalfRatchet *disk.RatchetState `json:"half_ratchet"` // MyResetRV is the RV that the local client listens to for reset // requests from the remote client. MyResetRV RawRVID `json:"my_resetrv"` // TheirResetRV is the RV that the remote client listens to for // reset requests from the local client. TheirResetRV RawRVID `json:"their_resetrv"` // Stage is the current stage of the KX process. Stage KXStage `json:"stage"` // Timestamp is the time when this KX data was stored. Timestamp time.Time `json:"timestamp"` // Invitee is set in the source user when the the invite was created // to be fulfilled by a known target user, usually as a result of // a mediated KX. Invitee *zkidentity.PublicIdentity `json:"invitee"` // IsForReset flags whether this KX request was initiated by a reset // request. IsForReset bool `json:"is_for_reset"` // MediatorID is the identity of a remote user that requested this // invite be created (not the source user). MediatorID *UserID `json:"mediator_id"` }
KXData holds information about outstanding KX sessions. In the description of the fields, the "source" user is the one that generated the initial invite and the "target" user is the one accepting the invite.
type KXSearch ¶
type KXSearch struct { Target clientintf.ID `json:"target"` Search rpc.RMKXSearch `json:"search"` Queries []KXSearchQuery `json:"queries"` }
KXSearch holds the queries performed when searching for a user.
type KXSearchQuery ¶
type KXSearchQuery struct { User clientintf.ID `json:"user"` DateSent time.Time `json:"date_sent"` IDsReceived []clientintf.ID `json:"ids_received"` }
KXSeachQuery holds a specific target used while searching for a KX.
type MediateIDRequest ¶
type MediateIDRequest struct { Mediator UserID `json:"mediator"` Target UserID `json:"target"` Date time.Time `json:"date"` }
MediateIDRequest is used to track in flight mediate identity requests.
type PayStatEvent ¶
type PayStatsSummary ¶
type PostID ¶
type PostID = clientintf.PostID
type PostKXAction ¶
type PostKXAction struct { Type PostKXActionType `json:"type"` DateAdded time.Time `json:"date_added"` Data string `json:"data"` }
type PostKXActionType ¶
type PostKXActionType string
const ( PKXActionKXSearch PostKXActionType = "kx_search" PKXActionFetchPost PostKXActionType = "fetch_post" PKXActionInviteGC PostKXActionType = "invite_gc" )
type PostSubscription ¶
type PostSummary ¶
type PostSummary struct { ID PostID `json:"id"` From UserID `json:"from"` AuthorID UserID `json:"author_id"` AuthorNick string `json:"author_nick"` Date time.Time `json:"date"` LastStatusTS time.Time `json:"last_status_ts"` Title string `json:"title"` }
func PostSummFromMetadata ¶
func PostSummFromMetadata(post *rpc.PostMetadata, from UserID) PostSummary
PostSummFromMetadata creates the basic post summary info from the given post metadata.
type RawRVID ¶
type RawRVID = clientintf.RawRVID
type ReadWriteTx ¶
type RemoteFile ¶
type RemoteFile struct { FID FileID `json:"file_id"` UID UserID `json:"uid"` DiskPath string `json:"disk_path"` Metadata rpc.FileMetadata `json:"metadata"` }
type SendQID ¶
type SendQID = clientintf.ID
type SendQueueElement ¶
type SharedFile ¶
type SharedFile struct { clientintf.ID `json:"file_hash"` // content hash). FID FileID `json:"fid"` Filename string `json:"filename"` }FileHash
type SharedFileAndShares ¶
type SharedFileAndShares struct {}
SharedFileAndShares tracks all the shares made for the given shared file.
type UnackedRM ¶
type UnackedRM struct { UID UserID `json:"uid"` Encrypted []byte `json:"encrypted"` RV RawRVID `json:"rv"` PayEvent string `json:"pay_event"` }
UnackedRM is an already encrypted but unacked RM.
type UserID ¶
type UserID = clientintf.UserID