Skip to content

Commit 6128abb

Browse files
committed
add node implementation
1 parent ea458bd commit 6128abb

File tree

2 files changed

+307
-37
lines changed

2 files changed

+307
-37
lines changed

node-registrar/client/account.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (c RegistrarClient) updateAccount(relays []string, rmbEncKey string) (err e
163163
}
164164

165165
func (c RegistrarClient) getAccountByPK(pk []byte) (account Account, err error) {
166-
url, err := url.JoinPath(c.baseURL, "accounts", fmt.Sprint(c.twinID))
166+
url, err := url.JoinPath(c.baseURL, "accounts")
167167
if err != nil {
168168
return account, errors.Wrap(err, "failed to construct registrar url")
169169
}
@@ -213,3 +213,17 @@ func (c RegistrarClient) ensureAccount(pk []byte, relays []string, rmbEncKey str
213213

214214
return
215215
}
216+
217+
func (c *RegistrarClient) ensureTwinID() error {
218+
if c.twinID != 0 {
219+
return nil
220+
}
221+
222+
twin, err := c.getAccountByPK(c.keyPair.publicKey)
223+
if err != nil {
224+
return errors.Wrap(err, "failed to get the account of the node, registrar client was not set up properly")
225+
}
226+
227+
c.twinID = twin.TwinID
228+
return nil
229+
}

0 commit comments

Comments
 (0)