Skip to content

Commit

Permalink
Updating it to peer_id
Browse files Browse the repository at this point in the history
  • Loading branch information
p-shubh committed Jun 13, 2024
1 parent c7c05ac commit 1fb1304
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/v1/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func RegisterClient(c *gin.Context) {
// return
// }
var node *models.Node
if err := db.Model(&models.Node{}).Where("id = ?", region_id).First(&node).Error; err != nil {
if err := db.Model(&models.Node{}).Where("peer_id = ?", region_id).First(&node).Error; err != nil {
logwrapper.Errorf("failed to get node: %s", err)
httpo.NewErrorResponse(http.StatusBadRequest, err.Error()).SendD(c)
return
Expand Down
2 changes: 1 addition & 1 deletion api/v1/nodes/testNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func UpdateNode(node *models.Node) error {
// DeleteNode deletes a node record from the database
func DeleteNode(id string) error {
DB := dbconfig.GetDb()
return DB.Delete(&models.Node{}, id).Error
return DB.Delete(&models.Node{}, "where peer_id = ?",id).Error
}

func getRandomString(n int) string {
Expand Down
2 changes: 1 addition & 1 deletion app/p2p-Node/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func SubscribeTopics(ps *pubsub.PubSub, h host.Host, ctx context.Context) {
func CreateOrUpdate(db *gorm.DB, node *models.Node) error {
var model models.Node

result := db.Model(&models.Node{}).Where("id = ?", node.PeerId)
result := db.Model(&models.Node{}).Where("peer_id = ?", node.PeerId)
if result.RowsAffected != 0 {
//exists, update
return db.Model(&model).Updates(node).Error
Expand Down

0 comments on commit 1fb1304

Please sign in to comment.