@@ -385,6 +385,7 @@ func (r *registrarGateway) getTwin(url string, twinID uint64) (result types.Acco
385
385
defer resp .Body .Close ()
386
386
387
387
err = json .NewDecoder (resp .Body ).Decode (& result )
388
+
388
389
return result , err
389
390
}
390
391
@@ -422,6 +423,9 @@ func (r *registrarGateway) getTwinByPubKey(url string, pk []byte) (result uint64
422
423
var account types.Account
423
424
err = json .NewDecoder (resp .Body ).Decode (& account )
424
425
426
+ if r .twinID == 0 {
427
+ r .twinID = account .TwinID
428
+ }
425
429
return account .TwinID , err
426
430
}
427
431
@@ -486,10 +490,13 @@ func (r *registrarGateway) createNode(url string, node types.UpdateNodeRequest)
486
490
487
491
defer resp .Body .Close ()
488
492
489
- err = json .NewDecoder (resp .Body ).Decode (& nodeID )
493
+ result := struct {
494
+ NodeID uint64 `json:"node_id"`
495
+ }{}
496
+ err = json .NewDecoder (resp .Body ).Decode (& result )
490
497
491
- r .nodeID = nodeID
492
- return nodeID , err
498
+ r .nodeID = result . NodeID
499
+ return result . NodeID , err
493
500
}
494
501
495
502
func (r * registrarGateway ) getFarm (url string ) (farm types.Farm , err error ) {
@@ -538,6 +545,9 @@ func (r *registrarGateway) getNode(url string) (node types.Node, err error) {
538
545
return
539
546
}
540
547
548
+ if r .nodeID == 0 {
549
+ r .nodeID = node .NodeID
550
+ }
541
551
return node , err
542
552
}
543
553
@@ -580,6 +590,9 @@ func (r *registrarGateway) getNodeByTwinID(url string, twin uint64) (result uint
580
590
return result , ErrorRecordNotFound
581
591
}
582
592
593
+ if r .nodeID == 0 {
594
+ r .nodeID = nodes [0 ].NodeID
595
+ }
583
596
return nodes [0 ].NodeID , nil
584
597
}
585
598
0 commit comments