Documentation
¶
Index ¶
- Variables
- func RMGroupListToGCEntry(gc *rpc.RMGroupList, entry *GCAddressBookEntry)
- type AddressBookAndRatchet
- type AddressBookEntry
- type ChunkID
- type ChunkState
- type ChunkUpload
- type Config
- type ContentFilter
- 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) Backup(_ ReadTx, rootDir, destPath string) (string, error)
- func (db *DB) CacheReceivedGCM(tx ReadWriteTx, rgcm clientintf.ReceivedGCMsg) error
- 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) (*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) HasKXWithUser(tx ReadTx, target UserID) ([]KXData, error)
- func (db *DB) HasMediateID(tx ReadTx, mediator, target UserID) (MediateIDRequest, error)
- func (db *DB) HasOnboardState(tx ReadTx) bool
- 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) KXExists(tx ReadTx, initialRV RawRVID) bool
- func (db *DB) ListAllSharedFiles(tx ReadTx) ([]SharedFileAndShares, error)
- func (db *DB) ListCachedRGCMs(tx ReadTx) ([]clientintf.ReceivedGCMsg, error)
- func (db *DB) ListContentFilters(tx ReadTx) ([]ContentFilter, error)
- func (db *DB) ListGCInvites(tx ReadTx, gc *zkidentity.ShortID) ([]*GCInvite, error)
- func (db *DB) ListGCs(tx ReadTx) ([]rpc.RMGroupList, error)
- func (db *DB) ListGCsWithMember(tx ReadTx, uid UserID) ([]zkidentity.ShortID, error)
- func (db *DB) ListGeneratedTipInvoices(tx ReadTx) ([]GeneratedInvoiceForTip, 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) ListOldestValidTipUserAttempts(tx ReadTx, maxLifetime time.Duration) ([]TipUserAttempt, 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) ListTipUserAttempts(tx ReadTx, uid UserID) ([]TipUserAttempt, 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) ([]AddressBookAndRatchet, 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) MarkGeneratedTipInvoiceExpired(tx ReadWriteTx, uid UserID, invoice string) error
- func (db *DB) MarkGeneratedTipInvoiceReceived(tx ReadWriteTx, uid UserID, invoice string, receivedMAtoms int64) error
- func (db *DB) MarkRVUnpaid(tx ReadWriteTx, rv ratchet.RVPoint) error
- func (db *DB) MissingFileDownloadChunks(tx ReadTx, fd *FileDownload) []int
- func (db *DB) NewPagesSession(tx ReadWriteTx) (clientintf.PagesSessionID, error)
- func (db *DB) NextTipAttemptToRetryForUser(tx ReadTx, uid UserID, maxLifetime time.Duration) (TipUserAttempt, error)
- func (db *DB) OnchainRecvAddrForUser(tx ReadTx, uid UserID) (string, error)
- 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) ReadLogGCMsg(tx ReadTx, gcName string, gcID zkidentity.ShortID, page, pageNum int) ([]PMLogEntry, error)
- func (db *DB) ReadLogPM(tx ReadTx, uid UserID, page, pageNum int) ([]PMLogEntry, error)
- func (db *DB) ReadOnboardState(tx ReadTx) (clientintf.OnboardState, error)
- func (db *DB) ReadPost(tx ReadTx, from UserID, post PostID) (rpc.PostMetadata, error)
- func (db *DB) ReadTipAttempt(tx ReadWriteTx, uid UserID, tag int32) (TipUserAttempt, error)
- func (db *DB) ReadUnxkdUserInfo(tx ReadTx, uid UserID) (UnkxdUserInfo, error)
- func (db *DB) RecordUserPayEvent(tx ReadWriteTx, user UserID, event string, amount, payFee int64) error
- func (db *DB) RemoveCachedRGCM(tx ReadWriteTx, rgcm clientintf.ReceivedGCMsg) error
- func (db *DB) RemoveContentFilter(tx ReadWriteTx, filterID uint64) 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) RemoveOnboardState(tx ReadWriteTx) error
- func (db *DB) RemovePostKXActions(tx ReadWriteTx, target UserID) error
- func (db *DB) RemoveRelayedPostCopies(author UserID, pid PostID) error
- func (db *DB) RemoveTipUserAttempt(tx ReadWriteTx, uid UserID, tag int32) error
- func (db *DB) RemoveUnkxUserInfo(tx ReadWriteTx, uid UserID) 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) StoreContentFilter(tx ReadWriteTx, filter *ContentFilter) error
- func (db *DB) StoreFetchedResource(tx ReadWriteTx, uid UserID, tag rpc.ResourceTag, ...) (FetchedResource, PageSessionOverview, error)
- func (db *DB) StoreGeneratedTipInvoice(tx ReadWriteTx, uid UserID, invoice string, amountMAtoms int64) 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) StoreResourceRequest(tx ReadWriteTx, uid UserID, sess, parentPage clientintf.PagesSessionID, ...) error
- func (db *DB) StoreTipUserAttempt(tx ReadWriteTx, ta TipUserAttempt) error
- func (db *DB) StoreTransResetHalfKX(tx ReadWriteTx, r *ratchet.Ratchet, theirID zkidentity.ShortID) error
- func (db *DB) StoreUnkxdUserInfo(tx ReadWriteTx, info UnkxdUserInfo) 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) UnusedTipUserTag(tx ReadWriteTx, uid clientintf.UserID) int32
- func (db *DB) Update(ctx context.Context, f func(tx ReadWriteTx) error) error
- func (db *DB) UpdateAddressBookEntry(tx ReadWriteTx, ab *AddressBookEntry) 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) UpdateOnboardState(tx ReadWriteTx, st *clientintf.OnboardState) error
- func (db *DB) UpdateOnchainRecvAddrForUser(tx ReadWriteTx, uid UserID, addr string) 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) UserWithOnchainRecvAddr(tx ReadTx, addr string) *UserID
- func (db *DB) View(ctx context.Context, f func(tx ReadTx) error) error
- type FetchedResource
- type FileDownload
- type FileID
- type GCAddressBookEntry
- type GCBlockList
- type GCInvite
- type GeneratedInvoiceForTip
- type KXData
- type KXSearch
- type KXSearchQuery
- type KXStage
- type MediateIDRequest
- type PMLogEntry
- type PageSessionOverview
- type PageSessionOverviewRequest
- type PageSessionOverviewResponse
- type PayStatEvent
- type PayStatsSummary
- type PostID
- type PostKXAction
- type PostKXActionType
- type PostSubscription
- type PostSummary
- type RawRVID
- type ReadTx
- type ReadWriteTx
- type RemoteFile
- type ResourceRequest
- type SendQID
- type SendQueueElement
- type SharedFile
- type SharedFileAndShares
- type TipUserAttempt
- type UnackedRM
- type UnkxdUserInfo
- type UserID
- type UserPayStats
Constants ¶
This section is empty.
Variables ¶
var ( ErrLocalIDEmpty = errors.New("local ID is not initialized") ErrServerIDEmpty = 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 AddressBookAndRatchet ¶ added in v0.1.9
type AddressBookAndRatchet struct { AddressBook *AddressBookEntry Ratchet *ratchet.Ratchet }
AddressBookAndRatchet stores both the address book entry and ratchet data of a remote user.
type AddressBookEntry ¶
type AddressBookEntry struct { ID *zkidentity.PublicIdentity `json:"id"` MyResetRV RawRVID `json:"myResetRV"` TheirResetRV RawRVID `json:"theirResetRV"` Ignored bool `json:"ignored"` // FirstCreated tracks when the address book entry was first created // (i.e. first time this user was KX'd with). FirstCreated time.Time `json:"first_created"` // LastHandshake is the last time when the local client attempted // to start a handshake with this remote user. LastHandshakeAttempt time.Time `json:"last_handshake_attempt,omitempty"` }
AddressBookEntry stores contact information of a remote user.
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 ContentFilter ¶ added in v0.1.8
type ContentFilter struct { // ID is the local ID of the filter. ID uint64 // UID of the user this filter applies to. If nil, this applies to all // users. UID *UserID // GC this filter applies to. If nil, this applies to all GCs. GC *zkidentity.ShortID // SkipPMs is true if this does not apply to PMs. SkipPMs bool // SkipGCMs is true if this does not apply to GCMs. SkipGCMs bool // SkipPosts is true if this is does not apply to posts. SkipPosts bool // SkipPostComments is true if this does not apply to post comments. SkipPostComments bool // Regexp is the raw filter to apply. Regexp string }
ContentFilter stores filtering rules for content.
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) CacheReceivedGCM ¶ added in v0.1.8
func (db *DB) CacheReceivedGCM(tx ReadWriteTx, rgcm clientintf.ReceivedGCMsg) error
CacheReceivedGCM stores a cached received GC message.
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) (*AddressBookEntry, error)
GetAddressBookEntry loads the address book information of an user.
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) HasKXWithUser ¶ added in v0.1.8
HasKXWithUser returns any outstanding KX attempt with the given user. This will return KXs which were created with an invitee filled to the target ID or when they were accepted and the remote user has the target ID.
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) HasOnboardState ¶ added in v0.1.7
HasOnboardState returns true if there is an existing onboard state.
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) KXExists ¶ added in v0.1.7
KXExists returns true if there's a KX procedure with the specified RV.
func (*DB) ListAllSharedFiles ¶
func (db *DB) ListAllSharedFiles(tx ReadTx) ([]SharedFileAndShares, error)
ListAllSharedFiles lists both globally and user shared files for all files.
func (*DB) ListCachedRGCMs ¶ added in v0.1.8
func (db *DB) ListCachedRGCMs(tx ReadTx) ([]clientintf.ReceivedGCMsg, error)
ListCachedRGCMs returns any existing cached RGCM.
func (*DB) ListContentFilters ¶ added in v0.1.8
func (db *DB) ListContentFilters(tx ReadTx) ([]ContentFilter, error)
ListContentFilters returns all content filters.
func (*DB) ListGCInvites ¶
ListGCInvites lists the GC invites. If gc is specified, lists only invites for the specified GCID.
func (*DB) ListGCsWithMember ¶ added in v0.1.8
ListGCsWithMember returns IDs for GCs that have the specified user as a member.
func (*DB) ListGeneratedTipInvoices ¶ added in v0.1.8
func (db *DB) ListGeneratedTipInvoices(tx ReadTx) ([]GeneratedInvoiceForTip, error)
ListGeneratedTipInvoices lists all invoices generated for tipping from all users.
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) ListOldestValidTipUserAttempts ¶ added in v0.1.8
func (db *DB) ListOldestValidTipUserAttempts(tx ReadTx, maxLifetime time.Duration) ([]TipUserAttempt, error)
ListOldestValidTipUserAttempts returns the oldest tip user attempts (at most one per user) which have not expired yet.
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) ListTipUserAttempts ¶ added in v0.1.7
func (db *DB) ListTipUserAttempts(tx ReadTx, uid UserID) ([]TipUserAttempt, error)
ListTipUserAttempts lists existing attempts to tip remote 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) ([]AddressBookAndRatchet, 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) MarkGeneratedTipInvoiceExpired ¶ added in v0.1.8
func (db *DB) MarkGeneratedTipInvoiceExpired(tx ReadWriteTx, uid UserID, invoice string) error
MarkGeneratedTipInvoiceExpired marks an invoice generated for tipping as having expired.
func (*DB) MarkGeneratedTipInvoiceReceived ¶ added in v0.1.8
func (db *DB) MarkGeneratedTipInvoiceReceived(tx ReadWriteTx, uid UserID, invoice string, receivedMAtoms int64) error
MarkGeneratedTipInvoiceReceived marks an invoice generated for tipping as having been received (i.e. invoice was paid).
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) NewPagesSession ¶ added in v0.1.8
func (db *DB) NewPagesSession(tx ReadWriteTx) (clientintf.PagesSessionID, error)
NewPagesSession starts a new session for fetching related pages.
func (*DB) NextTipAttemptToRetryForUser ¶ added in v0.1.8
func (db *DB) NextTipAttemptToRetryForUser(tx ReadTx, uid UserID, maxLifetime time.Duration) (TipUserAttempt, error)
NextTipAttemptToRetryForUser returns the oldest non-completed, non-expired tip attempt for a given user.
func (*DB) OnchainRecvAddrForUser ¶ added in v0.1.8
OnchainRecvAddrForUser returns the onchain address for an user or an empty string if a valid address does not exist.
func (*DB) PostExists ¶
PostExists verifies whether the given received post already exists.
func (*DB) ReadFileDownload ¶
func (*DB) ReadLogGCMsg ¶ added in v0.1.8
func (db *DB) ReadLogGCMsg(tx ReadTx, gcName string, gcID zkidentity.ShortID, page, pageNum int) ([]PMLogEntry, error)
ReadLogGCMsg reads the log a GC messages sent in the given GC.
func (*DB) ReadOnboardState ¶ added in v0.1.7
func (db *DB) ReadOnboardState(tx ReadTx) (clientintf.OnboardState, error)
ReadOnboardState fetches the existing onboard state of the client. It returns an error if there is no onboard state.
func (*DB) ReadTipAttempt ¶ added in v0.1.7
func (db *DB) ReadTipAttempt(tx ReadWriteTx, uid UserID, tag int32) (TipUserAttempt, error)
ReadTipAttempt reads an existing tip attempt.
func (*DB) ReadUnxkdUserInfo ¶ added in v0.1.8
func (db *DB) ReadUnxkdUserInfo(tx ReadTx, uid UserID) (UnkxdUserInfo, error)
ReadUnxkdUserInfo returns information about an unkxed user.
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) RemoveCachedRGCM ¶ added in v0.1.8
func (db *DB) RemoveCachedRGCM(tx ReadWriteTx, rgcm clientintf.ReceivedGCMsg) error
RemoveCachedRGCM removes a previously cached received GC message if it exists.
func (*DB) RemoveContentFilter ¶ added in v0.1.8
func (db *DB) RemoveContentFilter(tx ReadWriteTx, filterID uint64) error
RemoveContentFilter removes the filter with the specified ID.
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) RemoveOnboardState ¶ added in v0.1.7
func (db *DB) RemoveOnboardState(tx ReadWriteTx) error
RemoveOnboardState removes any existing onboard state.
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) RemoveTipUserAttempt ¶ added in v0.1.7
func (db *DB) RemoveTipUserAttempt(tx ReadWriteTx, uid UserID, tag int32) error
RemoveTipUserAttempt removes the given tip user attempt.
func (*DB) RemoveUnkxUserInfo ¶ added in v0.1.8
func (db *DB) RemoveUnkxUserInfo(tx ReadWriteTx, uid UserID) error
RemoveUnkxUserInfo removes the information about an unkxed user if it exists.
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) StoreContentFilter ¶ added in v0.1.8
func (db *DB) StoreContentFilter(tx ReadWriteTx, filter *ContentFilter) error
StoreContentFilter stores the given filter in the DB.
func (*DB) StoreFetchedResource ¶ added in v0.1.8
func (db *DB) StoreFetchedResource(tx ReadWriteTx, uid UserID, tag rpc.ResourceTag, reply rpc.RMFetchResourceReply) (FetchedResource, PageSessionOverview, error)
StoreFetchedResource removes an existing request sent to the specified user with the tag, and stores the resulting fetched response.
func (*DB) StoreGeneratedTipInvoice ¶ added in v0.1.8
func (db *DB) StoreGeneratedTipInvoice(tx ReadWriteTx, uid UserID, invoice string, amountMAtoms int64) error
StoreGeneratedTipInvoice stores the specified invoice as one generated for the remote client to pay the local client for a tip.
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) StoreResourceRequest ¶ added in v0.1.8
func (db *DB) StoreResourceRequest(tx ReadWriteTx, uid UserID, sess, parentPage clientintf.PagesSessionID, req *rpc.RMFetchResource) error
StoreResourceRequest stores the specified requested resource. This generates a random tag for the request, which is set in the passed request Tag field.
func (*DB) StoreTipUserAttempt ¶ added in v0.1.7
func (db *DB) StoreTipUserAttempt(tx ReadWriteTx, ta TipUserAttempt) error
StoreTipUserAttempt stores an attempt by the local client to send a remote user a tip.
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) StoreUnkxdUserInfo ¶ added in v0.1.8
func (db *DB) StoreUnkxdUserInfo(tx ReadWriteTx, info UnkxdUserInfo) error
StoreUnkxdUserInfo stores information about an unxked 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) UnusedTipUserTag ¶ added in v0.1.7
func (db *DB) UnusedTipUserTag(tx ReadWriteTx, uid clientintf.UserID) int32
UnusedTipUserTag generates a new, random, unused tag to use when asking for tips from a remote user.
func (*DB) UpdateAddressBookEntry ¶
func (db *DB) UpdateAddressBookEntry(tx ReadWriteTx, ab *AddressBookEntry) error
UpdateAddressBookEntry updates the address book entry for a single user. This *ONLY* saves the address book entry in the DB, it does not persist the ratchet data.
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) UpdateOnboardState ¶ added in v0.1.7
func (db *DB) UpdateOnboardState(tx ReadWriteTx, st *clientintf.OnboardState) error
UpdateOnboardState updates the client onboard state.
func (*DB) UpdateOnchainRecvAddrForUser ¶ added in v0.1.8
func (db *DB) UpdateOnchainRecvAddrForUser(tx ReadWriteTx, uid UserID, addr string) error
UpdateOnchainRecvAddrForUser updates the on-chain address of the local node for receiving payments for the specified user. If addr is an empty string, then this removes the existing address.
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
func (*DB) UserWithOnchainRecvAddr ¶ added in v0.1.8
UserWithOnchainRecvAddr returns the user id associated with the given receive address or nil if no such id exists.
type FetchedResource ¶ added in v0.1.8
type FetchedResource struct { UID UserID `json:"uid"` SessionID clientintf.PagesSessionID `json:"session_id"` ParentPage clientintf.PagesSessionID `json:"parent_page"` PageID clientintf.PagesSessionID `json:"page_id"` RequestTS time.Time `json:"request_ts"` ResponseTS time.Time `json:"response_ts"` Request rpc.RMFetchResource `json:"request"` Response rpc.RMFetchResourceReply `json:"response"` }
FetchedResource is the full information about a fetched resource from a remote client.
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 GeneratedInvoiceForTip ¶ added in v0.1.8
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 PMLogEntry ¶ added in v0.1.8
type PageSessionOverview ¶ added in v0.1.8
type PageSessionOverview struct { Requests []PageSessionOverviewRequest `json:"requests"` Responses []PageSessionOverviewResponse `json:"responses"` LastResponseTS time.Time `json:"last_response_ts"` LastRequestTS time.Time `json:"last_request_ts"` }
PageSessionOverview stores the overview of a pages session navigation.
type PageSessionOverviewRequest ¶ added in v0.1.8
type PageSessionOverviewRequest struct { UID clientintf.UserID `json:"uid"` Tag rpc.ResourceTag `json:"tag"` }
PageSessionOverviewRequest is the overview of a fetch resource request.
type PageSessionOverviewResponse ¶ added in v0.1.8
type PageSessionOverviewResponse struct { ID clientintf.PagesSessionID `json:"id"` Parent clientintf.PagesSessionID `json:"parent"` }
PageSessionOverviewResponse is the overview of a fetch resurce response.
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 ResourceRequest ¶ added in v0.1.8
type ResourceRequest struct { UID UserID `json:"uid"` Timestamp time.Time `json:"timestamp"` Request rpc.RMFetchResource `json:"request"` SesssionID clientintf.PagesSessionID `json:"session_id"` ParentPage clientintf.PagesSessionID `json:"parent_page"` }
ResourceRequest is a serialized request for a resource.
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 TipUserAttempt ¶ added in v0.1.7
type TipUserAttempt struct { UID UserID `json:"uid"` Tag int32 `json:"tag"` MilliAtoms uint64 `json:"milli_atoms"` Created time.Time `json:"created"` Attempts int32 `json:"attempts"` MaxAttempts int32 `json:"max_attempts"` InvoiceRequested *time.Time `json:"invoice_requested"` PaymentAttempt *time.Time `json:"payment_attempt"` PaymentAttemptCount uint32 `json:"payment_attempt_count"` PaymentAttemptFailed *time.Time `json:"payment_attempt_failed"` LastInvoice string `json:"last_invoice"` PrevInvoices []string `json:"prev_invoices"` LastInvoiceError *string `json:"last_invoice_error,omitempty"` Completed *time.Time `json:"completed,omitempty"` }
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 UnkxdUserInfo ¶ added in v0.1.8
type UnkxdUserInfo struct { UID UserID `json:"uid"` MIRequests uint32 `json:"mi_requests"` AddedToGCTime *time.Time `json:"added_to_gc_time"` }
UnkxdUserInfo tracks information about unxked users.
type UserID ¶
type UserID = clientintf.UserID