Syncing provides information when this nodes starts synchronising with the Ethereum network and when it's finished.
(ctx context.Context)
| 91 | |
| 92 | // Syncing provides information when this nodes starts synchronising with the Ethereum network and when it's finished. |
| 93 | func (api *PublicDownloaderAPI) Syncing(ctx context.Context) (*rpc.Subscription, error) { |
| 94 | notifier, supported := rpc.NotifierFromContext(ctx) |
| 95 | if !supported { |
| 96 | return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported |
| 97 | } |
| 98 | |
| 99 | rpcSub := notifier.CreateSubscription() |
| 100 | |
| 101 | go func() { |
| 102 | statuses := make(chan interface{}) |
| 103 | sub := api.SubscribeSyncStatus(statuses) |
| 104 | |
| 105 | for { |
| 106 | select { |
| 107 | case status := <-statuses: |
| 108 | notifier.Notify(rpcSub.ID, status) |
| 109 | case <-rpcSub.Err(): |
| 110 | sub.Unsubscribe() |
| 111 | return |
| 112 | case <-notifier.Closed(): |
| 113 | sub.Unsubscribe() |
| 114 | return |
| 115 | } |
| 116 | } |
| 117 | }() |
| 118 | |
| 119 | return rpcSub, nil |
| 120 | } |
| 121 | |
| 122 | // SyncingResult provides information about the current synchronisation status for this node. |
| 123 | type SyncingResult struct { |
nothing calls this directly
no test coverage detected