Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Added check for duplicate requests #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions blockchain/agoric.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type chainlinkQuery struct {
Params map[string]interface{} `json:"params"`
}

var lastRequestId = ""

func (sm *agoricManager) ParseResponse(data []byte) ([]subscriber.Event, bool) {
promLastSourcePing.With(prometheus.Labels{"endpoint": sm.endpointName, "jobid": string(sm.filter.JobID)}).SetToCurrentTime()

Expand Down Expand Up @@ -108,15 +110,22 @@ func (sm *agoricManager) ParseResponse(data []byte) ([]subscriber.Event, bool) {
}
requestParams["request_id"] = onQueryData.QueryID
requestParams["payment"] = onQueryData.Fee

//send request only if request id is not like last request
if onQueryData.QueryID != lastRequestId {
lastRequestId = onQueryData.QueryID
event, err := json.Marshal(requestParams)
if err != nil {
logger.Error(err)
return nil, false
}
subEvents = append(subEvents, event)

event, err := json.Marshal(requestParams)
if err != nil {
logger.Error(err)
return nil, false
}
subEvents = append(subEvents, event)

return subEvents, true
return subEvents, true
} else {
logger.Error("Request already submitted for ",onQueryData.QueryID)
return nil, false
}
}

func (sm *agoricManager) GetTestJson() []byte {
Expand Down