[bug] Failed to update tips
This commit is contained in:
parent
19da967605
commit
c422881cd1
@ -1406,8 +1406,17 @@ export default class Services {
|
|||||||
let new_states = [];
|
let new_states = [];
|
||||||
let roles = [];
|
let roles = [];
|
||||||
for (const state of process.states) {
|
for (const state of process.states) {
|
||||||
if (!state.state_id || state.state_id === EMPTY32BYTES) { continue; }
|
if (!state || !state.state_id) { continue; } // shouldn't happen
|
||||||
if (!this.lookForStateId(existing, state.state_id)) {
|
if (state.state_id === EMPTY32BYTES) {
|
||||||
|
// We check that the tip is the same we have, if not we update
|
||||||
|
const existingTip = existing.states[existing.states.length - 1].commited_in;
|
||||||
|
if (existingTip !== state.commited_in) {
|
||||||
|
console.log('Found new tip for process', processId);
|
||||||
|
// We update the process
|
||||||
|
new_states.push(state.state_id);
|
||||||
|
roles.push(state.roles);
|
||||||
|
}
|
||||||
|
} else if (!this.lookForStateId(existing, state.state_id)) {
|
||||||
if (this.rolesContainsUs(state.roles)) {
|
if (this.rolesContainsUs(state.roles)) {
|
||||||
new_states.push(state.state_id);
|
new_states.push(state.state_id);
|
||||||
roles.push(state.roles);
|
roles.push(state.roles);
|
||||||
@ -1417,6 +1426,12 @@ export default class Services {
|
|||||||
|
|
||||||
if (new_states.length != 0) {
|
if (new_states.length != 0) {
|
||||||
// We request the new states
|
// We request the new states
|
||||||
|
// filter out the empty state, if any
|
||||||
|
// empty state will always be last, so that's easy
|
||||||
|
if (new_states.findLast(state => state === EMPTY32BYTES)) {
|
||||||
|
new_states.pop();
|
||||||
|
roles.pop();
|
||||||
|
}
|
||||||
await this.requestDataFromPeers(processId, new_states, roles);
|
await this.requestDataFromPeers(processId, new_states, roles);
|
||||||
toSave[processId] = process;
|
toSave[processId] = process;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user