forked from breadwallet/breadwallet-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBRSyncMode.h
More file actions
206 lines (166 loc) · 5.31 KB
/
Copy pathBRSyncMode.h
File metadata and controls
206 lines (166 loc) · 5.31 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//
// BRSyncMode.h
// BRCore
//
// Created by Ed Gamble on 3/18/19.
// Copyright © 2019 breadwallet. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#ifndef BRSyncMode_h
#define BRSyncMode_h
#include <stdio.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/// MARK: Transfer Submission Result
typedef enum {
TRANSFER_SUBMIT_ERROR_UNKNOWN,
TRANSFER_SUBMIT_ERROR_POSIX,
} BRTransferSubmitErrorType;
typedef struct {
BRTransferSubmitErrorType type;
union {
struct {
int errnum;
} posix;
} u;
} BRTransferSubmitError;
extern BRTransferSubmitError
BRTransferSubmitErrorUnknown(void);
extern BRTransferSubmitError
BRTransferSubmitErrorPosix(int errnum);
/**
* Return a descriptive message as to why the error occurred.
*
*@return the detailed reason as a string or NULL
*/
extern char *
BRTransferSubmitErrorGetMessage(BRTransferSubmitError *e);
/// MARK: Disconnect Reason
typedef enum {
DISCONNECT_REASON_REQUESTED,
DISCONNECT_REASON_UNKNOWN,
DISCONNECT_REASON_POSIX
} BRDisconnectReasonType;
typedef struct {
BRDisconnectReasonType type;
union {
struct {
int errnum;
} posix;
} u;
} BRDisconnectReason;
extern BRDisconnectReason
BRDisconnectReasonRequested(void);
extern BRDisconnectReason
BRDisconnectReasonUnknown(void);
extern BRDisconnectReason
BRDisconnectReasonPosix(int errnum);
/**
* Return a descriptive message as to why the disconnect occurred.
*
*@return the detailed reason as a string or NULL
*/
extern char *
BRDisconnectReasonGetMessage(BRDisconnectReason *reason);
/// MARK: Sync Stopped Reason
typedef enum {
SYNC_STOPPED_REASON_COMPLETE,
SYNC_STOPPED_REASON_REQUESTED,
SYNC_STOPPED_REASON_UNKNOWN,
SYNC_STOPPED_REASON_POSIX
} BRSyncStoppedReasonType;
typedef struct {
BRSyncStoppedReasonType type;
union {
struct {
int errnum;
} posix;
} u;
} BRSyncStoppedReason;
extern BRSyncStoppedReason
BRSyncStoppedReasonComplete(void);
extern BRSyncStoppedReason
BRSyncStoppedReasonRequested(void);
extern BRSyncStoppedReason
BRSyncStoppedReasonUnknown(void);
extern BRSyncStoppedReason
BRSyncStoppedReasonPosix(int errnum);
/**
* Return a descriptive message as to why the sync stopped.
*
*@return the detailed reason as a string or NULL
*/
extern char *
BRSyncStoppedReasonGetMessage(BRSyncStoppedReason *reason);
/// MARK: Sync Mode
typedef enum {
/**
* Use the BRD backend for all Core blockchain state. The BRD backend includes a 'submit
* transaction' interface.
*/
SYNC_MODE_BRD_ONLY,
/**
* Use the BRD backend for everything other than 'submit transaction'
*/
SYNC_MODE_BRD_WITH_P2P_SEND,
/**
* Use the BRD backend for an initial sync and then, once complete, use P2P. If a sync
* has not occurred in a while, use the BRD backend again before using P2P (so as to catch-up
* quickly)
*/
SYNC_MODE_P2P_WITH_BRD_SYNC,
/**
* Use acomplete block chain sync, even starting at block zero (but usually from a block
* derived from the accounts `earliestStartTime` (or the BIP-39 introduction block).
*/
SYNC_MODE_P2P_ONLY
} BRSyncMode;
extern const char *
BRSyncModeString (BRSyncMode m);
/// MARK: Sync Depth
typedef enum {
/**
* Sync from the block height of the last confirmed send transaction.
*/
SYNC_DEPTH_FROM_LAST_CONFIRMED_SEND,
/**
* Sync from the block height of the last trusted block; this is dependent on the
* blockchain and mode as to how it determines trust.
*/
SYNC_DEPTH_FROM_LAST_TRUSTED_BLOCK,
/**
* Sync from the block height of the point in time when the account was created.
*/
SYNC_DEPTH_FROM_CREATION
} BRSyncDepth;
/// The Percent Complete (0...100.0) derived from the last block processed relative to the
/// full block range in a sync.
typedef float BRSyncPercentComplete;
#define AS_SYNC_PERCENT_COMPLETE(number) ((BRSyncPercentComplete) (number))
/// The Timestamp (in the Unix epoch) of the last block processed in a sync.
typedef uint32_t BRSyncTimestamp;
#define AS_SYNC_TIMESTAMP(unixSeconds) ((BRSyncTimestamp) (unixSeconds))
#define NO_SYNC_TIMESTAMP (AS_SYNC_TIMESTAMP (0))
#ifdef __cplusplus
}
#endif
#endif /* BRSyncMode_h */