@mainsail/consensus 0.0.1-alpha.1
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/LICENSE +623 -0
- package/distribution/aggregator.d.ts +11 -0
- package/distribution/aggregator.d.ts.map +1 -0
- package/distribution/aggregator.js +58 -0
- package/distribution/aggregator.js.map +1 -0
- package/distribution/bootstrapper.d.ts +8 -0
- package/distribution/bootstrapper.d.ts.map +1 -0
- package/distribution/bootstrapper.js +68 -0
- package/distribution/bootstrapper.js.map +1 -0
- package/distribution/commit-state.d.ts +19 -0
- package/distribution/commit-state.d.ts.map +1 -0
- package/distribution/commit-state.js +102 -0
- package/distribution/commit-state.js.map +1 -0
- package/distribution/consensus.d.ts +45 -0
- package/distribution/consensus.d.ts.map +1 -0
- package/distribution/consensus.js +445 -0
- package/distribution/consensus.js.map +1 -0
- package/distribution/index.d.ts +6 -0
- package/distribution/index.d.ts.map +1 -0
- package/distribution/index.js +59 -0
- package/distribution/index.js.map +1 -0
- package/distribution/processors/abstract-processor.d.ts +16 -0
- package/distribution/processors/abstract-processor.d.ts.map +1 -0
- package/distribution/processors/abstract-processor.js +52 -0
- package/distribution/processors/abstract-processor.js.map +1 -0
- package/distribution/processors/commit-processor.d.ts +14 -0
- package/distribution/processors/commit-processor.d.ts.map +1 -0
- package/distribution/processors/commit-processor.js +103 -0
- package/distribution/processors/commit-processor.js.map +1 -0
- package/distribution/processors/index.d.ts +5 -0
- package/distribution/processors/index.d.ts.map +1 -0
- package/distribution/processors/index.js +21 -0
- package/distribution/processors/index.js.map +1 -0
- package/distribution/processors/precommit-processor.d.ts +12 -0
- package/distribution/processors/precommit-processor.d.ts.map +1 -0
- package/distribution/processors/precommit-processor.js +81 -0
- package/distribution/processors/precommit-processor.js.map +1 -0
- package/distribution/processors/prevote-processor.d.ts +12 -0
- package/distribution/processors/prevote-processor.d.ts.map +1 -0
- package/distribution/processors/prevote-processor.js +81 -0
- package/distribution/processors/prevote-processor.js.map +1 -0
- package/distribution/processors/proposal-processor.d.ts +16 -0
- package/distribution/processors/proposal-processor.d.ts.map +1 -0
- package/distribution/processors/proposal-processor.js +148 -0
- package/distribution/processors/proposal-processor.js.map +1 -0
- package/distribution/round-state-repository.d.ts +9 -0
- package/distribution/round-state-repository.d.ts.map +1 -0
- package/distribution/round-state-repository.js +54 -0
- package/distribution/round-state-repository.js.map +1 -0
- package/distribution/round-state.d.ts +49 -0
- package/distribution/round-state.d.ts.map +1 -0
- package/distribution/round-state.js +315 -0
- package/distribution/round-state.js.map +1 -0
- package/distribution/scheduler.d.ts +13 -0
- package/distribution/scheduler.d.ts.map +1 -0
- package/distribution/scheduler.js +125 -0
- package/distribution/scheduler.js.map +1 -0
- package/distribution/storage.d.ts +19 -0
- package/distribution/storage.d.ts.map +1 -0
- package/distribution/storage.js +114 -0
- package/distribution/storage.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"round-state-repository.js","sourceRoot":"","sources":["../source/round-state-repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,mDAAyD;AACzD,mDAA6D;AAE7D,+CAA2C;AAGpC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAA1B;;QAIN,4CAAe,IAAI,GAAG,EAA0C,EAAC;IAuBlE,CAAC;IArBO,aAAa,CAAC,MAAc,EAAE,KAAa;QACjD,MAAM,GAAG,GAAG,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC;QAEjC,IAAI,CAAC,uBAAA,IAAI,yCAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,uBAAA,IAAI,yCAAa,CAAC,GAAG,CAAC,GAAG,EAAE,uBAAA,IAAI,+EAAkB,MAAtB,IAAI,EAAmB,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,uBAAA,IAAI,yCAAa,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;IACpC,CAAC;IAEM,cAAc;QACpB,OAAO,CAAC,GAAG,uBAAA,IAAI,yCAAa,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,CAAC;IAEM,KAAK;QACX,uBAAA,IAAI,yCAAa,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CAKD,CAAA;AA3BY,oDAAoB;;;yFAwBd,MAAc,EAAE,KAAa;IAC9C,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,wBAAU,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC9D,CAAC;AAxBgB;IADhB,IAAA,kBAAM,EAAC,uBAAW,CAAC,WAAW,CAAC,QAAQ,CAAC;;iDACW;+BAFxC,oBAAoB;IADhC,IAAA,sBAAU,GAAE;GACA,oBAAoB,CA2BhC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Contracts } from "@mainsail/contracts";
|
|
2
|
+
export declare class RoundState implements Contracts.Consensus.RoundState {
|
|
3
|
+
#private;
|
|
4
|
+
private readonly aggregator;
|
|
5
|
+
private readonly configuration;
|
|
6
|
+
private readonly stateService;
|
|
7
|
+
private readonly validatorSet;
|
|
8
|
+
private readonly proposerSelector;
|
|
9
|
+
private readonly commitSerializer;
|
|
10
|
+
private readonly logger;
|
|
11
|
+
initialize(): void;
|
|
12
|
+
get height(): number;
|
|
13
|
+
get round(): number;
|
|
14
|
+
get persist(): boolean;
|
|
15
|
+
get validators(): string[];
|
|
16
|
+
get proposer(): Contracts.State.ValidatorWallet;
|
|
17
|
+
get store(): Contracts.State.Store;
|
|
18
|
+
configure(height: number, round: number): RoundState;
|
|
19
|
+
getValidator(consensusPublicKey: string): Contracts.State.ValidatorWallet;
|
|
20
|
+
hasProposal(): boolean;
|
|
21
|
+
addProposal(proposal: Contracts.Crypto.Proposal): void;
|
|
22
|
+
getProposal(): Contracts.Crypto.Proposal | undefined;
|
|
23
|
+
getBlock(): Contracts.Crypto.Block;
|
|
24
|
+
getCommit(): Promise<Contracts.Crypto.Commit>;
|
|
25
|
+
setProcessorResult(processorResult: boolean): void;
|
|
26
|
+
hasProcessorResult(): boolean;
|
|
27
|
+
getProcessorResult(): boolean;
|
|
28
|
+
hasPrevote(validatorIndex: number): boolean;
|
|
29
|
+
addPrevote(prevote: Contracts.Crypto.Prevote): void;
|
|
30
|
+
hasPrecommit(validatorIndex: number): boolean;
|
|
31
|
+
addPrecommit(precommit: Contracts.Crypto.Precommit): void;
|
|
32
|
+
hasMajorityPrevotes(): boolean;
|
|
33
|
+
hasMajorityPrevotesAny(): boolean;
|
|
34
|
+
hasMajorityPrevotesNull(): boolean;
|
|
35
|
+
hasMajorityPrecommits(): boolean;
|
|
36
|
+
hasMajorityPrecommitsAny(): boolean;
|
|
37
|
+
hasMinorityPrevotesOrPrecommits(): boolean;
|
|
38
|
+
getPrevote(validatorIndex: number): Contracts.Crypto.Prevote | undefined;
|
|
39
|
+
getPrevotes(): Contracts.Crypto.Prevote[];
|
|
40
|
+
getPrecommit(validatorIndex: number): Contracts.Crypto.Precommit | undefined;
|
|
41
|
+
getPrecommits(): Contracts.Crypto.Precommit[];
|
|
42
|
+
getValidatorsSignedPrevote(): readonly boolean[];
|
|
43
|
+
getValidatorsSignedPrecommit(): readonly boolean[];
|
|
44
|
+
aggregatePrevotes(): Promise<Contracts.Crypto.AggregatedSignature>;
|
|
45
|
+
aggregatePrecommits(): Promise<Contracts.Crypto.AggregatedSignature>;
|
|
46
|
+
logPrevotes(): void;
|
|
47
|
+
logPrecommits(): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=round-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"round-state.d.ts","sourceRoot":"","sources":["../source/round-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAG7D,qBACa,UAAW,YAAW,SAAS,CAAC,SAAS,CAAC,UAAU;;IAEhE,OAAO,CAAC,QAAQ,CA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,CAAC,OAAO,GAAG,IAAI;IAUnD,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO;IAI7C,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI;IAUzD,mBAAmB,IAAI,OAAO;IAQ9B,sBAAsB,IAAI,OAAO;IAIjC,uBAAuB,IAAI,OAAO;IAIlC,qBAAqB,IAAI,OAAO;IAQhC,wBAAwB,IAAI,OAAO;IAInC,+BAA+B,IAAI,OAAO;IAI1C,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,GAAG,SAAS;IAIxE,WAAW,IAAI,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE;IAIzC,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,SAAS,GAAG,SAAS;IAI5E,aAAa,IAAI,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE;IAI7C,0BAA0B,IAAI,SAAS,OAAO,EAAE;IAIhD,4BAA4B,IAAI,SAAS,OAAO,EAAE;IAI5C,iBAAiB,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAKlE,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAK1E,WAAW,IAAI,IAAI;IAUnB,aAAa,IAAI,IAAI;CAwD5B"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var _RoundState_instances, _RoundState_height, _RoundState_round, _RoundState_proposal, _RoundState_processorResult, _RoundState_prevotes, _RoundState_prevotesCount, _RoundState_precommits, _RoundState_precommitsCount, _RoundState_validators, _RoundState_validatorsSignedPrevote, _RoundState_validatorsSignedPrecommit, _RoundState_proposer, _RoundState_commit, _RoundState_store, _RoundState_hasMinorityPrevotes, _RoundState_hasMinorityPrecommits, _RoundState_isMajority, _RoundState_isMinority, _RoundState_increasePrevoteCount, _RoundState_getPrevoteCount, _RoundState_increasePrecommitCount, _RoundState_getPrecommitCount, _RoundState_getSignatures;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.RoundState = void 0;
|
|
25
|
+
const container_1 = require("@mainsail/container");
|
|
26
|
+
const contracts_1 = require("@mainsail/contracts");
|
|
27
|
+
const kernel_1 = require("@mainsail/kernel");
|
|
28
|
+
let RoundState = class RoundState {
|
|
29
|
+
constructor() {
|
|
30
|
+
_RoundState_instances.add(this);
|
|
31
|
+
_RoundState_height.set(this, 0);
|
|
32
|
+
_RoundState_round.set(this, 0);
|
|
33
|
+
_RoundState_proposal.set(this, void 0);
|
|
34
|
+
_RoundState_processorResult.set(this, void 0);
|
|
35
|
+
_RoundState_prevotes.set(this, new Map());
|
|
36
|
+
_RoundState_prevotesCount.set(this, new Map());
|
|
37
|
+
_RoundState_precommits.set(this, new Map());
|
|
38
|
+
_RoundState_precommitsCount.set(this, new Map());
|
|
39
|
+
_RoundState_validators.set(this, new Map());
|
|
40
|
+
_RoundState_validatorsSignedPrevote.set(this, []);
|
|
41
|
+
_RoundState_validatorsSignedPrecommit.set(this, []);
|
|
42
|
+
_RoundState_proposer.set(this, void 0);
|
|
43
|
+
_RoundState_commit.set(this, void 0);
|
|
44
|
+
_RoundState_store.set(this, void 0);
|
|
45
|
+
}
|
|
46
|
+
initialize() {
|
|
47
|
+
__classPrivateFieldSet(this, _RoundState_store, this.stateService.createStoreClone(), "f");
|
|
48
|
+
}
|
|
49
|
+
get height() {
|
|
50
|
+
return __classPrivateFieldGet(this, _RoundState_height, "f");
|
|
51
|
+
}
|
|
52
|
+
get round() {
|
|
53
|
+
return __classPrivateFieldGet(this, _RoundState_round, "f");
|
|
54
|
+
}
|
|
55
|
+
get persist() {
|
|
56
|
+
return true; // Store block in database every time
|
|
57
|
+
}
|
|
58
|
+
get validators() {
|
|
59
|
+
return [...__classPrivateFieldGet(this, _RoundState_validators, "f").keys()];
|
|
60
|
+
}
|
|
61
|
+
get proposer() {
|
|
62
|
+
return __classPrivateFieldGet(this, _RoundState_proposer, "f");
|
|
63
|
+
}
|
|
64
|
+
get store() {
|
|
65
|
+
return __classPrivateFieldGet(this, _RoundState_store, "f");
|
|
66
|
+
}
|
|
67
|
+
configure(height, round) {
|
|
68
|
+
__classPrivateFieldSet(this, _RoundState_height, height, "f");
|
|
69
|
+
__classPrivateFieldSet(this, _RoundState_round, round, "f");
|
|
70
|
+
const validators = this.validatorSet.getActiveValidators();
|
|
71
|
+
for (const validator of validators) {
|
|
72
|
+
const consensusPublicKey = validator.getConsensusPublicKey();
|
|
73
|
+
__classPrivateFieldGet(this, _RoundState_validators, "f").set(consensusPublicKey, validator);
|
|
74
|
+
__classPrivateFieldGet(this, _RoundState_validatorsSignedPrecommit, "f").push(false);
|
|
75
|
+
__classPrivateFieldGet(this, _RoundState_validatorsSignedPrevote, "f").push(false);
|
|
76
|
+
}
|
|
77
|
+
const validatorIndex = this.proposerSelector.getValidatorIndex(round);
|
|
78
|
+
__classPrivateFieldSet(this, _RoundState_proposer, validators[validatorIndex], "f");
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
getValidator(consensusPublicKey) {
|
|
82
|
+
const validator = __classPrivateFieldGet(this, _RoundState_validators, "f").get(consensusPublicKey);
|
|
83
|
+
kernel_1.Utils.assert.defined(validator);
|
|
84
|
+
return validator;
|
|
85
|
+
}
|
|
86
|
+
hasProposal() {
|
|
87
|
+
return !!__classPrivateFieldGet(this, _RoundState_proposal, "f");
|
|
88
|
+
}
|
|
89
|
+
addProposal(proposal) {
|
|
90
|
+
if (__classPrivateFieldGet(this, _RoundState_proposal, "f")) {
|
|
91
|
+
throw new Error("Proposal already exists.");
|
|
92
|
+
}
|
|
93
|
+
__classPrivateFieldSet(this, _RoundState_proposal, proposal, "f");
|
|
94
|
+
}
|
|
95
|
+
getProposal() {
|
|
96
|
+
return __classPrivateFieldGet(this, _RoundState_proposal, "f");
|
|
97
|
+
}
|
|
98
|
+
getBlock() {
|
|
99
|
+
if (__classPrivateFieldGet(this, _RoundState_proposal, "f")) {
|
|
100
|
+
return __classPrivateFieldGet(this, _RoundState_proposal, "f").block.block;
|
|
101
|
+
}
|
|
102
|
+
throw new Error("Block is not available, because proposal is not set");
|
|
103
|
+
}
|
|
104
|
+
async getCommit() {
|
|
105
|
+
if (!__classPrivateFieldGet(this, _RoundState_commit, "f")) {
|
|
106
|
+
const majority = await this.aggregatePrecommits();
|
|
107
|
+
const proposal = this.getProposal();
|
|
108
|
+
kernel_1.Utils.assert.defined(proposal);
|
|
109
|
+
const { round, block: { block }, } = proposal;
|
|
110
|
+
const commit = {
|
|
111
|
+
block,
|
|
112
|
+
proof: {
|
|
113
|
+
round,
|
|
114
|
+
...majority,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
const serialized = await this.commitSerializer.serializeCommit(commit);
|
|
118
|
+
__classPrivateFieldSet(this, _RoundState_commit, {
|
|
119
|
+
...commit,
|
|
120
|
+
serialized: serialized.toString("hex"),
|
|
121
|
+
}, "f");
|
|
122
|
+
}
|
|
123
|
+
return __classPrivateFieldGet(this, _RoundState_commit, "f");
|
|
124
|
+
}
|
|
125
|
+
setProcessorResult(processorResult) {
|
|
126
|
+
__classPrivateFieldSet(this, _RoundState_processorResult, processorResult, "f");
|
|
127
|
+
}
|
|
128
|
+
hasProcessorResult() {
|
|
129
|
+
return __classPrivateFieldGet(this, _RoundState_processorResult, "f") !== undefined;
|
|
130
|
+
}
|
|
131
|
+
getProcessorResult() {
|
|
132
|
+
if (__classPrivateFieldGet(this, _RoundState_processorResult, "f") === undefined) {
|
|
133
|
+
throw new Error("Processor result is undefined.");
|
|
134
|
+
}
|
|
135
|
+
return __classPrivateFieldGet(this, _RoundState_processorResult, "f");
|
|
136
|
+
}
|
|
137
|
+
hasPrevote(validatorIndex) {
|
|
138
|
+
return __classPrivateFieldGet(this, _RoundState_prevotes, "f").has(validatorIndex);
|
|
139
|
+
}
|
|
140
|
+
addPrevote(prevote) {
|
|
141
|
+
if (__classPrivateFieldGet(this, _RoundState_prevotes, "f").has(prevote.validatorIndex)) {
|
|
142
|
+
throw new Error("Prevote already exists.");
|
|
143
|
+
}
|
|
144
|
+
__classPrivateFieldGet(this, _RoundState_prevotes, "f").set(prevote.validatorIndex, prevote);
|
|
145
|
+
__classPrivateFieldGet(this, _RoundState_validatorsSignedPrevote, "f")[prevote.validatorIndex] = true;
|
|
146
|
+
__classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_increasePrevoteCount).call(this, prevote.blockId);
|
|
147
|
+
}
|
|
148
|
+
hasPrecommit(validatorIndex) {
|
|
149
|
+
return __classPrivateFieldGet(this, _RoundState_precommits, "f").has(validatorIndex);
|
|
150
|
+
}
|
|
151
|
+
addPrecommit(precommit) {
|
|
152
|
+
if (__classPrivateFieldGet(this, _RoundState_precommits, "f").has(precommit.validatorIndex)) {
|
|
153
|
+
throw new Error("Precommit already exists.");
|
|
154
|
+
}
|
|
155
|
+
__classPrivateFieldGet(this, _RoundState_precommits, "f").set(precommit.validatorIndex, precommit);
|
|
156
|
+
__classPrivateFieldGet(this, _RoundState_validatorsSignedPrecommit, "f")[precommit.validatorIndex] = true;
|
|
157
|
+
__classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_increasePrecommitCount).call(this, precommit.blockId);
|
|
158
|
+
}
|
|
159
|
+
hasMajorityPrevotes() {
|
|
160
|
+
if (!__classPrivateFieldGet(this, _RoundState_proposal, "f")) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
return __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_isMajority).call(this, __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_getPrevoteCount).call(this, __classPrivateFieldGet(this, _RoundState_proposal, "f").block.block.data.id));
|
|
164
|
+
}
|
|
165
|
+
hasMajorityPrevotesAny() {
|
|
166
|
+
return __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_isMajority).call(this, __classPrivateFieldGet(this, _RoundState_prevotes, "f").size);
|
|
167
|
+
}
|
|
168
|
+
hasMajorityPrevotesNull() {
|
|
169
|
+
return __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_isMajority).call(this, __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_getPrevoteCount).call(this));
|
|
170
|
+
}
|
|
171
|
+
hasMajorityPrecommits() {
|
|
172
|
+
if (!__classPrivateFieldGet(this, _RoundState_proposal, "f")) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
return __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_isMajority).call(this, __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_getPrecommitCount).call(this, __classPrivateFieldGet(this, _RoundState_proposal, "f").block.block.data.id));
|
|
176
|
+
}
|
|
177
|
+
hasMajorityPrecommitsAny() {
|
|
178
|
+
return __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_isMajority).call(this, __classPrivateFieldGet(this, _RoundState_precommits, "f").size);
|
|
179
|
+
}
|
|
180
|
+
hasMinorityPrevotesOrPrecommits() {
|
|
181
|
+
return __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_hasMinorityPrevotes).call(this) || __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_hasMinorityPrecommits).call(this);
|
|
182
|
+
}
|
|
183
|
+
getPrevote(validatorIndex) {
|
|
184
|
+
return __classPrivateFieldGet(this, _RoundState_prevotes, "f").get(validatorIndex);
|
|
185
|
+
}
|
|
186
|
+
getPrevotes() {
|
|
187
|
+
return [...__classPrivateFieldGet(this, _RoundState_prevotes, "f").values()];
|
|
188
|
+
}
|
|
189
|
+
getPrecommit(validatorIndex) {
|
|
190
|
+
return __classPrivateFieldGet(this, _RoundState_precommits, "f").get(validatorIndex);
|
|
191
|
+
}
|
|
192
|
+
getPrecommits() {
|
|
193
|
+
return [...__classPrivateFieldGet(this, _RoundState_precommits, "f").values()];
|
|
194
|
+
}
|
|
195
|
+
getValidatorsSignedPrevote() {
|
|
196
|
+
return __classPrivateFieldGet(this, _RoundState_validatorsSignedPrevote, "f");
|
|
197
|
+
}
|
|
198
|
+
getValidatorsSignedPrecommit() {
|
|
199
|
+
return __classPrivateFieldGet(this, _RoundState_validatorsSignedPrecommit, "f");
|
|
200
|
+
}
|
|
201
|
+
async aggregatePrevotes() {
|
|
202
|
+
const { activeValidators } = this.configuration.getMilestone(__classPrivateFieldGet(this, _RoundState_height, "f"));
|
|
203
|
+
return this.aggregator.aggregate(__classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_getSignatures).call(this, __classPrivateFieldGet(this, _RoundState_prevotes, "f")), activeValidators);
|
|
204
|
+
}
|
|
205
|
+
async aggregatePrecommits() {
|
|
206
|
+
const { activeValidators } = this.configuration.getMilestone(__classPrivateFieldGet(this, _RoundState_height, "f"));
|
|
207
|
+
return this.aggregator.aggregate(__classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_getSignatures).call(this, __classPrivateFieldGet(this, _RoundState_precommits, "f")), activeValidators);
|
|
208
|
+
}
|
|
209
|
+
logPrevotes() {
|
|
210
|
+
for (const key of __classPrivateFieldGet(this, _RoundState_prevotesCount, "f").keys()) {
|
|
211
|
+
const voters = [...__classPrivateFieldGet(this, _RoundState_prevotes, "f").values()]
|
|
212
|
+
.filter((prevote) => prevote.blockId === key)
|
|
213
|
+
.map((prevote) => this.validatorSet.getValidator(prevote.validatorIndex).getWalletPublicKey());
|
|
214
|
+
this.logger.debug(`Block ${key ?? "null"} prevoted by: ${voters.join(", ")}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
logPrecommits() {
|
|
218
|
+
for (const key of __classPrivateFieldGet(this, _RoundState_precommitsCount, "f").keys()) {
|
|
219
|
+
const voters = [...__classPrivateFieldGet(this, _RoundState_precommits, "f").values()]
|
|
220
|
+
.filter((precommit) => precommit.blockId === key)
|
|
221
|
+
.map((precommit) => this.validatorSet.getValidator(precommit.validatorIndex).getWalletPublicKey());
|
|
222
|
+
this.logger.debug(`Block ${key ?? "null"} precommitted by: ${voters.join(", ")}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
exports.RoundState = RoundState;
|
|
227
|
+
_RoundState_height = new WeakMap();
|
|
228
|
+
_RoundState_round = new WeakMap();
|
|
229
|
+
_RoundState_proposal = new WeakMap();
|
|
230
|
+
_RoundState_processorResult = new WeakMap();
|
|
231
|
+
_RoundState_prevotes = new WeakMap();
|
|
232
|
+
_RoundState_prevotesCount = new WeakMap();
|
|
233
|
+
_RoundState_precommits = new WeakMap();
|
|
234
|
+
_RoundState_precommitsCount = new WeakMap();
|
|
235
|
+
_RoundState_validators = new WeakMap();
|
|
236
|
+
_RoundState_validatorsSignedPrevote = new WeakMap();
|
|
237
|
+
_RoundState_validatorsSignedPrecommit = new WeakMap();
|
|
238
|
+
_RoundState_proposer = new WeakMap();
|
|
239
|
+
_RoundState_commit = new WeakMap();
|
|
240
|
+
_RoundState_store = new WeakMap();
|
|
241
|
+
_RoundState_instances = new WeakSet();
|
|
242
|
+
_RoundState_hasMinorityPrevotes = function _RoundState_hasMinorityPrevotes() {
|
|
243
|
+
return __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_isMinority).call(this, __classPrivateFieldGet(this, _RoundState_prevotes, "f").size);
|
|
244
|
+
};
|
|
245
|
+
_RoundState_hasMinorityPrecommits = function _RoundState_hasMinorityPrecommits() {
|
|
246
|
+
return __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_isMinority).call(this, __classPrivateFieldGet(this, _RoundState_precommits, "f").size);
|
|
247
|
+
};
|
|
248
|
+
_RoundState_isMajority = function _RoundState_isMajority(size) {
|
|
249
|
+
const { activeValidators } = this.configuration.getMilestone(__classPrivateFieldGet(this, _RoundState_height, "f"));
|
|
250
|
+
return kernel_1.Utils.isMajority(size, activeValidators);
|
|
251
|
+
};
|
|
252
|
+
_RoundState_isMinority = function _RoundState_isMinority(size) {
|
|
253
|
+
const { activeValidators } = this.configuration.getMilestone(__classPrivateFieldGet(this, _RoundState_height, "f"));
|
|
254
|
+
return kernel_1.Utils.isMinority(size, activeValidators);
|
|
255
|
+
};
|
|
256
|
+
_RoundState_increasePrevoteCount = function _RoundState_increasePrevoteCount(blockId) {
|
|
257
|
+
__classPrivateFieldGet(this, _RoundState_prevotesCount, "f").set(blockId, __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_getPrevoteCount).call(this, blockId) + 1);
|
|
258
|
+
};
|
|
259
|
+
_RoundState_getPrevoteCount = function _RoundState_getPrevoteCount(blockId) {
|
|
260
|
+
return __classPrivateFieldGet(this, _RoundState_prevotesCount, "f").get(blockId) ?? 0;
|
|
261
|
+
};
|
|
262
|
+
_RoundState_increasePrecommitCount = function _RoundState_increasePrecommitCount(blockId) {
|
|
263
|
+
__classPrivateFieldGet(this, _RoundState_precommitsCount, "f").set(blockId, __classPrivateFieldGet(this, _RoundState_instances, "m", _RoundState_getPrecommitCount).call(this, blockId) + 1);
|
|
264
|
+
};
|
|
265
|
+
_RoundState_getPrecommitCount = function _RoundState_getPrecommitCount(blockId) {
|
|
266
|
+
return __classPrivateFieldGet(this, _RoundState_precommitsCount, "f").get(blockId) ?? 0;
|
|
267
|
+
};
|
|
268
|
+
_RoundState_getSignatures = function _RoundState_getSignatures(s) {
|
|
269
|
+
kernel_1.Utils.assert.defined(__classPrivateFieldGet(this, _RoundState_proposal, "f"));
|
|
270
|
+
const filtered = new Map();
|
|
271
|
+
for (const [key, value] of s) {
|
|
272
|
+
if (value.blockId === __classPrivateFieldGet(this, _RoundState_proposal, "f").block.block.header.id) {
|
|
273
|
+
filtered.set(key, value);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return filtered;
|
|
277
|
+
};
|
|
278
|
+
__decorate([
|
|
279
|
+
(0, container_1.inject)(contracts_1.Identifiers.Consensus.Aggregator),
|
|
280
|
+
__metadata("design:type", Object)
|
|
281
|
+
], RoundState.prototype, "aggregator", void 0);
|
|
282
|
+
__decorate([
|
|
283
|
+
(0, container_1.inject)(contracts_1.Identifiers.Cryptography.Configuration),
|
|
284
|
+
__metadata("design:type", Object)
|
|
285
|
+
], RoundState.prototype, "configuration", void 0);
|
|
286
|
+
__decorate([
|
|
287
|
+
(0, container_1.inject)(contracts_1.Identifiers.State.Service),
|
|
288
|
+
__metadata("design:type", Object)
|
|
289
|
+
], RoundState.prototype, "stateService", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
(0, container_1.inject)(contracts_1.Identifiers.ValidatorSet.Service),
|
|
292
|
+
__metadata("design:type", Object)
|
|
293
|
+
], RoundState.prototype, "validatorSet", void 0);
|
|
294
|
+
__decorate([
|
|
295
|
+
(0, container_1.inject)(contracts_1.Identifiers.Proposer.Selector),
|
|
296
|
+
__metadata("design:type", Object)
|
|
297
|
+
], RoundState.prototype, "proposerSelector", void 0);
|
|
298
|
+
__decorate([
|
|
299
|
+
(0, container_1.inject)(contracts_1.Identifiers.Cryptography.Commit.Serializer),
|
|
300
|
+
__metadata("design:type", Object)
|
|
301
|
+
], RoundState.prototype, "commitSerializer", void 0);
|
|
302
|
+
__decorate([
|
|
303
|
+
(0, container_1.inject)(contracts_1.Identifiers.Services.Log.Service),
|
|
304
|
+
__metadata("design:type", Object)
|
|
305
|
+
], RoundState.prototype, "logger", void 0);
|
|
306
|
+
__decorate([
|
|
307
|
+
(0, container_1.postConstruct)(),
|
|
308
|
+
__metadata("design:type", Function),
|
|
309
|
+
__metadata("design:paramtypes", []),
|
|
310
|
+
__metadata("design:returntype", void 0)
|
|
311
|
+
], RoundState.prototype, "initialize", null);
|
|
312
|
+
exports.RoundState = RoundState = __decorate([
|
|
313
|
+
(0, container_1.injectable)()
|
|
314
|
+
], RoundState);
|
|
315
|
+
//# sourceMappingURL=round-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"round-state.js","sourceRoot":"","sources":["../source/round-state.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAwE;AACxE,mDAA6D;AAC7D,6CAAyC;AAGlC,IAAM,UAAU,GAAhB,MAAM,UAAU;IAAhB;;QAsBN,6BAAU,CAAC,EAAC;QACZ,4BAAS,CAAC,E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AC;;oDAC0B;AAG/C;IADhB,IAAA,kBAAM,EAAC,uBAAW,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC;;oDACmB;AAGrD;IADhB,IAAA,kBAAM,EAAC,uBAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;;0CACS;AAmB3C;IADN,IAAA,yBAAa,GAAE;;;;4CAGf;qBAzCW,UAAU;IADtB,IAAA,sBAAU,GAAE;GACA,UAAU,CAmUtB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Contracts } from "@mainsail/contracts";
|
|
2
|
+
export declare class Scheduler implements Contracts.Consensus.Scheduler {
|
|
3
|
+
#private;
|
|
4
|
+
private readonly app;
|
|
5
|
+
private readonly stateService;
|
|
6
|
+
private readonly cryptoConfiguration;
|
|
7
|
+
scheduleTimeoutStartRound(): void;
|
|
8
|
+
scheduleTimeoutPropose(height: number, round: number): void;
|
|
9
|
+
scheduleTimeoutPrevote(height: number, round: number): void;
|
|
10
|
+
scheduleTimeoutPrecommit(height: number, round: number): void;
|
|
11
|
+
clear(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../source/scheduler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAG7D,qBACa,SAAU,YAAW,SAAS,CAAC,SAAS,CAAC,SAAS;;IAE9D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgC;IAGpD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA2B;IAGxD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;IAO/D,yBAAyB,IAAI,IAAI;IAkBjC,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAW3D,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAW3D,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAW7D,KAAK,IAAI,IAAI;CAgCpB"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
14
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
|
+
};
|
|
16
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
17
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
20
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
var _Scheduler_instances, _Scheduler_timeoutStartRound, _Scheduler_timeoutPropose, _Scheduler_timeoutPrevote, _Scheduler_timeoutPrecommit, _Scheduler_getTimeout, _Scheduler_getConsensus;
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.Scheduler = void 0;
|
|
28
|
+
const container_1 = require("@mainsail/container");
|
|
29
|
+
const contracts_1 = require("@mainsail/contracts");
|
|
30
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
31
|
+
let Scheduler = class Scheduler {
|
|
32
|
+
constructor() {
|
|
33
|
+
_Scheduler_instances.add(this);
|
|
34
|
+
_Scheduler_timeoutStartRound.set(this, void 0);
|
|
35
|
+
_Scheduler_timeoutPropose.set(this, void 0);
|
|
36
|
+
_Scheduler_timeoutPrevote.set(this, void 0);
|
|
37
|
+
_Scheduler_timeoutPrecommit.set(this, void 0);
|
|
38
|
+
}
|
|
39
|
+
scheduleTimeoutStartRound() {
|
|
40
|
+
if (__classPrivateFieldGet(this, _Scheduler_timeoutStartRound, "f")) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const timeout = Math.max(0, this.stateService.getStore().getLastBlock().data.timestamp -
|
|
44
|
+
(0, dayjs_1.default)().valueOf() +
|
|
45
|
+
this.cryptoConfiguration.getMilestone().blockTime);
|
|
46
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutStartRound, setTimeout(async () => {
|
|
47
|
+
await __classPrivateFieldGet(this, _Scheduler_instances, "m", _Scheduler_getConsensus).call(this).onTimeoutStartRound();
|
|
48
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutStartRound, undefined, "f");
|
|
49
|
+
}, timeout), "f");
|
|
50
|
+
}
|
|
51
|
+
scheduleTimeoutPropose(height, round) {
|
|
52
|
+
if (__classPrivateFieldGet(this, _Scheduler_timeoutPropose, "f")) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutPropose, setTimeout(async () => {
|
|
56
|
+
await __classPrivateFieldGet(this, _Scheduler_instances, "m", _Scheduler_getConsensus).call(this).onTimeoutPropose(height, round);
|
|
57
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutPropose, undefined, "f");
|
|
58
|
+
}, __classPrivateFieldGet(this, _Scheduler_instances, "m", _Scheduler_getTimeout).call(this, round)), "f");
|
|
59
|
+
}
|
|
60
|
+
scheduleTimeoutPrevote(height, round) {
|
|
61
|
+
if (__classPrivateFieldGet(this, _Scheduler_timeoutPrevote, "f")) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutPrevote, setTimeout(async () => {
|
|
65
|
+
await __classPrivateFieldGet(this, _Scheduler_instances, "m", _Scheduler_getConsensus).call(this).onTimeoutPrevote(height, round);
|
|
66
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutPrevote, undefined, "f");
|
|
67
|
+
}, __classPrivateFieldGet(this, _Scheduler_instances, "m", _Scheduler_getTimeout).call(this, round)), "f");
|
|
68
|
+
}
|
|
69
|
+
scheduleTimeoutPrecommit(height, round) {
|
|
70
|
+
if (__classPrivateFieldGet(this, _Scheduler_timeoutPrecommit, "f")) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutPrecommit, setTimeout(async () => {
|
|
74
|
+
await __classPrivateFieldGet(this, _Scheduler_instances, "m", _Scheduler_getConsensus).call(this).onTimeoutPrecommit(height, round);
|
|
75
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutPrecommit, undefined, "f");
|
|
76
|
+
}, __classPrivateFieldGet(this, _Scheduler_instances, "m", _Scheduler_getTimeout).call(this, round)), "f");
|
|
77
|
+
}
|
|
78
|
+
clear() {
|
|
79
|
+
if (__classPrivateFieldGet(this, _Scheduler_timeoutStartRound, "f")) {
|
|
80
|
+
clearTimeout(__classPrivateFieldGet(this, _Scheduler_timeoutStartRound, "f"));
|
|
81
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutStartRound, undefined, "f");
|
|
82
|
+
}
|
|
83
|
+
if (__classPrivateFieldGet(this, _Scheduler_timeoutPropose, "f")) {
|
|
84
|
+
clearTimeout(__classPrivateFieldGet(this, _Scheduler_timeoutPropose, "f"));
|
|
85
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutPropose, undefined, "f");
|
|
86
|
+
}
|
|
87
|
+
if (__classPrivateFieldGet(this, _Scheduler_timeoutPrevote, "f")) {
|
|
88
|
+
clearTimeout(__classPrivateFieldGet(this, _Scheduler_timeoutPrevote, "f"));
|
|
89
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutPrevote, undefined, "f");
|
|
90
|
+
}
|
|
91
|
+
if (__classPrivateFieldGet(this, _Scheduler_timeoutPrecommit, "f")) {
|
|
92
|
+
clearTimeout(__classPrivateFieldGet(this, _Scheduler_timeoutPrecommit, "f"));
|
|
93
|
+
__classPrivateFieldSet(this, _Scheduler_timeoutPrecommit, undefined, "f");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
exports.Scheduler = Scheduler;
|
|
98
|
+
_Scheduler_timeoutStartRound = new WeakMap();
|
|
99
|
+
_Scheduler_timeoutPropose = new WeakMap();
|
|
100
|
+
_Scheduler_timeoutPrevote = new WeakMap();
|
|
101
|
+
_Scheduler_timeoutPrecommit = new WeakMap();
|
|
102
|
+
_Scheduler_instances = new WeakSet();
|
|
103
|
+
_Scheduler_getTimeout = function _Scheduler_getTimeout(round) {
|
|
104
|
+
return (this.cryptoConfiguration.getMilestone().stageTimeout +
|
|
105
|
+
round * this.cryptoConfiguration.getMilestone().stageTimeoutIncrease);
|
|
106
|
+
};
|
|
107
|
+
_Scheduler_getConsensus = function _Scheduler_getConsensus() {
|
|
108
|
+
return this.app.get(contracts_1.Identifiers.Consensus.Service);
|
|
109
|
+
};
|
|
110
|
+
__decorate([
|
|
111
|
+
(0, container_1.inject)(contracts_1.Identifiers.Application.Instance),
|
|
112
|
+
__metadata("design:type", Object)
|
|
113
|
+
], Scheduler.prototype, "app", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, container_1.inject)(contracts_1.Identifiers.State.Service),
|
|
116
|
+
__metadata("design:type", Object)
|
|
117
|
+
], Scheduler.prototype, "stateService", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, container_1.inject)(contracts_1.Identifiers.Cryptography.Configuration),
|
|
120
|
+
__metadata("design:type", Object)
|
|
121
|
+
], Scheduler.prototype, "cryptoConfiguration", void 0);
|
|
122
|
+
exports.Scheduler = Scheduler = __decorate([
|
|
123
|
+
(0, container_1.injectable)()
|
|
124
|
+
], Scheduler);
|
|
125
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../source/scheduler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAyD;AACzD,mDAA6D;AAC7D,kDAA0B;AAGnB,IAAM,SAAS,GAAf,MAAM,SAAS;IAAf;;QAUN,+CAAoC;QACpC,4CAAiC;QACjC,4CAAiC;QACjC,8CAAmC;IAqFpC,CAAC;IAnFO,yBAAyB;QAC/B,IAAI,uBAAA,IAAI,oCAAmB,EAAE,CAAC;YAC7B,OAAO;QACR,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CACvB,CAAC,EACD,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,SAAS;YACzD,IAAA,eAAK,GAAE,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,mBAAmB,CAAC,YAAY,EAA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;AAC1F,CAAC;AA/FgB;IADhB,IAAA,kBAAM,EAAC,uBAAW,CAAC,WAAW,CAAC,QAAQ,CAAC;;sCACW;AAGnC;IADhB,IAAA,kBAAM,EAAC,uBAAW,CAAC,KAAK,CAAC,OAAO,CAAC;;+CACsB;AAGvC;IADhB,IAAA,kBAAM,EAAC,uBAAW,CAAC,YAAY,CAAC,aAAa,CAAC;;sDACuB;oBAR1D,SAAS;IADrB,IAAA,sBAAU,GAAE;GACA,SAAS,CAkGrB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Contracts } from "@mainsail/contracts";
|
|
2
|
+
export declare class Storage implements Contracts.Consensus.ConsensusStorage {
|
|
3
|
+
private readonly proposalStorage;
|
|
4
|
+
private readonly prevoteStorage;
|
|
5
|
+
private readonly precommitStorage;
|
|
6
|
+
private readonly stateStorage;
|
|
7
|
+
private readonly validatorSet;
|
|
8
|
+
private readonly messageFactory;
|
|
9
|
+
getState(): Promise<Contracts.Consensus.ConsensusStateData | undefined>;
|
|
10
|
+
saveState(state: Contracts.Consensus.ConsensusState): Promise<void>;
|
|
11
|
+
saveProposals(proposals: Contracts.Crypto.Proposal[]): Promise<void>;
|
|
12
|
+
savePrevotes(prevotes: Contracts.Crypto.Prevote[]): Promise<void>;
|
|
13
|
+
savePrecommits(precommits: Contracts.Crypto.Precommit[]): Promise<void>;
|
|
14
|
+
getProposals(): Promise<Contracts.Crypto.Proposal[]>;
|
|
15
|
+
getPrevotes(): Promise<Contracts.Crypto.Prevote[]>;
|
|
16
|
+
getPrecommits(): Promise<Contracts.Crypto.Precommit[]>;
|
|
17
|
+
clear(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../source/storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAG7D,qBACa,OA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