Skip to content

Commit

Permalink
testing on dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jdutchak committed Jul 19, 2024
1 parent bd0b360 commit 34b0ed5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions pkg/api/handlers_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ func (api *API) GetFromDHT() gin.HandlerFunc {
logrus.WithFields(logrus.Fields{
"key": keyStr,
"error": err,
}).Error("Failed to read data from DHT")
}).Debug("Failed to read data from DHT")
c.JSON(http.StatusInternalServerError, gin.H{
"success": false,
"message": "failed to read data",
"message": "no data",
})
return
}
Expand Down
32 changes: 19 additions & 13 deletions pkg/oracle_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,22 +412,28 @@ func updateBlocks(ctx context.Context, node *OracleNode, block *chain.Block) {
TransactionNonce: int(block.Nonce),
}

exists, _ := node.DHT.GetValue(ctx, "/db/blocks")

var existingBlocks Blocks
if exists != nil {
err := json.Unmarshal(exists, &existingBlocks)
if err != nil {
logrus.Errorf("Error unmarshalling existing block data: %v", err)
}
existingBlocks.BlockData = append(existingBlocks.BlockData, blockData)
} else {
existingBlocks = Blocks{
TransactionHash: blockData.TransactionHash,
BlockData: []BlockData{blockData},
}
existingBlocks.BlockData = append(existingBlocks.BlockData, blockData)
existingBlocks = Blocks{
TransactionHash: blockData.TransactionHash,
BlockData: []BlockData{blockData},
}

// exists, _ := node.DHT.GetValue(ctx, "/db/blocks")
// var existingBlocks Blocks
// if exists != nil {
// err := json.Unmarshal(exists, &existingBlocks)
// if err != nil {
// logrus.Errorf("Error unmarshalling existing block data: %v", err)
// }
// existingBlocks.BlockData = append(existingBlocks.BlockData, blockData)
// } else {
// existingBlocks = Blocks{
// TransactionHash: blockData.TransactionHash,
// BlockData: []BlockData{blockData},
// }
// }

jsonData, err := json.Marshal(existingBlocks)
if err != nil {
logrus.Error(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/workers/workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func MonitorWorkers(ctx context.Context, node *masa.OracleNode) {
return
}
if node.WorkerTracker == nil || node.WorkerTracker.WorkerStatusCh == nil {
logrus.Error("MonitorWorkers: WorkerTracker or WorkerStatusCh is nil")
logrus.Debug("MonitorWorkers: WorkerTracker or WorkerStatusCh is nil")
return
}

Expand Down Expand Up @@ -528,5 +528,5 @@ func processWork(data *pubsub2.Message, work string, startTime *time.Time, node
}
// @todo

updateRecords(node, workEvent)
// updateRecords(node, workEvent)
}

0 comments on commit 34b0ed5

Please sign in to comment.