@@ -390,6 +390,7 @@ func (r *registrarGateway) getTwin(url string, twinID uint64) (result types.Acco
390
390
defer resp .Body .Close ()
391
391
392
392
err = json .NewDecoder (resp .Body ).Decode (& result )
393
+
393
394
return result , err
394
395
}
395
396
@@ -427,6 +428,9 @@ func (r *registrarGateway) getTwinByPubKey(url string, pk []byte) (result uint64
427
428
var account types.Account
428
429
err = json .NewDecoder (resp .Body ).Decode (& account )
429
430
431
+ if r .twinID == 0 {
432
+ r .twinID = account .TwinID
433
+ }
430
434
return account .TwinID , err
431
435
}
432
436
@@ -491,10 +495,13 @@ func (r *registrarGateway) createNode(url string, node types.UpdateNodeRequest)
491
495
492
496
defer resp .Body .Close ()
493
497
494
- err = json .NewDecoder (resp .Body ).Decode (& nodeID )
498
+ result := struct {
499
+ NodeID uint64 `json:"node_id"`
500
+ }{}
501
+ err = json .NewDecoder (resp .Body ).Decode (& result )
495
502
496
- r .nodeID = nodeID
497
- return nodeID , err
503
+ r .nodeID = result . NodeID
504
+ return result . NodeID , err
498
505
}
499
506
500
507
func (r * registrarGateway ) getFarm (url string ) (farm types.Farm , err error ) {
@@ -543,6 +550,9 @@ func (r *registrarGateway) getNode(url string) (node types.Node, err error) {
543
550
return
544
551
}
545
552
553
+ if r .nodeID == 0 {
554
+ r .nodeID = node .NodeID
555
+ }
546
556
return node , err
547
557
}
548
558
@@ -585,6 +595,9 @@ func (r *registrarGateway) getNodeByTwinID(url string, twin uint64) (result uint
585
595
return result , ErrorRecordNotFound
586
596
}
587
597
598
+ if r .nodeID == 0 {
599
+ r .nodeID = nodes [0 ].NodeID
600
+ }
588
601
return nodes [0 ].NodeID , nil
589
602
}
590
603
0 commit comments