chore(no-torrent)_: Copy and pasted Andrea's work
https://github.com/status-im/status-go/pull/5295
This commit is contained in:
parent
88343eed50
commit
66cd084084
4
Makefile
4
Makefile
|
@ -189,7 +189,7 @@ statusgo-android: ##@cross-compile Build status-go for Android
|
||||||
gomobile init; \
|
gomobile init; \
|
||||||
gomobile bind -v \
|
gomobile bind -v \
|
||||||
-target=android -ldflags="-s -w" \
|
-target=android -ldflags="-s -w" \
|
||||||
-tags '$(BUILD_TAGS)' \
|
-tags '$(BUILD_TAGS) disable_torrent' \
|
||||||
$(BUILD_FLAGS_MOBILE) \
|
$(BUILD_FLAGS_MOBILE) \
|
||||||
-o build/bin/statusgo.aar \
|
-o build/bin/statusgo.aar \
|
||||||
github.com/status-im/status-go/mobile
|
github.com/status-im/status-go/mobile
|
||||||
|
@ -201,7 +201,7 @@ statusgo-ios: ##@cross-compile Build status-go for iOS
|
||||||
gomobile init; \
|
gomobile init; \
|
||||||
gomobile bind -v \
|
gomobile bind -v \
|
||||||
-target=ios -ldflags="-s -w" \
|
-target=ios -ldflags="-s -w" \
|
||||||
-tags 'nowatchdog $(BUILD_TAGS)' \
|
-tags 'nowatchdog $(BUILD_TAGS) disable_torrent' \
|
||||||
$(BUILD_FLAGS_MOBILE) \
|
$(BUILD_FLAGS_MOBILE) \
|
||||||
-o build/bin/Statusgo.xcframework \
|
-o build/bin/Statusgo.xcframework \
|
||||||
github.com/status-im/status-go/mobile
|
github.com/status-im/status-go/mobile
|
||||||
|
|
|
@ -158,6 +158,47 @@ type HistoryArchiveDownloadTask struct {
|
||||||
Cancelled bool
|
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 {
|
func (t *HistoryArchiveDownloadTask) IsCancelled() bool {
|
||||||
t.m.RLock()
|
t.m.RLock()
|
||||||
defer t.m.RUnlock()
|
defer t.m.RUnlock()
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
//go:build (!android || !ios) && (windows || linux || darwin)
|
//go:build !disable_torrent
|
||||||
// +build !android !ios
|
// +build !disable_torrent
|
||||||
// +build windows linux darwin
|
|
||||||
|
|
||||||
package communities
|
package communities
|
||||||
|
|
||||||
|
@ -24,17 +23,6 @@ import (
|
||||||
"go.uber.org/zap"
|
"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 {
|
type ArchiveManager struct {
|
||||||
torrentConfig *params.TorrentConfig
|
torrentConfig *params.TorrentConfig
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
//go:build (!windows || !linux || !darwin) && (android || ios)
|
//go:build disable_torrent
|
||||||
// +build !windows !linux !darwin
|
// +build disable_torrent
|
||||||
// +build android ios
|
|
||||||
|
|
||||||
package communities
|
package communities
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
//go:build (!android || !ios) && (windows || linux || darwin)
|
//go:build !disable_torrent
|
||||||
// +build !android !ios
|
// +build !disable_torrent
|
||||||
// +build windows linux darwin
|
|
||||||
|
|
||||||
package communities
|
package communities
|
||||||
|
|
||||||
|
@ -50,36 +49,6 @@ type EncodedArchiveData struct {
|
||||||
bytes []byte
|
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 {
|
type TorrentManager struct {
|
||||||
torrentConfig *params.TorrentConfig
|
torrentConfig *params.TorrentConfig
|
||||||
torrentClient *torrent.Client
|
torrentClient *torrent.Client
|
||||||
|
@ -100,7 +69,7 @@ type TorrentManager struct {
|
||||||
publisher Publisher
|
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
|
// 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.
|
// 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"
|
// NOTE: It is intentional that this file contains the identical function name as in "manager_torrent_mobile.go"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
//go:build (!windows || !linux || !darwin) && (android || ios)
|
//go:build disable_torrent
|
||||||
// +build !windows !linux !darwin
|
// +build disable_torrent
|
||||||
// +build android ios
|
|
||||||
|
|
||||||
package communities
|
package communities
|
||||||
|
|
||||||
|
@ -21,7 +20,7 @@ type TorrentManagerMobile struct {
|
||||||
logger *zap.Logger
|
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
|
// 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.
|
// 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"
|
// NOTE: It is intentional that this file contains the identical function name as in "manager_torrent.go"
|
||||||
|
|
Loading…
Reference in New Issue