Skip to content

Commit

Permalink
Add vote signaling to voting registry contract handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Oct 30, 2023
1 parent 12c5988 commit 3b0a12b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/gridcoin/voting/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,9 @@ void PollRegistry::AddVote(const ContractContext& ctx) EXCLUSIVE_LOCKS_REQUIRED(
*poll_ref->m_ptitle,
poll_ref->Votes().size());

if (fQtActive && !poll_ref->Expired(GetAdjustedTime())) {
uiInterface.NewVoteReceived(ctx.m_tx.GetHash());
}
}
}

Expand All @@ -1068,13 +1071,19 @@ void PollRegistry::AddVote(const ContractContext& ctx) EXCLUSIVE_LOCKS_REQUIRED(
return;
}
poll_ref->LinkVote(ctx.m_tx.GetHash());

if (fQtActive && !poll_ref->Expired(GetAdjustedTime())) {
uiInterface.NewVoteReceived(ctx.m_tx.GetHash());
}
}
}

void PollRegistry::DeletePoll(const ContractContext& ctx) EXCLUSIVE_LOCKS_REQUIRED(cs_main, PollRegistry::cs_poll_registry)
{
const auto payload = ctx->SharePayloadAs<PollPayload>();

int64_t poll_time = payload->m_poll.m_timestamp;

m_polls.erase(ToLower(payload->m_poll.m_title));

m_polls_by_txid.erase(ctx.m_tx.GetHash());
Expand All @@ -1085,6 +1094,10 @@ void PollRegistry::DeletePoll(const ContractContext& ctx) EXCLUSIVE_LOCKS_REQUIR
payload->m_poll.m_title,
m_polls.size());

if (fQtActive) {
uiInterface.NewPollReceived(poll_time);;
}

}

void PollRegistry::DeleteVote(const ContractContext& ctx) EXCLUSIVE_LOCKS_REQUIRED(cs_main, PollRegistry::cs_poll_registry)
Expand All @@ -1100,6 +1113,10 @@ void PollRegistry::DeleteVote(const ContractContext& ctx) EXCLUSIVE_LOCKS_REQUIR
ctx.m_tx.GetHash().GetHex(),
*poll_ref->m_ptitle,
poll_ref->Votes().size());

if (fQtActive && !poll_ref->Expired(GetAdjustedTime())) {
uiInterface.NewVoteReceived(ctx.m_tx.GetHash());
}
}

return;
Expand Down

0 comments on commit 3b0a12b

Please sign in to comment.