2019-05-10 10:26:57 +00:00
|
|
|
package mailserver
|
|
|
|
|
|
|
|
import (
|
|
|
|
whisper "github.com/status-im/whisper/whisperv6"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
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
|
|
|
|
SaveEnvelope(*whisper.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
|
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
|
|
|
|
}
|