From 8f74f8f7f968e7716b7f797bb6c04400593f1a65 Mon Sep 17 00:00:00 2001 From: David Rodriguez Garcia <70919589+daveroga@users.noreply.github.com> Date: Mon, 22 Nov 2021 15:25:04 +0100 Subject: [PATCH] fix: get proposers collection and register proposer (#314) --- nightfall-deployer/contracts/Proposers.sol | 7 ++++++- nightfall-optimist/src/routes/proposer.mjs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nightfall-deployer/contracts/Proposers.sol b/nightfall-deployer/contracts/Proposers.sol index 409e5eb2a..6ebf50ad1 100644 --- a/nightfall-deployer/contracts/Proposers.sol +++ b/nightfall-deployer/contracts/Proposers.sol @@ -53,9 +53,14 @@ contract Proposers is Stateful, Structures, Config { // updated the pulled state proposersPrevious.nextAddress = proposer.thisAddress; // X: (u,v,B) proposersCurrent.previousAddress = proposer.thisAddress; // current: (B,A,z) + if (proposersPrevious.thisAddress == proposersCurrent.thisAddress) { // case register second proposer + proposersCurrent.nextAddress = proposer.thisAddress; // previous and next Address is the second proposer + } currentProposer = proposersCurrent; // ensure sync: currentProposer: (B,A,z) // set global state to new values - state.setProposer(proposersPrevious.thisAddress, proposersPrevious); + if (proposersPrevious.thisAddress != proposersCurrent.thisAddress) { // not case register second proposer + state.setProposer(proposersPrevious.thisAddress, proposersPrevious); + } state.setProposer(proposersCurrent.thisAddress, proposersCurrent); state.setProposer(msg.sender, proposer); } diff --git a/nightfall-optimist/src/routes/proposer.mjs b/nightfall-optimist/src/routes/proposer.mjs index d955afa6b..13a11161e 100644 --- a/nightfall-optimist/src/routes/proposer.mjs +++ b/nightfall-optimist/src/routes/proposer.mjs @@ -60,7 +60,7 @@ router.get('/proposers', async (req, res, next) => { // eslint-disable-next-line no-await-in-loop const proposer = await proposersContractInstance.methods.proposers(thisPtr).call(); proposers.push(proposer); - thisPtr = proposer.thisAddress; + thisPtr = proposer.nextAddress; } while (thisPtr !== currentProposer.thisAddress); logger.debug('returning raw transaction data');