2019-05-10 10:26:57 +00:00
|
|
|
package mailserver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
2019-12-09 10:06:04 +00:00
|
|
|
|
2020-01-08 11:12:23 +00:00
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
2019-05-10 10:26:57 +00:00
|
|
|
)
|
|
|
|
|
2020-04-07 08:21:39 +00:00
|
|
|
// every this many seconds check real envelopes count
|
|
|
|
const envelopeCountCheckInterval = 60
|
|
|
|
|
2019-05-13 09:25:46 +00:00
|
|
|
// DB is an interface to abstract interactions with the db so that the mailserver
|
2020-01-08 11:12:23 +00:00
|
|
|
// is agnostic to the underlying 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
|
2020-01-08 11:12:23 +00:00
|
|
|
SaveEnvelope(types.Envelope) error
|
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)
|
2020-01-21 07:11:24 +00:00
|
|
|
Release() error
|
2019-05-10 10:26:57 +00:00
|
|
|
Error() error
|
|
|
|
GetEnvelope(bloom []byte) ([]byte, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type CursorQuery struct {
|
|
|
|
start []byte
|
|
|
|
end []byte
|
|
|
|
cursor []byte
|
|
|
|
limit uint32
|
|
|
|
bloom []byte
|
2020-01-21 07:11:24 +00:00
|
|
|
topics [][]byte
|
2019-05-10 10:26:57 +00:00
|
|
|
}
|