github.com/status-im/status-go@v1.1.0/mailserver/mailserver_db.go (about) 1 package mailserver 2 3 import ( 4 "time" 5 6 "github.com/status-im/status-go/eth-node/types" 7 ) 8 9 // every this many seconds check real envelopes count 10 const envelopeCountCheckInterval = 60 11 12 // DB is an interface to abstract interactions with the db so that the mailserver 13 // is agnostic to the underlying technology used 14 type DB interface { 15 Close() error 16 // SaveEnvelope stores an envelope 17 SaveEnvelope(types.Envelope) error 18 // GetEnvelope returns an rlp encoded envelope from the datastore 19 GetEnvelope(*DBKey) ([]byte, error) 20 // Prune removes envelopes older than time 21 Prune(time.Time, int) (int, error) 22 // BuildIterator returns an iterator over envelopes 23 BuildIterator(query CursorQuery) (Iterator, error) 24 } 25 26 type Iterator interface { 27 Next() bool 28 DBKey() (*DBKey, error) 29 Release() error 30 Error() error 31 GetEnvelopeByBloomFilter(bloom []byte) ([]byte, error) 32 GetEnvelopeByTopicsMap(topics map[types.TopicType]bool) ([]byte, error) 33 } 34 35 type CursorQuery struct { 36 start []byte 37 end []byte 38 cursor []byte 39 limit uint32 40 bloom []byte 41 topics [][]byte 42 }