2019-05-10 10:26:57 +00:00
|
|
|
package mailserver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
2019-12-09 10:06:04 +00:00
|
|
|
|
2019-12-09 10:36:14 +00:00
|
|
|
"github.com/status-im/status-go/whisper/v6"
|
2019-05-10 10:26:57 +00:00
|
|
|
)
|
|
|
|
|
2019-05-13 09:25:46 +00:00
|
|
|
// DB is an interface to abstract interactions with the db so that the mailserver
|
2019-05-10 10:26:57 +00:00
|
|
|
// is agnostic to the underlaying technology used
|
2019-05-13 09:25:46 +00:00
|
|
|
type DB interface {
|
2019-05-10 10:26:57 +00:00
|
|
|
Close() error
|
|
|
|
// SaveEnvelope stores an envelope
|
2019-11-23 17:57:05 +00:00
|
|
|
SaveEnvelope(*whisper.Envelope) error // TODO: Migrate to types.Envelope
|
2019-05-10 10:26:57 +00:00
|
|
|
// 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
|
2019-05-13 09:25:46 +00:00
|
|
|
BuildIterator(query CursorQuery) (Iterator, error)
|
2019-05-10 10:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Iterator interface {
|
|
|
|
Next() bool
|
2019-05-13 09:25:46 +00:00
|
|
|
DBKey() (*DBKey, error)
|
2019-05-10 10:26:57 +00:00
|
|
|
Release()
|
|
|
|
Error() error
|
|
|
|
GetEnvelope(bloom []byte) ([]byte, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type CursorQuery struct {
|
|
|
|
start []byte
|
|
|
|
end []byte
|
|
|
|
cursor []byte
|
|
|
|
limit uint32
|
|
|
|
bloom []byte
|
|
|
|
}
|