diff --git a/platform/view/core/endpoint/binder.go b/platform/view/core/endpoint/binder.go index 3414eb077..2beb2b5ab 100644 --- a/platform/view/core/endpoint/binder.go +++ b/platform/view/core/endpoint/binder.go @@ -26,28 +26,29 @@ type binder struct { bindingKVS driver.BindingKVS } -func (b *binder) Bind(ephemeral, longTerm view.Identity) error { - if ephemeral.IsNone() || longTerm.IsNone() { +func (b *binder) Bind(this, that view.Identity) error { + if this.IsNone() || that.IsNone() { return errors.New("empty ids passed") } // Make sure the long term is passed, so that the hierarchy is flat and all ephemerals point to the long term - longTerm, err := b.bindingKVS.GetBinding(longTerm) + longTerm, err := b.bindingKVS.GetBinding(that) if err != nil { - return errors.Wrapf(err, "no long term found for [%s]. if long term was passed, it has to be registered first.", longTerm) + return errors.Wrapf(err, "no long term found for [%s]. if long term was passed, it has to be registered first.", that) } - if longTerm != nil { - return b.bindingKVS.PutBinding(ephemeral, longTerm) + if !longTerm.IsNone() { + logger.Infof("Long term id for [%s] is [%s]", that, longTerm) + return b.bindingKVS.PutBinding(this, longTerm) } - logger.Infof("Id [%s] has no long term binding. It will be registered as a long-term id.", longTerm) - if err := b.bindingKVS.PutBinding(longTerm, longTerm); err != nil { - return errors.Wrapf(err, "failed to register [%s] as long term", longTerm) + logger.Infof("Id [%s] has no long term binding. It will be registered as a long-term id.", that) + if err := b.bindingKVS.PutBinding(that, that); err != nil { + return errors.Wrapf(err, "failed to register [%s] as long term", that) } - err = b.bindingKVS.PutBinding(ephemeral, longTerm) - if lt, err := b.bindingKVS.GetBinding(ephemeral); err != nil || lt.IsNone() { - logger.Errorf("wrong binding for [%s][%s]: %v", longTerm, lt, err) + err = b.bindingKVS.PutBinding(this, that) + if lt, err := b.bindingKVS.GetBinding(this); err != nil || lt.IsNone() { + logger.Errorf("wrong binding for [%s][%s]: %v", that, lt, err) } else { - logger.Errorf("successful binding for [%s]", longTerm) + logger.Errorf("successful binding for [%s]", that) } return err }