Name Registry

From Rholang Wiki
Jump to navigation Jump to search

The RChain interpreter implements a name registry where names can be published. Publishing a name essentially puts it in global scope.

Insert Arbitrary[edit]

 new mapCh, read, mutate, insertArbitrary(`rho:registry:insertArbitrary`), stdout(`rho:io:stdout`) in {
   // Send an initially empty map
   mapCh!({}) | 
   // Do crypto-based access control
   contract read(key, return) = { ... } |
   contract mutate(key, value, return) = { ... } |
// Register contracts new readUriCh, mutateUriCh in { insertArbitrary!(bundle+{*read}, *readUriCh) | insertArbitrary!(bundle+{*mutate}, *mutateUriCh) } |
// Hack to get the underlying unforgeable names // A nicer way is to use the peviewUnforgeableNames api that @dckc wrote // An even nicer solution would be rearchitecting the node a bit #OutOfScope stdout!([*read, *mutate]) }

Now you have the underlying unforgeable ids. They are long hex strings. And in rchainAPI you can listenForDataAtPrivateNames(<readId>);

Insert Signed[edit]

Relationship to Bundles[edit]

It's common to publish names on which contracts are listening. Bundles are necessary for proper channel security in this case. You would only want you clients sending messages on the channel, not receiving, so you should publish the bundle+.