-
Notifications
You must be signed in to change notification settings - Fork 249
/
mailserver_db.go
41 lines (35 loc) · 975 Bytes
/
mailserver_db.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
package mailserver
import (
"time"
"github.com/status-im/status-go/eth-node/types"
)
// every this many seconds check real envelopes count
const envelopeCountCheckInterval = 60
// DB is an interface to abstract interactions with the db so that the mailserver
// is agnostic to the underlying technology used
type DB interface {
Close() error
// SaveEnvelope stores an envelope
SaveEnvelope(types.Envelope) error
// GetEnvelope returns an rlp encoded envelope from the datastore
GetEnvelope(*DBKey) ([]byte, error)
// Prune removes envelopes older than time
Prune(time.Time, int) (int, error)
// BuildIterator returns an iterator over envelopes
BuildIterator(query CursorQuery) (Iterator, error)
}
type Iterator interface {
Next() bool
DBKey() (*DBKey, error)
Release() error
Error() error
GetEnvelope(bloom []byte) ([]byte, error)
}
type CursorQuery struct {
start []byte
end []byte
cursor []byte
limit uint32
bloom []byte
topics [][]byte
}