Registering and Deregistering Keys
Registering Keys
A node can register keys with DrtRegisterKey at anytime while in the DRT_ACTIVE, DRT_ALONE, and DRT_NO_NETWORK states. Keys registered in DRT_ALONE and DRT_NO_NETWORK states can only be recognized by other DRTs after the local node has transitioned to DRT_ACTIVE.
Identical keys cannot be registered within the same DRT instance when using DrtCreateDerivedKeySecurityProvider. If the registration of identical keys is attempted, the registration of the second key will fail. The use of identical keys should also be avoided between different DRT instances. Searches against the unique key designation these identical keys share could return any one of the keys, regardless of what data is associated to the key.
Note
If different behavior is required for implementation, a security provider can be created in place of DrtCreateDerivedKeySecurityProvider to accommodate.
Deregistering Keys
A node can deregister a key anytime after it has been registered. However, only the application that registered the key can deregister it. An application can deregister a key from the local node using the DrtUnregisterKey function. Upon completion the function triggers a DRT_EVENT_LEAFSET_KEY_CHANGE event; informing the application as well as other nodes participating in the DRT mesh.
While in the DRT_FAULTED state, the required call of DrtClose will result in the DRT infrastructure deregistering all keys.
Related topics