Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 16 additions & 3 deletions pkg/registrar_gateway/registrar_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ func (r *registrarGateway) getTwin(url string, twinID uint64) (result types.Acco
defer resp.Body.Close()

err = json.NewDecoder(resp.Body).Decode(&result)

return result, err
}

Expand Down Expand Up @@ -422,6 +423,9 @@ func (r *registrarGateway) getTwinByPubKey(url string, pk []byte) (result uint64
var account types.Account
err = json.NewDecoder(resp.Body).Decode(&account)

if r.twinID == 0 {
r.twinID = account.TwinID
}
return account.TwinID, err
}

Expand Down Expand Up @@ -486,10 +490,13 @@ func (r *registrarGateway) createNode(url string, node types.UpdateNodeRequest)

defer resp.Body.Close()

err = json.NewDecoder(resp.Body).Decode(&nodeID)
result := struct {
NodeID uint64 `json:"node_id"`
}{}
err = json.NewDecoder(resp.Body).Decode(&result)

r.nodeID = nodeID
return nodeID, err
r.nodeID = result.NodeID
return result.NodeID, err
}

func (r *registrarGateway) getFarm(url string) (farm types.Farm, err error) {
Expand Down Expand Up @@ -538,6 +545,9 @@ func (r *registrarGateway) getNode(url string) (node types.Node, err error) {
return
}

if r.nodeID == 0 {
r.nodeID = node.NodeID
}
return node, err
}

Expand Down Expand Up @@ -580,6 +590,9 @@ func (r *registrarGateway) getNodeByTwinID(url string, twin uint64) (result uint
return result, ErrorRecordNotFound
}

if r.nodeID == 0 {
r.nodeID = nodes[0].NodeID
}
return nodes[0].NodeID, nil
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ type Farm struct {
FarmName string `json:"farm_name"`
TwinID uint64 `json:"twin_id"` // Farmer account reference
Dedicated bool `json:"dedicated"`
CreatedAt time.Time
UpdatedAt time.Time
}

type Node struct {
Expand Down
Loading