Skip to content

Commit

Permalink
comments fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmenendez committed Sep 4, 2023
1 parent 5785455 commit 630bb14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions api/censuses.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (capi *census3API) launchCensusCreation(msg *api.APIdata, ctx *httprouter.H
}
// create and publish census merkle tree in background
queueID := capi.queue.Enqueue()
go func(req *CreateCensusResquest) {
go func() {
censusID, err := capi.createAndPublishCensus(req, queueID)
if err != nil && !errors.Is(ErrCensusAlreadyExists, err) {
if ok := capi.queue.Update(queueID, true, nil, err); !ok {
Expand All @@ -117,7 +117,7 @@ func (capi *census3API) launchCensusCreation(msg *api.APIdata, ctx *httprouter.H
if ok := capi.queue.Update(queueID, true, queueData, nil); !ok {
log.Errorf("error updating census queue process with error")
}
}(req)
}()
// encoding the result and response it
res, err := json.Marshal(CreateCensusResponse{
QueueID: queueID,
Expand Down Expand Up @@ -274,7 +274,7 @@ func (capi *census3API) getEnqueueCensus(msg *api.APIdata, ctx *httprouter.HTTPC
return ErrNotFoundCensus.Withf("the ID %s does not exist in the queue", queueID)
}
// init queue item response
queueItem := QueueItemResponse{
queueCensus := CensusQueueResponse{
Done: done,
Error: err,
}
Expand Down Expand Up @@ -311,7 +311,7 @@ func (capi *census3API) getEnqueueCensus(msg *api.APIdata, ctx *httprouter.HTTPC
censusWeight = []byte(currentCensus.Weight.String)
}
// encode census
queueItem.Census = &GetCensusResponse{
queueCensus.Census = &GetCensusResponse{
CensusID: uint64(currentCensus.ID),
StrategyID: uint64(currentCensus.StrategyID),
MerkleRoot: common.Bytes2Hex(currentCensus.MerkleRoot),
Expand All @@ -325,7 +325,7 @@ func (capi *census3API) getEnqueueCensus(msg *api.APIdata, ctx *httprouter.HTTPC
capi.queue.Dequeue(queueID)
}
// encode item response and send it
res, err := json.Marshal(queueItem)
res, err := json.Marshal(queueCensus)
if err != nil {
log.Errorw(ErrEncodeQueueItem, err.Error())
return ErrEncodeQueueItem
Expand Down
4 changes: 2 additions & 2 deletions api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ type GetStrategyResponse struct {
Predicate string `json:"strategy"`
}

type QueueItemResponse struct {
type CensusQueueResponse struct {
Done bool `json:"done"`
Error error `json:"error"`
Census *GetCensusResponse `json:"census,omitempty"`
Census *GetCensusResponse `json:"census"`
}

0 comments on commit 630bb14

Please sign in to comment.