-
Notifications
You must be signed in to change notification settings - Fork 253
/
Copy pathevents_community_archives.go
143 lines (121 loc) · 5.01 KB
/
events_community_archives.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package signal
const (
// EventHistoryArchivesEnabled triggered when the community history archive protocol
// was enabled via the RPC API
EventHistoryArchivesProtocolEnabled = "community.historyArchivesProtocolEnabled"
// EventHistoryArchivesDisabled triggered when the community history archive protocol
// was disabled via the RPC API
EventHistoryArchivesProtocolDisabled = "community.historyArchivesProtocolDisabled"
// EventCreatingHistoryArchives is triggered when the community owner node
// starts to create archives torrents
EventCreatingHistoryArchives = "community.creatingHistoryArchives"
// EventHistoryArchivesCreated is triggered when the community owner node
// has finished to create archives torrents
EventHistoryArchivesCreated = "community.historyArchivesCreated"
// EventNoHistoryArchivesCreated is triggered when the community owner node
// tried to create archives but haven't because there were no new messages
// to archive
EventNoHistoryArchivesCreated = "community.noHistoryArchivesCreated"
// EventHistoryArchivesSeeding is triggered when the community owner node
// started seeding archives torrents
EventHistoryArchivesSeeding = "community.historyArchivesSeeding"
// EventHistoryArchivesUnseeded is triggered when the community owner node
// drops a torrent for a particular community
EventHistoryArchivesUnseeded = "community.historyArchivesUnseeded"
// EventDownloadingHistoryArchivesFinished is triggered when the community member node
// has downloaded all archives
EventDownloadingHistoryArchivesStarted = "community.downloadingHistoryArchivesStarted"
// EventHistoryArchiveDownloaded is triggered when the community member node
// has downloaded an individual community archive
EventHistoryArchiveDownloaded = "community.historyArchiveDownloaded"
// EventImportingHistoryArchiveMessages is triggered when the community member node
// has starts importing downloaded archive messages into the database
EventImportingHistoryArchiveMessages = "community.importingHistoryArchiveMessages"
// EventDownloadingHistoryArchivesFinished is triggered when the community member node
// has downloaded all archives
EventDownloadingHistoryArchivesFinished = "community.downloadingHistoryArchivesFinished"
)
type CreatingHistoryArchivesSignal struct {
CommunityID string `json:"communityId"`
}
type NoHistoryArchivesCreatedSignal struct {
CommunityID string `json:"communityId"`
From int `json:"from"`
To int `json:"to"`
}
type HistoryArchivesCreatedSignal struct {
CommunityID string `json:"communityId"`
From int `json:"from"`
To int `json:"to"`
}
type HistoryArchivesSeedingSignal struct {
CommunityID string `json:"communityId"`
}
type HistoryArchivesUnseededSignal struct {
CommunityID string `json:"communityId"`
}
type HistoryArchiveDownloadedSignal struct {
CommunityID string `json:"communityId"`
From int `json:"from"`
To int `json:"to"`
}
type DownloadingHistoryArchivesStartedSignal struct {
CommunityID string `json:"communityId"`
}
type ImportingHistoryArchiveMessagesSignal struct {
CommunityID string `json:"communityId"`
}
type DownloadingHistoryArchivesFinishedSignal struct {
CommunityID string `json:"communityId"`
}
func SendHistoryArchivesProtocolEnabled() {
send(EventHistoryArchivesProtocolEnabled, nil)
}
func SendHistoryArchivesProtocolDisabled() {
send(EventHistoryArchivesProtocolDisabled, nil)
}
func SendCreatingHistoryArchives(communityID string) {
send(EventCreatingHistoryArchives, CreatingHistoryArchivesSignal{CommunityID: communityID})
}
func SendNoHistoryArchivesCreated(communityID string, from int, to int) {
send(EventNoHistoryArchivesCreated, NoHistoryArchivesCreatedSignal{
CommunityID: communityID,
From: from,
To: to,
})
}
func SendHistoryArchivesCreated(communityID string, from int, to int) {
send(EventHistoryArchivesCreated, HistoryArchivesCreatedSignal{
CommunityID: communityID,
From: from,
To: to,
})
}
func SendHistoryArchivesSeeding(communityID string) {
send(EventHistoryArchivesSeeding, HistoryArchivesSeedingSignal{CommunityID: communityID})
}
func SendHistoryArchivesUnseeded(communityID string) {
send(EventHistoryArchivesUnseeded, HistoryArchivesUnseededSignal{CommunityID: communityID})
}
func SendHistoryArchiveDownloaded(communityID string, from int, to int) {
send(EventHistoryArchiveDownloaded, HistoryArchiveDownloadedSignal{
CommunityID: communityID,
From: from,
To: to,
})
}
func SendDownloadingHistoryArchivesStarted(communityID string) {
send(EventDownloadingHistoryArchivesStarted, DownloadingHistoryArchivesStartedSignal{
CommunityID: communityID,
})
}
func SendImportingHistoryArchiveMessages(communityID string) {
send(EventImportingHistoryArchiveMessages, ImportingHistoryArchiveMessagesSignal{
CommunityID: communityID,
})
}
func SendDownloadingHistoryArchivesFinished(communityID string) {
send(EventDownloadingHistoryArchivesFinished, DownloadingHistoryArchivesFinishedSignal{
CommunityID: communityID,
})
}