chore(no-torrent)_: Created TorrentContract and ArchiveContract interfaces
This commit is contained in:
parent
bf5ab8c46b
commit
f0ac9715e8
|
@ -2,7 +2,6 @@ package communities
|
|||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"go.uber.org/zap"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
@ -18,8 +17,20 @@ import (
|
|||
"github.com/anacrolix/torrent/bencode"
|
||||
"github.com/anacrolix/torrent/metainfo"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type ArchiveContract interface {
|
||||
CreateHistoryArchiveTorrentFromMessages(communityID types.HexBytes, messages []*types.Message, topics []types.TopicType, startDate time.Time, endDate time.Time, partition time.Duration, encrypt bool) ([]string, error)
|
||||
CreateHistoryArchiveTorrentFromDB(communityID types.HexBytes, topics []types.TopicType, startDate time.Time, endDate time.Time, partition time.Duration, encrypt bool) ([]string, error)
|
||||
SaveMessageArchiveID(communityID types.HexBytes, hash string) error
|
||||
GetMessageArchiveIDsToImport(communityID types.HexBytes) ([]string, error)
|
||||
SetMessageArchiveIDImported(communityID types.HexBytes, hash string, imported bool) error
|
||||
ExtractMessagesFromHistoryArchive(communityID types.HexBytes, archiveID string) ([]*protobuf.WakuMessage, error)
|
||||
GetHistoryArchiveMagnetlink(communityID types.HexBytes) (string, error)
|
||||
LoadHistoryArchiveIndexFromFile(myKey *ecdsa.PrivateKey, communityID types.HexBytes) (*protobuf.WakuMessageArchiveIndex, error)
|
||||
}
|
||||
|
||||
type ArchiveManager struct {
|
||||
torrentConfig *params.TorrentConfig
|
||||
|
||||
|
|
|
@ -11,15 +11,15 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/anacrolix/torrent/metainfo"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/params"
|
||||
"github.com/status-im/status-go/protocol/encryption"
|
||||
"github.com/status-im/status-go/protocol/transport"
|
||||
"github.com/status-im/status-go/signal"
|
||||
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/anacrolix/torrent/metainfo"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type archiveMDSlice []*archiveMetadata
|
||||
|
@ -52,6 +52,30 @@ type HistoryArchiveDownloadTaskInfo struct {
|
|||
Cancelled bool
|
||||
}
|
||||
|
||||
type TorrentContract interface {
|
||||
ArchiveContract
|
||||
|
||||
LogStdout(string, ...zap.Field)
|
||||
SetOnline(bool)
|
||||
SetTorrentConfig(*params.TorrentConfig)
|
||||
StartTorrentClient() error
|
||||
Stop() error
|
||||
IsReady() bool
|
||||
GetCommunityChatsFilters(communityID types.HexBytes) ([]*transport.Filter, error)
|
||||
GetCommunityChatsTopics(communityID types.HexBytes) ([]types.TopicType, error)
|
||||
GetHistoryArchivePartitionStartTimestamp(communityID types.HexBytes) (uint64, error)
|
||||
CreateAndSeedHistoryArchive(communityID types.HexBytes, topics []types.TopicType, startDate time.Time, endDate time.Time, partition time.Duration, encrypt bool) error
|
||||
StartHistoryArchiveTasksInterval(community *Community, interval time.Duration)
|
||||
StopHistoryArchiveTasksInterval(communityID types.HexBytes)
|
||||
SeedHistoryArchiveTorrent(communityID types.HexBytes) error
|
||||
UnseedHistoryArchiveTorrent(communityID types.HexBytes)
|
||||
IsSeedingHistoryArchiveTorrent(communityID types.HexBytes) bool
|
||||
GetHistoryArchiveDownloadTask(communityID string) *HistoryArchiveDownloadTask
|
||||
AddHistoryArchiveDownloadTask(communityID string, task *HistoryArchiveDownloadTask)
|
||||
DownloadHistoryArchivesByMagnetlink(communityID types.HexBytes, magnetlink string, cancelTask chan struct{}) (*HistoryArchiveDownloadTaskInfo, error)
|
||||
TorrentFileExists(communityID string) bool
|
||||
}
|
||||
|
||||
type TorrentManager struct {
|
||||
torrentConfig *params.TorrentConfig
|
||||
torrentClient *torrent.Client
|
||||
|
|
Loading…
Reference in New Issue