mirror of
https://github.com/status-im/status-go.git
synced 2025-01-10 22:56:40 +00:00
4ab08629f6
This commits adds support for postgres database. Currently two fields are stored: the bloom filter and the topic. Only the bloom filter is actually used to query, but potentially we will use also the topic in the future, so easier to separate it now in order to avoid a migration.
37 lines
863 B
Go
37 lines
863 B
Go
package mailserver
|
|
|
|
import (
|
|
whisper "github.com/status-im/whisper/whisperv6"
|
|
"time"
|
|
)
|
|
|
|
// DB is an interface to abstract interactions with the db so that the mailserver
|
|
// is agnostic to the underlaying technology used
|
|
type DB interface {
|
|
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
|
|
BuildIterator(query CursorQuery) (Iterator, error)
|
|
}
|
|
|
|
type Iterator interface {
|
|
Next() bool
|
|
DBKey() (*DBKey, error)
|
|
Release()
|
|
Error() error
|
|
GetEnvelope(bloom []byte) ([]byte, error)
|
|
}
|
|
|
|
type CursorQuery struct {
|
|
start []byte
|
|
end []byte
|
|
cursor []byte
|
|
limit uint32
|
|
bloom []byte
|
|
}
|