net.captp.tables
Class PromiseGiftTable

java.lang.Object
  |
  +--net.captp.tables.PromiseGiftTable

public class PromiseGiftTable
extends Object

Untamed: Rendezvous point for 3-vat live Granovetter introductions of Unresolved remote references (RemotePromises).

Where we normally speak of Alice giving Bob a reference to Carol, we here speak of the Donor (VatA) giving to the Recipient (VatB) a reference to the Gift (Carol) residing on the Host (VatC). There is one PromiseGiftTable in the Host per Donor. The Donor associates the gift with a Nonce and the Recipient's ID, and she tells the Nonce to the Recipient. The Recipient asks the Host "What gift has Donor (identified by DonorID) deposited for me at this Nonce?".

A Nonce is a use once unique number. It only needs to be "impossible" to collide under benevolent assumptions; it doesn't need to be unguessable, so perhaps a 64 bit number could have been used instead. For now, we just use our normal unguessable numbers (given by 'entropy nextSwiss()').

Two interesting complexities: 1) The Recipient's lookup request may arrive at the Host before the Donors donation request does. 2) A partition could prevent the operation from completing, in which case the Recipient cannot be left hanging, and the association must be cleaned up.

For 3-vat live Granovetter introductions of Resolved remote references (FarRefs), see the NearGiftTable.

Author:
Mark S. Miller.

Field Summary
private  Object myNonceLocatorPromise
          A RemotePromise for the Donor's NonceLocator.
private  FlexMap myStuff
          Maps from [recipID, Nonce] to [referent, optResolver]
 
Constructor Summary
PromiseGiftTable(Object nonceLocatorPromise)
          Enabled: @param nonceLocatorPromise A RemotePromise for the Donor's NonceLocator.
 
Method Summary
 Object acceptFor(String recipID, BigInteger nonce)
          Enabled: Lookup the gift.
 void drop(String recipID, BigInteger nonce)
          Enabled: Automagically called when the vine is dropped.
 Vine provideFor(Object gift, String recipID, BigInteger nonce)
          Enabled: Make the gift available to the recipient so long as the Vine is held onto (isn't garbage).
 void smash(Throwable problem)
          Enabled: Smash all untaken promises for undonated gifts, and then disable this table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myStuff

private FlexMap myStuff
Maps from [recipID, Nonce] to [referent, optResolver]


myNonceLocatorPromise

private final Object myNonceLocatorPromise
A RemotePromise for the Donor's NonceLocator.

Constructor Detail

PromiseGiftTable

public PromiseGiftTable(Object nonceLocatorPromise)
Enabled: @param nonceLocatorPromise A RemotePromise for the Donor's NonceLocator. The ignore(vine) message is sent to it, so that it can ignore it.

Method Detail

smash

public void smash(Throwable problem)
Enabled: Smash all untaken promises for undonated gifts, and then disable this table.


provideFor

public Vine provideFor(Object gift,
                       String recipID,
                       BigInteger nonce)
Enabled: Make the gift available to the recipient so long as the Vine is held onto (isn't garbage).


acceptFor

public Object acceptFor(String recipID,
                        BigInteger nonce)
Enabled: Lookup the gift.

If absent, return a promise for what will be given, and sends an ignore(vine) to the nonceLocatorPromise. The promise is good as long as the vine is held.

Note that this message is named "acceptFor" whereas the corresponding NonceLocator message is names "acceptFrom". In acceptFor, the recipient is explicit and the donor implicit. In acceptFrom, the donor is explicit and the recipient implicit.

Parameters:
recipID - The vatID of the vat (Bob, the gift recipient) that the gift is being picked up for.
nonce - Identifies (together with the recipID) the gift.

drop

public void drop(String recipID,
                 BigInteger nonce)
Enabled: Automagically called when the vine is dropped.

The Donor is able to call this as well, which isn't appropriate, but isn't dangerous, so what the hell.



comments?