tigerbeetle-node 0.11.9 → 0.11.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.client.node.sha256 +1 -1
- package/dist/index.d.ts +70 -67
- package/dist/index.js +70 -67
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/build_lib.sh +22 -10
- package/src/index.ts +3 -0
- package/src/tigerbeetle/src/config.zig +2 -0
- package/src/tigerbeetle/src/constants.zig +18 -0
- package/src/tigerbeetle/src/lsm/forest_fuzz.zig +0 -2
- package/src/tigerbeetle/src/lsm/manifest_log_fuzz.zig +6 -5
- package/src/tigerbeetle/src/lsm/test.zig +5 -4
- package/src/tigerbeetle/src/lsm/tree.zig +3 -30
- package/src/tigerbeetle/src/lsm/tree_fuzz.zig +0 -2
- package/src/tigerbeetle/src/simulator.zig +34 -53
- package/src/tigerbeetle/src/testing/cluster/state_checker.zig +1 -1
- package/src/tigerbeetle/src/testing/cluster/storage_checker.zig +6 -6
- package/src/tigerbeetle/src/testing/cluster.zig +5 -99
- package/src/tigerbeetle/src/testing/storage.zig +26 -23
- package/src/tigerbeetle/src/vsr/journal.zig +86 -90
- package/src/tigerbeetle/src/vsr/replica.zig +631 -687
- package/src/tigerbeetle/src/vsr/replica_format.zig +12 -12
- package/src/tigerbeetle/src/vsr/superblock.zig +192 -110
- package/src/tigerbeetle/src/vsr/superblock_fuzz.zig +35 -8
- package/src/tigerbeetle/src/vsr/superblock_quorums.zig +48 -48
- package/src/tigerbeetle/src/vsr/superblock_quorums_fuzz.zig +50 -50
- package/src/tigerbeetle/src/vsr.zig +93 -29
package/dist/.client.node.sha256
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
21c6105d76e0efc68fe5cbe799d363a083a9b44359e16d7dbfbb172e381ea0c3 dist/client.node
|
package/dist/index.d.ts
CHANGED
|
@@ -25,22 +25,23 @@ export declare enum AccountFlags {
|
|
|
25
25
|
export declare enum CreateAccountError {
|
|
26
26
|
linked_event_failed = 1,
|
|
27
27
|
linked_event_chain_open = 2,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
timestamp_must_be_zero = 3,
|
|
29
|
+
reserved_flag = 4,
|
|
30
|
+
reserved_field = 5,
|
|
31
|
+
id_must_not_be_zero = 6,
|
|
32
|
+
id_must_not_be_int_max = 7,
|
|
33
|
+
ledger_must_not_be_zero = 8,
|
|
34
|
+
code_must_not_be_zero = 9,
|
|
35
|
+
debits_pending_must_be_zero = 10,
|
|
36
|
+
debits_posted_must_be_zero = 11,
|
|
37
|
+
credits_pending_must_be_zero = 12,
|
|
38
|
+
credits_posted_must_be_zero = 13,
|
|
39
|
+
mutually_exclusive_flags = 14,
|
|
40
|
+
exists_with_different_flags = 15,
|
|
41
|
+
exists_with_different_user_data = 16,
|
|
42
|
+
exists_with_different_ledger = 17,
|
|
43
|
+
exists_with_different_code = 18,
|
|
44
|
+
exists = 19
|
|
44
45
|
}
|
|
45
46
|
export declare type CreateAccountsError = {
|
|
46
47
|
index: number;
|
|
@@ -69,57 +70,59 @@ export declare enum TransferFlags {
|
|
|
69
70
|
export declare enum CreateTransferError {
|
|
70
71
|
linked_event_failed = 1,
|
|
71
72
|
linked_event_chain_open = 2,
|
|
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
|
-
|
|
73
|
+
timestamp_must_be_zero = 3,
|
|
74
|
+
reserved_flag = 4,
|
|
75
|
+
reserved_field = 5,
|
|
76
|
+
id_must_not_be_zero = 6,
|
|
77
|
+
id_must_not_be_int_max = 7,
|
|
78
|
+
debit_account_id_must_not_be_zero = 8,
|
|
79
|
+
debit_account_id_must_not_be_int_max = 9,
|
|
80
|
+
credit_account_id_must_not_be_zero = 10,
|
|
81
|
+
credit_account_id_must_not_be_int_max = 11,
|
|
82
|
+
accounts_must_be_different = 12,
|
|
83
|
+
pending_id_must_be_zero = 13,
|
|
84
|
+
ledger_must_not_be_zero = 14,
|
|
85
|
+
code_must_not_be_zero = 15,
|
|
86
|
+
amount_must_not_be_zero = 16,
|
|
87
|
+
debit_account_not_found = 17,
|
|
88
|
+
credit_account_not_found = 18,
|
|
89
|
+
accounts_must_have_the_same_ledger = 19,
|
|
90
|
+
transfer_must_have_the_same_ledger_as_accounts = 20,
|
|
91
|
+
exists_with_different_flags = 21,
|
|
92
|
+
exists_with_different_debit_account_id = 22,
|
|
93
|
+
exists_with_different_credit_account_id = 23,
|
|
94
|
+
exists_with_different_user_data = 24,
|
|
95
|
+
exists_with_different_pending_id = 25,
|
|
96
|
+
exists_with_different_timeout = 26,
|
|
97
|
+
exists_with_different_code = 27,
|
|
98
|
+
exists_with_different_amount = 28,
|
|
99
|
+
exists = 29,
|
|
100
|
+
overflows_debits_pending = 30,
|
|
101
|
+
overflows_credits_pending = 31,
|
|
102
|
+
overflows_debits_posted = 32,
|
|
103
|
+
overflows_credits_posted = 33,
|
|
104
|
+
overflows_debits = 34,
|
|
105
|
+
overflows_credits = 35,
|
|
106
|
+
overflows_timeout = 36,
|
|
107
|
+
exceeds_credits = 37,
|
|
108
|
+
exceeds_debits = 38,
|
|
109
|
+
cannot_post_and_void_pending_transfer = 39,
|
|
110
|
+
pending_transfer_cannot_post_or_void_another = 40,
|
|
111
|
+
timeout_reserved_for_pending_transfer = 41,
|
|
112
|
+
pending_id_must_not_be_zero = 42,
|
|
113
|
+
pending_id_must_not_be_int_max = 43,
|
|
114
|
+
pending_id_must_be_different = 44,
|
|
115
|
+
pending_transfer_not_found = 45,
|
|
116
|
+
pending_transfer_not_pending = 46,
|
|
117
|
+
pending_transfer_has_different_debit_account_id = 47,
|
|
118
|
+
pending_transfer_has_different_credit_account_id = 48,
|
|
119
|
+
pending_transfer_has_different_ledger = 49,
|
|
120
|
+
pending_transfer_has_different_code = 50,
|
|
121
|
+
exceeds_pending_transfer_amount = 51,
|
|
122
|
+
pending_transfer_has_different_amount = 52,
|
|
123
|
+
pending_transfer_already_posted = 53,
|
|
124
|
+
pending_transfer_already_voided = 54,
|
|
125
|
+
pending_transfer_expired = 55
|
|
123
126
|
}
|
|
124
127
|
export declare type CreateTransfersError = {
|
|
125
128
|
index: number;
|
package/dist/index.js
CHANGED
|
@@ -12,22 +12,23 @@ var CreateAccountError;
|
|
|
12
12
|
(function (CreateAccountError) {
|
|
13
13
|
CreateAccountError[CreateAccountError["linked_event_failed"] = 1] = "linked_event_failed";
|
|
14
14
|
CreateAccountError[CreateAccountError["linked_event_chain_open"] = 2] = "linked_event_chain_open";
|
|
15
|
-
CreateAccountError[CreateAccountError["
|
|
16
|
-
CreateAccountError[CreateAccountError["
|
|
17
|
-
CreateAccountError[CreateAccountError["
|
|
18
|
-
CreateAccountError[CreateAccountError["
|
|
19
|
-
CreateAccountError[CreateAccountError["
|
|
20
|
-
CreateAccountError[CreateAccountError["
|
|
21
|
-
CreateAccountError[CreateAccountError["
|
|
22
|
-
CreateAccountError[CreateAccountError["
|
|
23
|
-
CreateAccountError[CreateAccountError["
|
|
24
|
-
CreateAccountError[CreateAccountError["
|
|
25
|
-
CreateAccountError[CreateAccountError["
|
|
26
|
-
CreateAccountError[CreateAccountError["
|
|
27
|
-
CreateAccountError[CreateAccountError["
|
|
28
|
-
CreateAccountError[CreateAccountError["
|
|
29
|
-
CreateAccountError[CreateAccountError["
|
|
30
|
-
CreateAccountError[CreateAccountError["
|
|
15
|
+
CreateAccountError[CreateAccountError["timestamp_must_be_zero"] = 3] = "timestamp_must_be_zero";
|
|
16
|
+
CreateAccountError[CreateAccountError["reserved_flag"] = 4] = "reserved_flag";
|
|
17
|
+
CreateAccountError[CreateAccountError["reserved_field"] = 5] = "reserved_field";
|
|
18
|
+
CreateAccountError[CreateAccountError["id_must_not_be_zero"] = 6] = "id_must_not_be_zero";
|
|
19
|
+
CreateAccountError[CreateAccountError["id_must_not_be_int_max"] = 7] = "id_must_not_be_int_max";
|
|
20
|
+
CreateAccountError[CreateAccountError["ledger_must_not_be_zero"] = 8] = "ledger_must_not_be_zero";
|
|
21
|
+
CreateAccountError[CreateAccountError["code_must_not_be_zero"] = 9] = "code_must_not_be_zero";
|
|
22
|
+
CreateAccountError[CreateAccountError["debits_pending_must_be_zero"] = 10] = "debits_pending_must_be_zero";
|
|
23
|
+
CreateAccountError[CreateAccountError["debits_posted_must_be_zero"] = 11] = "debits_posted_must_be_zero";
|
|
24
|
+
CreateAccountError[CreateAccountError["credits_pending_must_be_zero"] = 12] = "credits_pending_must_be_zero";
|
|
25
|
+
CreateAccountError[CreateAccountError["credits_posted_must_be_zero"] = 13] = "credits_posted_must_be_zero";
|
|
26
|
+
CreateAccountError[CreateAccountError["mutually_exclusive_flags"] = 14] = "mutually_exclusive_flags";
|
|
27
|
+
CreateAccountError[CreateAccountError["exists_with_different_flags"] = 15] = "exists_with_different_flags";
|
|
28
|
+
CreateAccountError[CreateAccountError["exists_with_different_user_data"] = 16] = "exists_with_different_user_data";
|
|
29
|
+
CreateAccountError[CreateAccountError["exists_with_different_ledger"] = 17] = "exists_with_different_ledger";
|
|
30
|
+
CreateAccountError[CreateAccountError["exists_with_different_code"] = 18] = "exists_with_different_code";
|
|
31
|
+
CreateAccountError[CreateAccountError["exists"] = 19] = "exists";
|
|
31
32
|
})(CreateAccountError = exports.CreateAccountError || (exports.CreateAccountError = {}));
|
|
32
33
|
var TransferFlags;
|
|
33
34
|
(function (TransferFlags) {
|
|
@@ -40,57 +41,59 @@ var CreateTransferError;
|
|
|
40
41
|
(function (CreateTransferError) {
|
|
41
42
|
CreateTransferError[CreateTransferError["linked_event_failed"] = 1] = "linked_event_failed";
|
|
42
43
|
CreateTransferError[CreateTransferError["linked_event_chain_open"] = 2] = "linked_event_chain_open";
|
|
43
|
-
CreateTransferError[CreateTransferError["
|
|
44
|
-
CreateTransferError[CreateTransferError["
|
|
45
|
-
CreateTransferError[CreateTransferError["
|
|
46
|
-
CreateTransferError[CreateTransferError["
|
|
47
|
-
CreateTransferError[CreateTransferError["
|
|
48
|
-
CreateTransferError[CreateTransferError["
|
|
49
|
-
CreateTransferError[CreateTransferError["
|
|
50
|
-
CreateTransferError[CreateTransferError["
|
|
51
|
-
CreateTransferError[CreateTransferError["
|
|
52
|
-
CreateTransferError[CreateTransferError["
|
|
53
|
-
CreateTransferError[CreateTransferError["
|
|
54
|
-
CreateTransferError[CreateTransferError["
|
|
55
|
-
CreateTransferError[CreateTransferError["
|
|
56
|
-
CreateTransferError[CreateTransferError["
|
|
57
|
-
CreateTransferError[CreateTransferError["
|
|
58
|
-
CreateTransferError[CreateTransferError["
|
|
59
|
-
CreateTransferError[CreateTransferError["
|
|
60
|
-
CreateTransferError[CreateTransferError["
|
|
61
|
-
CreateTransferError[CreateTransferError["
|
|
62
|
-
CreateTransferError[CreateTransferError["
|
|
63
|
-
CreateTransferError[CreateTransferError["
|
|
64
|
-
CreateTransferError[CreateTransferError["
|
|
65
|
-
CreateTransferError[CreateTransferError["
|
|
66
|
-
CreateTransferError[CreateTransferError["
|
|
67
|
-
CreateTransferError[CreateTransferError["
|
|
68
|
-
CreateTransferError[CreateTransferError["
|
|
69
|
-
CreateTransferError[CreateTransferError["
|
|
70
|
-
CreateTransferError[CreateTransferError["
|
|
71
|
-
CreateTransferError[CreateTransferError["
|
|
72
|
-
CreateTransferError[CreateTransferError["
|
|
73
|
-
CreateTransferError[CreateTransferError["
|
|
74
|
-
CreateTransferError[CreateTransferError["
|
|
75
|
-
CreateTransferError[CreateTransferError["
|
|
76
|
-
CreateTransferError[CreateTransferError["
|
|
77
|
-
CreateTransferError[CreateTransferError["
|
|
78
|
-
CreateTransferError[CreateTransferError["
|
|
79
|
-
CreateTransferError[CreateTransferError["
|
|
80
|
-
CreateTransferError[CreateTransferError["
|
|
81
|
-
CreateTransferError[CreateTransferError["
|
|
82
|
-
CreateTransferError[CreateTransferError["
|
|
83
|
-
CreateTransferError[CreateTransferError["
|
|
84
|
-
CreateTransferError[CreateTransferError["
|
|
85
|
-
CreateTransferError[CreateTransferError["
|
|
86
|
-
CreateTransferError[CreateTransferError["
|
|
87
|
-
CreateTransferError[CreateTransferError["
|
|
88
|
-
CreateTransferError[CreateTransferError["
|
|
89
|
-
CreateTransferError[CreateTransferError["
|
|
90
|
-
CreateTransferError[CreateTransferError["
|
|
91
|
-
CreateTransferError[CreateTransferError["
|
|
92
|
-
CreateTransferError[CreateTransferError["
|
|
93
|
-
CreateTransferError[CreateTransferError["
|
|
44
|
+
CreateTransferError[CreateTransferError["timestamp_must_be_zero"] = 3] = "timestamp_must_be_zero";
|
|
45
|
+
CreateTransferError[CreateTransferError["reserved_flag"] = 4] = "reserved_flag";
|
|
46
|
+
CreateTransferError[CreateTransferError["reserved_field"] = 5] = "reserved_field";
|
|
47
|
+
CreateTransferError[CreateTransferError["id_must_not_be_zero"] = 6] = "id_must_not_be_zero";
|
|
48
|
+
CreateTransferError[CreateTransferError["id_must_not_be_int_max"] = 7] = "id_must_not_be_int_max";
|
|
49
|
+
CreateTransferError[CreateTransferError["debit_account_id_must_not_be_zero"] = 8] = "debit_account_id_must_not_be_zero";
|
|
50
|
+
CreateTransferError[CreateTransferError["debit_account_id_must_not_be_int_max"] = 9] = "debit_account_id_must_not_be_int_max";
|
|
51
|
+
CreateTransferError[CreateTransferError["credit_account_id_must_not_be_zero"] = 10] = "credit_account_id_must_not_be_zero";
|
|
52
|
+
CreateTransferError[CreateTransferError["credit_account_id_must_not_be_int_max"] = 11] = "credit_account_id_must_not_be_int_max";
|
|
53
|
+
CreateTransferError[CreateTransferError["accounts_must_be_different"] = 12] = "accounts_must_be_different";
|
|
54
|
+
CreateTransferError[CreateTransferError["pending_id_must_be_zero"] = 13] = "pending_id_must_be_zero";
|
|
55
|
+
CreateTransferError[CreateTransferError["ledger_must_not_be_zero"] = 14] = "ledger_must_not_be_zero";
|
|
56
|
+
CreateTransferError[CreateTransferError["code_must_not_be_zero"] = 15] = "code_must_not_be_zero";
|
|
57
|
+
CreateTransferError[CreateTransferError["amount_must_not_be_zero"] = 16] = "amount_must_not_be_zero";
|
|
58
|
+
CreateTransferError[CreateTransferError["debit_account_not_found"] = 17] = "debit_account_not_found";
|
|
59
|
+
CreateTransferError[CreateTransferError["credit_account_not_found"] = 18] = "credit_account_not_found";
|
|
60
|
+
CreateTransferError[CreateTransferError["accounts_must_have_the_same_ledger"] = 19] = "accounts_must_have_the_same_ledger";
|
|
61
|
+
CreateTransferError[CreateTransferError["transfer_must_have_the_same_ledger_as_accounts"] = 20] = "transfer_must_have_the_same_ledger_as_accounts";
|
|
62
|
+
CreateTransferError[CreateTransferError["exists_with_different_flags"] = 21] = "exists_with_different_flags";
|
|
63
|
+
CreateTransferError[CreateTransferError["exists_with_different_debit_account_id"] = 22] = "exists_with_different_debit_account_id";
|
|
64
|
+
CreateTransferError[CreateTransferError["exists_with_different_credit_account_id"] = 23] = "exists_with_different_credit_account_id";
|
|
65
|
+
CreateTransferError[CreateTransferError["exists_with_different_user_data"] = 24] = "exists_with_different_user_data";
|
|
66
|
+
CreateTransferError[CreateTransferError["exists_with_different_pending_id"] = 25] = "exists_with_different_pending_id";
|
|
67
|
+
CreateTransferError[CreateTransferError["exists_with_different_timeout"] = 26] = "exists_with_different_timeout";
|
|
68
|
+
CreateTransferError[CreateTransferError["exists_with_different_code"] = 27] = "exists_with_different_code";
|
|
69
|
+
CreateTransferError[CreateTransferError["exists_with_different_amount"] = 28] = "exists_with_different_amount";
|
|
70
|
+
CreateTransferError[CreateTransferError["exists"] = 29] = "exists";
|
|
71
|
+
CreateTransferError[CreateTransferError["overflows_debits_pending"] = 30] = "overflows_debits_pending";
|
|
72
|
+
CreateTransferError[CreateTransferError["overflows_credits_pending"] = 31] = "overflows_credits_pending";
|
|
73
|
+
CreateTransferError[CreateTransferError["overflows_debits_posted"] = 32] = "overflows_debits_posted";
|
|
74
|
+
CreateTransferError[CreateTransferError["overflows_credits_posted"] = 33] = "overflows_credits_posted";
|
|
75
|
+
CreateTransferError[CreateTransferError["overflows_debits"] = 34] = "overflows_debits";
|
|
76
|
+
CreateTransferError[CreateTransferError["overflows_credits"] = 35] = "overflows_credits";
|
|
77
|
+
CreateTransferError[CreateTransferError["overflows_timeout"] = 36] = "overflows_timeout";
|
|
78
|
+
CreateTransferError[CreateTransferError["exceeds_credits"] = 37] = "exceeds_credits";
|
|
79
|
+
CreateTransferError[CreateTransferError["exceeds_debits"] = 38] = "exceeds_debits";
|
|
80
|
+
CreateTransferError[CreateTransferError["cannot_post_and_void_pending_transfer"] = 39] = "cannot_post_and_void_pending_transfer";
|
|
81
|
+
CreateTransferError[CreateTransferError["pending_transfer_cannot_post_or_void_another"] = 40] = "pending_transfer_cannot_post_or_void_another";
|
|
82
|
+
CreateTransferError[CreateTransferError["timeout_reserved_for_pending_transfer"] = 41] = "timeout_reserved_for_pending_transfer";
|
|
83
|
+
CreateTransferError[CreateTransferError["pending_id_must_not_be_zero"] = 42] = "pending_id_must_not_be_zero";
|
|
84
|
+
CreateTransferError[CreateTransferError["pending_id_must_not_be_int_max"] = 43] = "pending_id_must_not_be_int_max";
|
|
85
|
+
CreateTransferError[CreateTransferError["pending_id_must_be_different"] = 44] = "pending_id_must_be_different";
|
|
86
|
+
CreateTransferError[CreateTransferError["pending_transfer_not_found"] = 45] = "pending_transfer_not_found";
|
|
87
|
+
CreateTransferError[CreateTransferError["pending_transfer_not_pending"] = 46] = "pending_transfer_not_pending";
|
|
88
|
+
CreateTransferError[CreateTransferError["pending_transfer_has_different_debit_account_id"] = 47] = "pending_transfer_has_different_debit_account_id";
|
|
89
|
+
CreateTransferError[CreateTransferError["pending_transfer_has_different_credit_account_id"] = 48] = "pending_transfer_has_different_credit_account_id";
|
|
90
|
+
CreateTransferError[CreateTransferError["pending_transfer_has_different_ledger"] = 49] = "pending_transfer_has_different_ledger";
|
|
91
|
+
CreateTransferError[CreateTransferError["pending_transfer_has_different_code"] = 50] = "pending_transfer_has_different_code";
|
|
92
|
+
CreateTransferError[CreateTransferError["exceeds_pending_transfer_amount"] = 51] = "exceeds_pending_transfer_amount";
|
|
93
|
+
CreateTransferError[CreateTransferError["pending_transfer_has_different_amount"] = 52] = "pending_transfer_has_different_amount";
|
|
94
|
+
CreateTransferError[CreateTransferError["pending_transfer_already_posted"] = 53] = "pending_transfer_already_posted";
|
|
95
|
+
CreateTransferError[CreateTransferError["pending_transfer_already_voided"] = 54] = "pending_transfer_already_voided";
|
|
96
|
+
CreateTransferError[CreateTransferError["pending_transfer_expired"] = 55] = "pending_transfer_expired";
|
|
94
97
|
})(CreateTransferError = exports.CreateTransferError || (exports.CreateTransferError = {}));
|
|
95
98
|
var Operation;
|
|
96
99
|
(function (Operation) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAY,OAAO,CAAC,eAAe,CAAC,CAAA;AAoCj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AC,KAAK,CAAC,CAAA;oBACb,OAAM;iBACP;gBACD,OAAO,CAAC,OAAO,CAAC,CAAA;YAClB,CAAC,CAAA;YAED,IAAI;gBACF,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,eAAe,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;aACrE;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,KAAK,CAAC,CAAA;aACd;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,GAAS,EAAE;QACzB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACvB,IAAI,SAAS,EAAC;YACZ,aAAa,CAAC,SAAS,CAAC,CAAA;SACzB;QACD,OAAO,GAAG,SAAS,CAAA;IACrB,CAAC,CAAA;IAED,OAAO,GAAG;QACR,cAAc;QACd,eAAe;QACf,cAAc;QACd,eAAe;QACf,OAAO;QACP,UAAU;QACV,OAAO;KACR,CAAA;IAED,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE;QAC3B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACvB,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IAEnB,OAAO,OAAO,CAAA;AAChB,CAAC;AAzID,oCAyIC","sourcesContent":["const binding: Binding = require('./client.node')\ninterface Binding {\n init: (args: BindingInitArgs) => Context\n request: (context: Context, operation: Operation, batch: Event[], result: ResultCallback) => void\n raw_request: (context: Context, operation: Operation, raw_batch: Buffer, result: ResultCallback) => void\n tick: (context: Context) => void,\n deinit: (context: Context) => void,\n tick_ms: number\n}\n\ninterface BindingInitArgs {\n cluster_id: number, // u32\n replica_addresses: Buffer,\n}\n\nexport interface InitArgs {\n cluster_id: number, // u32\n replica_addresses: Array<string | number>,\n}\n\nexport type Context = object\n\nexport type Account = {\n id: bigint // u128\n user_data: bigint // u128\n reserved: Buffer // [48]u8\n ledger: number // u32, ledger of value\n code: number // u16, A chart of accounts code describing the type of account (e.g. clearing, settlement)\n flags: number // u16\n debits_pending: bigint // u64\n debits_posted: bigint // u64\n credits_pending: bigint // u64\n credits_posted: bigint // u64\n timestamp: bigint // u64, Set this to 0n - the actual value will be set by TigerBeetle server\n}\n\nexport enum AccountFlags {\n linked = (1 << 0),\n debits_must_not_exceed_credits = (1 << 1),\n credits_must_not_exceed_debits = (1 << 2)\n}\n\nexport enum CreateAccountError {\n // ok = 0 (No Error)\n linked_event_failed = 1,\n linked_event_chain_open,\n\n reserved_flag,\n reserved_field,\n\n id_must_not_be_zero,\n id_must_not_be_int_max,\n ledger_must_not_be_zero,\n code_must_not_be_zero,\n debits_pending_must_be_zero,\n debits_posted_must_be_zero,\n credits_pending_must_be_zero,\n credits_posted_must_be_zero,\n\n mutually_exclusive_flags,\n\n exists_with_different_flags,\n exists_with_different_user_data,\n exists_with_different_ledger,\n exists_with_different_code,\n exists,\n}\n\nexport type CreateAccountsError = {\n index: number,\n code: CreateAccountError,\n}\n\nexport type Transfer = {\n id: bigint, // u128\n debit_account_id: bigint, // u128\n credit_account_id: bigint, // u128\n user_data: bigint, // u128\n reserved: bigint, // u128\n pending_id: bigint, // u128\n timeout: bigint, // u64, In nanoseconds.\n ledger: number // u32, The ledger of value.\n code: number, // u16, A user-defined accounting code to describe the type of transfer (e.g. settlement).\n flags: number, // u16\n amount: bigint, // u64,\n timestamp: bigint, // u64, Set this to 0n - the timestamp will be set by TigerBeetle.\n}\n\nexport enum TransferFlags {\n linked = (1 << 0),\n pending = (1 << 1),\n post_pending_transfer = (1 << 2),\n void_pending_transfer = (1 << 3)\n}\n\nexport enum CreateTransferError {\n // ok = 0 (No Error)\n linked_event_failed = 1,\n linked_event_chain_open,\n\n reserved_flag,\n reserved_field,\n\n id_must_not_be_zero,\n id_must_not_be_int_max,\n debit_account_id_must_not_be_zero,\n debit_account_id_must_not_be_int_max,\n credit_account_id_must_not_be_zero,\n credit_account_id_must_not_be_int_max,\n accounts_must_be_different,\n\n pending_id_must_be_zero,\n\n ledger_must_not_be_zero,\n code_must_not_be_zero,\n amount_must_not_be_zero,\n\n debit_account_not_found,\n credit_account_not_found,\n\n accounts_must_have_the_same_ledger,\n transfer_must_have_the_same_ledger_as_accounts,\n\n exists_with_different_flags,\n exists_with_different_debit_account_id,\n exists_with_different_credit_account_id,\n exists_with_different_user_data,\n exists_with_different_pending_id,\n exists_with_different_timeout,\n exists_with_different_code,\n exists_with_different_amount,\n exists,\n\n overflows_debits_pending,\n overflows_credits_pending,\n overflows_debits_posted,\n overflows_credits_posted,\n overflows_debits,\n overflows_credits,\n\n exceeds_credits,\n exceeds_debits,\n\n cannot_post_and_void_pending_transfer,\n pending_transfer_cannot_post_or_void_another,\n timeout_reserved_for_pending_transfer,\n\n pending_id_must_not_be_zero,\n pending_id_must_not_be_int_max,\n pending_id_must_be_different,\n\n pending_transfer_not_found,\n pending_transfer_not_pending,\n\n pending_transfer_has_different_debit_account_id,\n pending_transfer_has_different_credit_account_id,\n pending_transfer_has_different_ledger,\n pending_transfer_has_different_code,\n\n exceeds_pending_transfer_amount,\n pending_transfer_has_different_amount,\n\n pending_transfer_already_posted,\n pending_transfer_already_voided,\n\n pending_transfer_expired,\n}\n\nexport type CreateTransfersError = {\n index: number,\n code: CreateTransferError,\n}\n\nexport type AccountID = bigint // u128\nexport type TransferID = bigint // u128\n\nexport type Event = Account | Transfer | AccountID | TransferID\nexport type Result = CreateAccountsError | CreateTransfersError | Account | Transfer\nexport type ResultCallback = (error: undefined | Error, results: Result[]) => void\n\nexport enum Operation {\n CREATE_ACCOUNT = 3,\n CREATE_TRANSFER,\n ACCOUNT_LOOKUP,\n TRANSFER_LOOKUP\n}\n\nexport interface Client {\n createAccounts: (batch: Account[]) => Promise<CreateAccountsError[]>\n createTransfers: (batch: Transfer[]) => Promise<CreateTransfersError[]>\n lookupAccounts: (batch: AccountID[]) => Promise<Account[]>\n lookupTransfers: (batch: TransferID[]) => Promise<Transfer[]>\n request: (operation: Operation, batch: Event[], callback: ResultCallback) => void\n rawRequest: (operation: Operation, rawBatch: Buffer, callback: ResultCallback) => void\n destroy: () => void\n}\n\nlet _args: InitArgs | undefined = undefined\nconst isSameArgs = (args: InitArgs): boolean => {\n if (typeof _args === 'undefined') {\n return false\n }\n\n if (_args.replica_addresses.length !== args.replica_addresses.length) {\n return false\n }\n\n let isSameReplicas = true\n args.replica_addresses.forEach((entry, index) => {\n if (_args?.replica_addresses[index] !== entry) {\n isSameReplicas = false\n }\n })\n\n return args.cluster_id === _args.cluster_id && isSameReplicas\n}\n\nlet _client: Client | undefined = undefined\nlet _interval: NodeJS.Timeout | undefined = undefined\n// Here to wait until `ping` is sent to server so that connection is registered - temporary till client table and sessions are implemented.\nlet _pinged = false\n// TODO: allow creation of clients if the arguments are different. Will require changes in node.zig as well.\nexport function createClient (args: InitArgs): Client {\n const duplicateArgs = isSameArgs(args)\n if (!duplicateArgs && typeof _client !== 'undefined'){\n throw new Error('Client has already been initialized with different arguments.')\n }\n\n if (duplicateArgs && typeof _client !== 'undefined'){\n throw new Error('Client has already been initialized with the same arguments.')\n }\n\n _args = Object.assign({}, { ...args })\n const context = binding.init({\n ...args,\n replica_addresses: Buffer.from(args.replica_addresses.join(','))\n })\n\n const request = (operation: Operation, batch: Event[], callback: ResultCallback) => {\n binding.request(context, operation, batch, callback)\n }\n\n const rawRequest = (operation: Operation, rawBatch: Buffer, callback: ResultCallback) => {\n binding.raw_request(context, operation, rawBatch, callback)\n }\n\n const createAccounts = async (batch: Account[]): Promise<CreateAccountsError[]> => {\n // Here to wait until `ping` is sent to server so that connection is registered - temporary till client table and sessions are implemented.\n if (!_pinged) {\n await new Promise<void>(resolve => {\n setTimeout(() => {\n _pinged = true\n resolve()\n }, 600)\n })\n }\n return new Promise((resolve, reject) => {\n const callback = (error: undefined | Error, results: CreateAccountsError[]) => {\n if (error) {\n reject(error)\n return\n }\n resolve(results)\n }\n\n try {\n binding.request(context, Operation.CREATE_ACCOUNT, batch, callback)\n } catch (error) {\n reject(error)\n }\n })\n }\n\n const createTransfers = async (batch: Transfer[]): Promise<CreateTransfersError[]> => {\n // Here to wait until `ping` is sent to server so that connection is registered - temporary till client table and sessions are implemented.\n if (!_pinged) {\n await new Promise<void>(resolve => {\n setTimeout(() => {\n _pinged = true\n resolve()\n }, 600)\n })\n }\n return new Promise((resolve, reject) => {\n const callback = (error: undefined | Error, results: CreateTransfersError[]) => {\n if (error) {\n reject(error)\n return\n }\n resolve(results)\n }\n\n try {\n binding.request(context, Operation.CREATE_TRANSFER, batch, callback)\n } catch (error) {\n reject(error)\n }\n })\n }\n\n const lookupAccounts = async (batch: AccountID[]): Promise<Account[]> => {\n return new Promise((resolve, reject) => {\n const callback = (error: undefined | Error, results: Account[]) => {\n if (error) {\n reject(error)\n return\n }\n resolve(results)\n }\n\n try {\n binding.request(context, Operation.ACCOUNT_LOOKUP, batch, callback)\n } catch (error) {\n reject(error)\n }\n })\n }\n\n const lookupTransfers = async (batch: TransferID[]): Promise<Transfer[]> => {\n return new Promise((resolve, reject) => {\n const callback = (error: undefined | Error, results: Transfer[]) => {\n if (error) {\n reject(error)\n return\n }\n resolve(results)\n }\n\n try {\n binding.request(context, Operation.TRANSFER_LOOKUP, batch, callback)\n } catch (error) {\n reject(error)\n }\n })\n }\n\n const destroy = (): void => {\n binding.deinit(context)\n if (_interval){\n clearInterval(_interval)\n }\n _client = undefined\n }\n\n _client = {\n createAccounts,\n createTransfers,\n lookupAccounts,\n lookupTransfers,\n request,\n rawRequest,\n destroy\n }\n\n _interval = setInterval(() => {\n binding.tick(context)\n }, binding.tick_ms)\n\n return _client\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAY,OAAO,CAAC,eAAe,CAAC,CAAA;AAoCjD,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,mDAAiB,CAAA;IACjB,mGAAyC,CAAA;IACzC,mGAAyC,CAAA;AAC3C,CAAC,EAJW,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CAAC,OAAO,CAAC,CAAA;YAClB,CAAC,CAAA;YAED,IAAI;gBACF,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,eAAe,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;aACrE;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,KAAK,CAAC,CAAA;aACd;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,GAAS,EAAE;QACzB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACvB,IAAI,SAAS,EAAC;YACZ,aAAa,CAAC,SAAS,CAAC,CAAA;SACzB;QACD,OAAO,GAAG,SAAS,CAAA;IACrB,CAAC,CAAA;IAED,OAAO,GAAG;QACR,cAAc;QACd,eAAe;QACf,cAAc;QACd,eAAe;QACf,OAAO;QACP,UAAU;QACV,OAAO;KACR,CAAA;IAED,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE;QAC3B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACvB,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IAEnB,OAAO,OAAO,CAAA;AAChB,CAAC;AAzID,oCAyIC","sourcesContent":["const binding: Binding = require('./client.node')\ninterface Binding {\n init: (args: BindingInitArgs) => Context\n request: (context: Context, operation: Operation, batch: Event[], result: ResultCallback) => void\n raw_request: (context: Context, operation: Operation, raw_batch: Buffer, result: ResultCallback) => void\n tick: (context: Context) => void,\n deinit: (context: Context) => void,\n tick_ms: number\n}\n\ninterface BindingInitArgs {\n cluster_id: number, // u32\n replica_addresses: Buffer,\n}\n\nexport interface InitArgs {\n cluster_id: number, // u32\n replica_addresses: Array<string | number>,\n}\n\nexport type Context = object\n\nexport type Account = {\n id: bigint // u128\n user_data: bigint // u128\n reserved: Buffer // [48]u8\n ledger: number // u32, ledger of value\n code: number // u16, A chart of accounts code describing the type of account (e.g. clearing, settlement)\n flags: number // u16\n debits_pending: bigint // u64\n debits_posted: bigint // u64\n credits_pending: bigint // u64\n credits_posted: bigint // u64\n timestamp: bigint // u64, Set this to 0n - the actual value will be set by TigerBeetle server\n}\n\nexport enum AccountFlags {\n linked = (1 << 0),\n debits_must_not_exceed_credits = (1 << 1),\n credits_must_not_exceed_debits = (1 << 2)\n}\n\nexport enum CreateAccountError {\n // ok = 0 (No Error)\n linked_event_failed = 1,\n linked_event_chain_open,\n timestamp_must_be_zero,\n\n reserved_flag,\n reserved_field,\n\n id_must_not_be_zero,\n id_must_not_be_int_max,\n ledger_must_not_be_zero,\n code_must_not_be_zero,\n debits_pending_must_be_zero,\n debits_posted_must_be_zero,\n credits_pending_must_be_zero,\n credits_posted_must_be_zero,\n\n mutually_exclusive_flags,\n\n exists_with_different_flags,\n exists_with_different_user_data,\n exists_with_different_ledger,\n exists_with_different_code,\n exists,\n}\n\nexport type CreateAccountsError = {\n index: number,\n code: CreateAccountError,\n}\n\nexport type Transfer = {\n id: bigint, // u128\n debit_account_id: bigint, // u128\n credit_account_id: bigint, // u128\n user_data: bigint, // u128\n reserved: bigint, // u128\n pending_id: bigint, // u128\n timeout: bigint, // u64, In nanoseconds.\n ledger: number // u32, The ledger of value.\n code: number, // u16, A user-defined accounting code to describe the type of transfer (e.g. settlement).\n flags: number, // u16\n amount: bigint, // u64,\n timestamp: bigint, // u64, Set this to 0n - the timestamp will be set by TigerBeetle.\n}\n\nexport enum TransferFlags {\n linked = (1 << 0),\n pending = (1 << 1),\n post_pending_transfer = (1 << 2),\n void_pending_transfer = (1 << 3)\n}\n\nexport enum CreateTransferError {\n // ok = 0 (No Error)\n linked_event_failed = 1,\n linked_event_chain_open,\n timestamp_must_be_zero,\n\n reserved_flag,\n reserved_field,\n\n id_must_not_be_zero,\n id_must_not_be_int_max,\n debit_account_id_must_not_be_zero,\n debit_account_id_must_not_be_int_max,\n credit_account_id_must_not_be_zero,\n credit_account_id_must_not_be_int_max,\n accounts_must_be_different,\n\n pending_id_must_be_zero,\n\n ledger_must_not_be_zero,\n code_must_not_be_zero,\n amount_must_not_be_zero,\n\n debit_account_not_found,\n credit_account_not_found,\n\n accounts_must_have_the_same_ledger,\n transfer_must_have_the_same_ledger_as_accounts,\n\n exists_with_different_flags,\n exists_with_different_debit_account_id,\n exists_with_different_credit_account_id,\n exists_with_different_user_data,\n exists_with_different_pending_id,\n exists_with_different_timeout,\n exists_with_different_code,\n exists_with_different_amount,\n exists,\n\n overflows_debits_pending,\n overflows_credits_pending,\n overflows_debits_posted,\n overflows_credits_posted,\n overflows_debits,\n overflows_credits,\n overflows_timeout,\n\n exceeds_credits,\n exceeds_debits,\n\n cannot_post_and_void_pending_transfer,\n pending_transfer_cannot_post_or_void_another,\n timeout_reserved_for_pending_transfer,\n\n pending_id_must_not_be_zero,\n pending_id_must_not_be_int_max,\n pending_id_must_be_different,\n\n pending_transfer_not_found,\n pending_transfer_not_pending,\n\n pending_transfer_has_different_debit_account_id,\n pending_transfer_has_different_credit_account_id,\n pending_transfer_has_different_ledger,\n pending_transfer_has_different_code,\n\n exceeds_pending_transfer_amount,\n pending_transfer_has_different_amount,\n\n pending_transfer_already_posted,\n pending_transfer_already_voided,\n\n pending_transfer_expired,\n}\n\nexport type CreateTransfersError = {\n index: number,\n code: CreateTransferError,\n}\n\nexport type AccountID = bigint // u128\nexport type TransferID = bigint // u128\n\nexport type Event = Account | Transfer | AccountID | TransferID\nexport type Result = CreateAccountsError | CreateTransfersError | Account | Transfer\nexport type ResultCallback = (error: undefined | Error, results: Result[]) => void\n\nexport enum Operation {\n CREATE_ACCOUNT = 3,\n CREATE_TRANSFER,\n ACCOUNT_LOOKUP,\n TRANSFER_LOOKUP\n}\n\nexport interface Client {\n createAccounts: (batch: Account[]) => Promise<CreateAccountsError[]>\n createTransfers: (batch: Transfer[]) => Promise<CreateTransfersError[]>\n lookupAccounts: (batch: AccountID[]) => Promise<Account[]>\n lookupTransfers: (batch: TransferID[]) => Promise<Transfer[]>\n request: (operation: Operation, batch: Event[], callback: ResultCallback) => void\n rawRequest: (operation: Operation, rawBatch: Buffer, callback: ResultCallback) => void\n destroy: () => void\n}\n\nlet _args: InitArgs | undefined = undefined\nconst isSameArgs = (args: InitArgs): boolean => {\n if (typeof _args === 'undefined') {\n return false\n }\n\n if (_args.replica_addresses.length !== args.replica_addresses.length) {\n return false\n }\n\n let isSameReplicas = true\n args.replica_addresses.forEach((entry, index) => {\n if (_args?.replica_addresses[index] !== entry) {\n isSameReplicas = false\n }\n })\n\n return args.cluster_id === _args.cluster_id && isSameReplicas\n}\n\nlet _client: Client | undefined = undefined\nlet _interval: NodeJS.Timeout | undefined = undefined\n// Here to wait until `ping` is sent to server so that connection is registered - temporary till client table and sessions are implemented.\nlet _pinged = false\n// TODO: allow creation of clients if the arguments are different. Will require changes in node.zig as well.\nexport function createClient (args: InitArgs): Client {\n const duplicateArgs = isSameArgs(args)\n if (!duplicateArgs && typeof _client !== 'undefined'){\n throw new Error('Client has already been initialized with different arguments.')\n }\n\n if (duplicateArgs && typeof _client !== 'undefined'){\n throw new Error('Client has already been initialized with the same arguments.')\n }\n\n _args = Object.assign({}, { ...args })\n const context = binding.init({\n ...args,\n replica_addresses: Buffer.from(args.replica_addresses.join(','))\n })\n\n const request = (operation: Operation, batch: Event[], callback: ResultCallback) => {\n binding.request(context, operation, batch, callback)\n }\n\n const rawRequest = (operation: Operation, rawBatch: Buffer, callback: ResultCallback) => {\n binding.raw_request(context, operation, rawBatch, callback)\n }\n\n const createAccounts = async (batch: Account[]): Promise<CreateAccountsError[]> => {\n // Here to wait until `ping` is sent to server so that connection is registered - temporary till client table and sessions are implemented.\n if (!_pinged) {\n await new Promise<void>(resolve => {\n setTimeout(() => {\n _pinged = true\n resolve()\n }, 600)\n })\n }\n return new Promise((resolve, reject) => {\n const callback = (error: undefined | Error, results: CreateAccountsError[]) => {\n if (error) {\n reject(error)\n return\n }\n resolve(results)\n }\n\n try {\n binding.request(context, Operation.CREATE_ACCOUNT, batch, callback)\n } catch (error) {\n reject(error)\n }\n })\n }\n\n const createTransfers = async (batch: Transfer[]): Promise<CreateTransfersError[]> => {\n // Here to wait until `ping` is sent to server so that connection is registered - temporary till client table and sessions are implemented.\n if (!_pinged) {\n await new Promise<void>(resolve => {\n setTimeout(() => {\n _pinged = true\n resolve()\n }, 600)\n })\n }\n return new Promise((resolve, reject) => {\n const callback = (error: undefined | Error, results: CreateTransfersError[]) => {\n if (error) {\n reject(error)\n return\n }\n resolve(results)\n }\n\n try {\n binding.request(context, Operation.CREATE_TRANSFER, batch, callback)\n } catch (error) {\n reject(error)\n }\n })\n }\n\n const lookupAccounts = async (batch: AccountID[]): Promise<Account[]> => {\n return new Promise((resolve, reject) => {\n const callback = (error: undefined | Error, results: Account[]) => {\n if (error) {\n reject(error)\n return\n }\n resolve(results)\n }\n\n try {\n binding.request(context, Operation.ACCOUNT_LOOKUP, batch, callback)\n } catch (error) {\n reject(error)\n }\n })\n }\n\n const lookupTransfers = async (batch: TransferID[]): Promise<Transfer[]> => {\n return new Promise((resolve, reject) => {\n const callback = (error: undefined | Error, results: Transfer[]) => {\n if (error) {\n reject(error)\n return\n }\n resolve(results)\n }\n\n try {\n binding.request(context, Operation.TRANSFER_LOOKUP, batch, callback)\n } catch (error) {\n reject(error)\n }\n })\n }\n\n const destroy = (): void => {\n binding.deinit(context)\n if (_interval){\n clearInterval(_interval)\n }\n _client = undefined\n }\n\n _client = {\n createAccounts,\n createTransfers,\n lookupAccounts,\n lookupTransfers,\n request,\n rawRequest,\n destroy\n }\n\n _interval = setInterval(() => {\n binding.tick(context)\n }, binding.tick_ms)\n\n return _client\n}\n"]}
|
package/package.json
CHANGED
package/scripts/build_lib.sh
CHANGED
|
@@ -5,25 +5,37 @@ set -e
|
|
|
5
5
|
# macOS 13 Ventura is not supported on Zig 0.9.x.
|
|
6
6
|
# Overriding -target is one workaround Andrew suggests.
|
|
7
7
|
# https://github.com/ziglang/zig/issues/10478#issuecomment-1294313967
|
|
8
|
-
|
|
9
|
-
# because the rest of it doesn't always seem to be valid when passed
|
|
10
|
-
# back in to `-target`.
|
|
11
|
-
target="$(./zig/zig targets | grep triple |cut -d '"' -f 4 | cut -d '.' -f 1)"
|
|
8
|
+
target=""
|
|
12
9
|
if [ "$(./zig/zig targets | grep triple |cut -d '"' -f 4 | cut -d '.' -f 1,2)" = "aarch64-macos.13" ]; then
|
|
13
|
-
target="native-macos.11"
|
|
10
|
+
target="-target native-macos.11"
|
|
14
11
|
fi
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
# Zig picks musl libc on RHEL instead of glibc, incorrectly
|
|
14
|
+
# https://github.com/ziglang/zig/issues/12156
|
|
15
|
+
if [ -f "/etc/redhat-release" ]; then
|
|
16
|
+
if ! grep Fedora /etc/redhat-release; then
|
|
17
|
+
target="-target native-native-gnu"
|
|
18
|
+
fi
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
if [ "$target" = "" ]; then
|
|
22
|
+
echo "Building default target"
|
|
23
|
+
else
|
|
24
|
+
echo "Building for '$target'"
|
|
25
|
+
fi
|
|
17
26
|
|
|
18
27
|
mkdir -p dist
|
|
19
28
|
|
|
20
|
-
|
|
29
|
+
# Need to do string eval-ing because of shellcheck's strict string
|
|
30
|
+
# interpolation rules.
|
|
31
|
+
cmd="./zig/zig build-lib \
|
|
21
32
|
-mcpu=baseline \
|
|
22
33
|
-OReleaseSafe \
|
|
23
34
|
-dynamic \
|
|
24
35
|
-lc \
|
|
25
|
-
-isystem build/node
|
|
36
|
+
-isystem build/node-$(node --version)/include/node \
|
|
26
37
|
-fallow-shlib-undefined \
|
|
27
38
|
-femit-bin=dist/client.node \
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
$target src/node.zig"
|
|
40
|
+
|
|
41
|
+
eval "$cmd"
|
package/src/index.ts
CHANGED
|
@@ -44,6 +44,7 @@ export enum CreateAccountError {
|
|
|
44
44
|
// ok = 0 (No Error)
|
|
45
45
|
linked_event_failed = 1,
|
|
46
46
|
linked_event_chain_open,
|
|
47
|
+
timestamp_must_be_zero,
|
|
47
48
|
|
|
48
49
|
reserved_flag,
|
|
49
50
|
reserved_field,
|
|
@@ -97,6 +98,7 @@ export enum CreateTransferError {
|
|
|
97
98
|
// ok = 0 (No Error)
|
|
98
99
|
linked_event_failed = 1,
|
|
99
100
|
linked_event_chain_open,
|
|
101
|
+
timestamp_must_be_zero,
|
|
100
102
|
|
|
101
103
|
reserved_flag,
|
|
102
104
|
reserved_field,
|
|
@@ -137,6 +139,7 @@ export enum CreateTransferError {
|
|
|
137
139
|
overflows_credits_posted,
|
|
138
140
|
overflows_debits,
|
|
139
141
|
overflows_credits,
|
|
142
|
+
overflows_timeout,
|
|
140
143
|
|
|
141
144
|
exceeds_credits,
|
|
142
145
|
exceeds_debits,
|
|
@@ -80,6 +80,7 @@ const ConfigCluster = struct {
|
|
|
80
80
|
cache_line_size: comptime_int = 64,
|
|
81
81
|
clients_max: usize,
|
|
82
82
|
pipeline_prepare_queue_max: usize = 8,
|
|
83
|
+
view_change_headers_max: usize = 8,
|
|
83
84
|
quorum_replication_max: u8 = 3,
|
|
84
85
|
journal_slot_count: usize = 1024,
|
|
85
86
|
message_size_max: usize = 1 * 1024 * 1024,
|
|
@@ -180,6 +181,7 @@ pub const configs = struct {
|
|
|
180
181
|
.cluster = .{
|
|
181
182
|
.clients_max = 4 + 3,
|
|
182
183
|
.pipeline_prepare_queue_max = 4,
|
|
184
|
+
.view_change_headers_max = 4,
|
|
183
185
|
.journal_slot_count = Config.Cluster.journal_slot_count_min,
|
|
184
186
|
.message_size_max = Config.Cluster.message_size_max_min(4),
|
|
185
187
|
.storage_size_max = 4 * 1024 * 1024 * 1024,
|
|
@@ -157,6 +157,9 @@ comptime {
|
|
|
157
157
|
assert(message_size_max >= @sizeOf(vsr.Header));
|
|
158
158
|
assert(message_size_max >= sector_size);
|
|
159
159
|
assert(message_size_max >= Config.Cluster.message_size_max_min(clients_max));
|
|
160
|
+
|
|
161
|
+
// Ensure that DVC/SV messages can fit all necessary headers.
|
|
162
|
+
assert(message_body_size_max >= view_change_headers_max * @sizeOf(vsr.Header));
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
/// The maximum number of Viewstamped Replication prepare messages that can be inflight at a time.
|
|
@@ -184,6 +187,21 @@ comptime {
|
|
|
184
187
|
assert(pipeline_request_queue_max >= 0);
|
|
185
188
|
}
|
|
186
189
|
|
|
190
|
+
/// The number of prepare headers to include in the body of a DVC/SV.
|
|
191
|
+
///
|
|
192
|
+
/// CRITICAL:
|
|
193
|
+
/// We must provide enough headers to cover all uncommitted headers so that the new
|
|
194
|
+
/// primary (if we are in a view change) can decide whether to discard uncommitted headers
|
|
195
|
+
/// that cannot be repaired because they are gaps. See DVCQuorum for more detail.
|
|
196
|
+
pub const view_change_headers_max = config.cluster.view_change_headers_max;
|
|
197
|
+
|
|
198
|
+
comptime {
|
|
199
|
+
assert(view_change_headers_max > 0);
|
|
200
|
+
assert(view_change_headers_max >= pipeline_prepare_queue_max);
|
|
201
|
+
assert(view_change_headers_max <= journal_slot_count);
|
|
202
|
+
assert(view_change_headers_max <= @divFloor(message_body_size_max, @sizeOf(vsr.Header)));
|
|
203
|
+
}
|
|
204
|
+
|
|
187
205
|
/// The minimum and maximum amount of time in milliseconds to wait before initiating a connection.
|
|
188
206
|
/// Exponential backoff and jitter are applied within this range.
|
|
189
207
|
pub const connection_delay_min_ms = config.process.connection_delay_min_ms;
|
|
@@ -419,16 +419,17 @@ const Environment = struct {
|
|
|
419
419
|
env.manifest_log.checkpoint(checkpoint_callback);
|
|
420
420
|
env.wait(&env.manifest_log);
|
|
421
421
|
|
|
422
|
-
|
|
423
|
-
vsr_state.commit_min += 1;
|
|
424
|
-
vsr_state.commit_min_checksum += 1;
|
|
425
|
-
vsr_state.commit_max += 1;
|
|
422
|
+
const vsr_state = &env.manifest_log.superblock.working.vsr_state;
|
|
426
423
|
|
|
427
424
|
env.pending += 1;
|
|
428
425
|
env.manifest_log.superblock.checkpoint(
|
|
429
426
|
checkpoint_superblock_callback,
|
|
430
427
|
&env.superblock_context,
|
|
431
|
-
|
|
428
|
+
.{
|
|
429
|
+
.commit_min_checksum = vsr_state.commit_min_checksum + 1,
|
|
430
|
+
.commit_min = vsr_state.commit_min + 1,
|
|
431
|
+
.commit_max = vsr_state.commit_max + 1,
|
|
432
|
+
},
|
|
432
433
|
);
|
|
433
434
|
env.wait(&env.manifest_log);
|
|
434
435
|
|
|
@@ -202,15 +202,16 @@ const Environment = struct {
|
|
|
202
202
|
|
|
203
203
|
log.debug("forest checkpointing completed!", .{});
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
vsr_state.commit_min += 1;
|
|
207
|
-
vsr_state.commit_min_checkpoint += 1;
|
|
205
|
+
const vsr_state = &env.superblock.staging.vsr_state;
|
|
208
206
|
|
|
209
207
|
env.state = .superblock_checkpointing;
|
|
210
208
|
env.superblock.checkpoint(
|
|
211
209
|
superblock_checkpoint_callback,
|
|
212
210
|
&env.superblock_context,
|
|
213
|
-
|
|
211
|
+
.{
|
|
212
|
+
.commit_min_checkpoint = vsr_state.commit_min_checkpoint + 1,
|
|
213
|
+
.commit_min = vsr_state.commit_min + 1,
|
|
214
|
+
},
|
|
214
215
|
);
|
|
215
216
|
}
|
|
216
217
|
|