forked from planetdecred/godcr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listeners.go
108 lines (90 loc) · 3.1 KB
/
listeners.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
package ui
import (
"encoding/json"
"github.com/planetdecred/dcrlibwallet"
"github.com/planetdecred/godcr/wallet"
)
// Transaction notifications
func (mp *mainPage) OnTransaction(transaction string) {
mp.updateBalance()
// beeep send notification
var tx dcrlibwallet.Transaction
err := json.Unmarshal([]byte(transaction), &tx)
if err == nil {
mp.notificationsUpdate <- wallet.NewTransaction{
Transaction: &tx,
}
}
}
func (mp *mainPage) OnBlockAttached(walletID int, blockHeight int32) {
mp.updateBalance()
mp.notificationsUpdate <- wallet.SyncStatusUpdate{
Stage: wallet.BlockAttached,
}
}
func (mp *mainPage) OnTransactionConfirmed(walletID int, hash string, blockHeight int32) {
mp.updateBalance()
}
// Account mixer
func (mp *mainPage) OnAccountMixerStarted(walletID int) {}
func (mp *mainPage) OnAccountMixerEnded(walletID int) {}
// Politeia notifications
func (mp *mainPage) OnProposalsSynced() {}
func (mp *mainPage) OnNewProposal(proposal *dcrlibwallet.Proposal) {}
func (mp *mainPage) OnProposalVoteStarted(proposal *dcrlibwallet.Proposal) {}
func (mp *mainPage) OnProposalVoteFinished(proposal *dcrlibwallet.Proposal) {}
// Sync notifications
func (mp *mainPage) OnSyncStarted(wasRestarted bool) {
mp.notificationsUpdate <- wallet.SyncStatusUpdate{
Stage: wallet.SyncStarted,
}
}
func (mp *mainPage) OnPeerConnectedOrDisconnected(numberOfConnectedPeers int32) {
mp.notificationsUpdate <- wallet.SyncStatusUpdate{
Stage: wallet.PeersConnected,
ConnectedPeers: numberOfConnectedPeers,
}
}
func (mp *mainPage) OnCFiltersFetchProgress(cfiltersFetchProgress *dcrlibwallet.CFiltersFetchProgressReport) {
mp.notificationsUpdate <- wallet.SyncStatusUpdate{
Stage: wallet.CfiltersFetchProgress,
ProgressReport: cfiltersFetchProgress,
}
}
func (mp *mainPage) OnHeadersFetchProgress(headersFetchProgress *dcrlibwallet.HeadersFetchProgressReport) {
mp.notificationsUpdate <- wallet.SyncStatusUpdate{
Stage: wallet.HeadersFetchProgress,
ProgressReport: wallet.SyncHeadersFetchProgress{
Progress: headersFetchProgress,
},
}
}
func (mp *mainPage) OnAddressDiscoveryProgress(addressDiscoveryProgress *dcrlibwallet.AddressDiscoveryProgressReport) {
mp.notificationsUpdate <- wallet.SyncStatusUpdate{
Stage: wallet.AddressDiscoveryProgress,
ProgressReport: wallet.SyncAddressDiscoveryProgress{
Progress: addressDiscoveryProgress,
},
}
}
func (mp *mainPage) OnHeadersRescanProgress(headersRescanProgress *dcrlibwallet.HeadersRescanProgressReport) {
mp.notificationsUpdate <- wallet.SyncStatusUpdate{
Stage: wallet.HeadersRescanProgress,
ProgressReport: wallet.SyncHeadersRescanProgress{
Progress: headersRescanProgress,
},
}
}
func (mp *mainPage) OnSyncCompleted() {
mp.updateBalance()
mp.notificationsUpdate <- wallet.SyncStatusUpdate{
Stage: wallet.SyncCompleted,
}
}
func (mp *mainPage) OnSyncCanceled(willRestart bool) {
mp.notificationsUpdate <- wallet.SyncStatusUpdate{
Stage: wallet.SyncCanceled,
}
}
func (mp *mainPage) OnSyncEndedWithError(err error) {}
func (mp *mainPage) Debug(debugInfo *dcrlibwallet.DebugInfo) {}