diff --git a/Makefile b/Makefile index 330ef92a4..4d73dfd1c 100644 --- a/Makefile +++ b/Makefile @@ -189,7 +189,7 @@ statusgo-android: ##@cross-compile Build status-go for Android gomobile init; \ gomobile bind -v \ -target=android -ldflags="-s -w" \ - -tags '$(BUILD_TAGS)' \ + -tags '$(BUILD_TAGS) disable_torrent' \ $(BUILD_FLAGS_MOBILE) \ -o build/bin/statusgo.aar \ github.com/status-im/status-go/mobile @@ -201,7 +201,7 @@ statusgo-ios: ##@cross-compile Build status-go for iOS gomobile init; \ gomobile bind -v \ -target=ios -ldflags="-s -w" \ - -tags 'nowatchdog $(BUILD_TAGS)' \ + -tags 'nowatchdog $(BUILD_TAGS) disable_torrent' \ $(BUILD_FLAGS_MOBILE) \ -o build/bin/Statusgo.xcframework \ github.com/status-im/status-go/mobile diff --git a/protocol/communities/manager.go b/protocol/communities/manager.go index 1438f678f..ca326905e 100644 --- a/protocol/communities/manager.go +++ b/protocol/communities/manager.go @@ -158,6 +158,47 @@ type HistoryArchiveDownloadTask struct { Cancelled bool } +type HistoryArchiveDownloadTaskInfo struct { + TotalDownloadedArchivesCount int + TotalArchivesCount int + Cancelled bool +} + +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 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 +} + func (t *HistoryArchiveDownloadTask) IsCancelled() bool { t.m.RLock() defer t.m.RUnlock() diff --git a/protocol/communities/manager_archive.go b/protocol/communities/manager_archive.go index e1fac85e9..f95976cf1 100644 --- a/protocol/communities/manager_archive.go +++ b/protocol/communities/manager_archive.go @@ -1,6 +1,5 @@ -//go:build (!android || !ios) && (windows || linux || darwin) -// +build !android !ios -// +build windows linux darwin +//go:build !disable_torrent +// +build !disable_torrent package communities @@ -24,17 +23,6 @@ import ( "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 diff --git a/protocol/communities/manager_archive_mobile.go b/protocol/communities/manager_archive_mobile.go index f748b8537..457a98416 100644 --- a/protocol/communities/manager_archive_mobile.go +++ b/protocol/communities/manager_archive_mobile.go @@ -1,6 +1,5 @@ -//go:build (!windows || !linux || !darwin) && (android || ios) -// +build !windows !linux !darwin -// +build android ios +//go:build disable_torrent +// +build disable_torrent package communities diff --git a/protocol/communities/manager_torrent.go b/protocol/communities/manager_torrent.go index e22796a1e..6f27abb6c 100644 --- a/protocol/communities/manager_torrent.go +++ b/protocol/communities/manager_torrent.go @@ -1,6 +1,5 @@ -//go:build (!android || !ios) && (windows || linux || darwin) -// +build !android !ios -// +build windows linux darwin +//go:build !disable_torrent +// +build !disable_torrent package communities @@ -50,36 +49,6 @@ type EncodedArchiveData struct { bytes []byte } -type HistoryArchiveDownloadTaskInfo struct { - TotalDownloadedArchivesCount int - TotalArchivesCount int - 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 @@ -100,7 +69,7 @@ type TorrentManager struct { publisher Publisher } -// NewTorrentManager this function is only built and called when the "windows || linux || darwin" build OS criteria are met +// NewTorrentManager this function is only built and called when the "disable_torrent" build tag is not set // In this case this version of NewTorrentManager will return the full Desktop TorrentManager ensuring that the // build command will import and build the torrent deps for the Desktop OSes. // NOTE: It is intentional that this file contains the identical function name as in "manager_torrent_mobile.go" diff --git a/protocol/communities/manager_torrent_mobile.go b/protocol/communities/manager_torrent_mobile.go index 945b52710..9fa1d9f7c 100644 --- a/protocol/communities/manager_torrent_mobile.go +++ b/protocol/communities/manager_torrent_mobile.go @@ -1,6 +1,5 @@ -//go:build (!windows || !linux || !darwin) && (android || ios) -// +build !windows !linux !darwin -// +build android ios +//go:build disable_torrent +// +build disable_torrent package communities @@ -21,7 +20,7 @@ type TorrentManagerMobile struct { logger *zap.Logger } -// NewTorrentManager this function is only built and called when the "android || ios" build OS criteria are met +// NewTorrentManager this function is only built and called when the "disable_torrent" build tag is set // In this case this version of NewTorrentManager will return the mobile "nil" TorrentManagerMobile ensuring that the // build command will not import or build the torrent deps for the mobile OS. // NOTE: It is intentional that this file contains the identical function name as in "manager_torrent.go"