fiz: correções da pool

This commit is contained in:
Júnior
2025-06-17 18:26:14 -03:00
parent 682027d517
commit 9259f36e9c
31 changed files with 373 additions and 269 deletions

View File

@ -5,8 +5,9 @@ import (
"net/http"
"strconv"
"github.com/gorilla/mux"
"dejo_node/internal/dao"
"github.com/gorilla/mux"
)
type CreateProposalRequest struct {
@ -30,7 +31,7 @@ func (h *Handler) CreateProposal(w http.ResponseWriter, r *http.Request) {
}
p := DaoStore.Create(req.Title, req.Content, req.Creator, dao.ProposalType(req.Type), req.Duration)
_ = DaoStore.SaveToDisk("data/proposals.db")
WriteJSON(w, p)
WriteJSON(w, http.StatusOK, p)
}
func (h *Handler) VoteProposal(w http.ResponseWriter, r *http.Request) {
@ -53,7 +54,7 @@ func (h *Handler) VoteProposal(w http.ResponseWriter, r *http.Request) {
_ = p.Vote(req.Address, req.Approve)
p.CheckAndClose(h.snapshotStakes())
_ = DaoStore.SaveToDisk("data/proposals.db")
WriteJSON(w, p)
WriteJSON(w, http.StatusOK, p)
}
func (h *Handler) GetProposal(w http.ResponseWriter, r *http.Request) {
@ -68,11 +69,11 @@ func (h *Handler) GetProposal(w http.ResponseWriter, r *http.Request) {
WriteError(w, http.StatusNotFound, "Proposta não encontrada")
return
}
WriteJSON(w, p)
WriteJSON(w, http.StatusOK, p)
}
func (h *Handler) ListProposals(w http.ResponseWriter, r *http.Request) {
WriteJSON(w, DaoStore.List())
WriteJSON(w, http.StatusOK, DaoStore.List())
}
func (h *Handler) snapshotStakes() map[string]uint64 {
@ -81,4 +82,4 @@ func (h *Handler) snapshotStakes() map[string]uint64 {
snapshot[addr] = entry.Amount
}
return snapshot
}
}