Skip to content

Commit

Permalink
Fix bug - update groupInfo as well when there're no valid members
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhaixian1984 committed Jun 21, 2024
1 parent 966254f commit 2a9ac15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/tasks/group-info-updater-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ async function handleUpdate(context: AppContext, logger: Logger) {

if (validMembers.length > 0) {
logger.info(`load ${validMembers.length} valid group members`);
validMembers.sort();
const nodeIndex = validMembers.indexOf(api.getChainAccount());
context.groupInfo = {
groupAccount: groupOwner,
totalMembers: validMembers.length,
nodeIndex,
};
} else {
logger.warn(`load ${validMembers.length} valid group members`);
}

validMembers.sort();
const nodeIndex = validMembers.indexOf(api.getChainAccount());
context.groupInfo = {
groupAccount: groupOwner,
totalMembers: validMembers.length,
nodeIndex,
};
} catch (e) {
logger.error('failed updating group info: %s', formatError(e));
context.groupInfo = null;
Expand Down
5 changes: 1 addition & 4 deletions src/tasks/pull-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ export async function filterFile(
const groupInfo = context.groupInfo;
try {
const bn = cidToBigNumber(record.cid);
if (
groupInfo.totalMembers > 0 &&
!bn.mod(groupInfo.totalMembers).eq(groupInfo.nodeIndex)
) {
if (groupInfo.totalMembers == 0 || !bn.mod(groupInfo.totalMembers).eq(groupInfo.nodeIndex) ) {
return 'nodeSkipped';
}
} catch (ex) {
Expand Down

0 comments on commit 2a9ac15

Please sign in to comment.