-
Notifications
You must be signed in to change notification settings - Fork 15
/
spool.go
52 lines (43 loc) · 2.04 KB
/
spool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// spool.go - Katzenpost server user message spool.
// Copyright (C) 2017 Yawning Angel.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Package spool defines the Katzenpost server user message spool abstract
// interface.
package spool
import (
"github.com/katzenpost/katzenpost/core/sphinx/constants"
"github.com/katzenpost/katzenpost/server/userdb"
)
// Spool is the interface provided by all user messgage spool implementations.
type Spool interface {
// StoreMessage stores a message in the user's spool.
StoreMessage(u, msg []byte) error
// StoreSURBReply stores a SURBReply in the user's spool.
StoreSURBReply(u []byte, id *[constants.SURBIDLength]byte, msg []byte) error
// Get optionally deletes the first entry in a user's spool, and returns
// the (new) first entry. Both messages and SURBReplies may be returned.
Get(u []byte, advance bool) (msg, surbID []byte, remaining int, err error)
// Remove removes the spool identified by the username from the database.
Remove(u []byte) error
// Vacuum removes the spools that do not correspond to valid users in the
// provided UserDB.
Vacuum(udb userdb.UserDB) error
// VacuumExpired removes expired users from the userdb and then
// removes their spools unless the identity is present in the given
// ignoreIdentities.
VacuumExpired(udb userdb.UserDB, ignoreIdentities map[[constants.RecipientIDLength]byte]interface{}) error
// Close closes the Spool instance.
Close()
}