webfunds.client.sox
Class StoreReceiptStore

java.lang.Object
  |
  +--webfunds.utils.Debug
        |
        +--webfunds.client.sox.StoreReceiptStore

public final class StoreReceiptStore
extends Debug
implements ReceiptsStore

A place to persistantly store SOX receipts. It has persistant stores, one each for pending and confirmed receipts. It should store each (pending)receipts as a StateReceipt or the like. This should be dependant on Store and SOX only. (Used to be dependant on client.)


Fields inherited from class webfunds.utils.Debug
bug, debugAll, logfix
 
Constructor Summary
StoreReceiptStore(Store store)
           
StoreReceiptStore(Store store, java.io.PrintWriter bug)
           
 
Method Summary
 void addPendingReceipt(PendingReceipt pending, AccountId acct)
          A payment has been made/signed, indicating a receipt will come at some stage.
 void addReceipt(Receipt receipt)
          A signed receipt has arrived.
 void addReceipt(Receipt receipt, AccountId acct)
          A signed receipt has arrived.
protected  void addReceipt(Store sub, Receipt receipt)
          Add this signed receipt into the store.
 long confirmedValue(AccountId acct, ItemId item)
           
static void convert(Store store, java.io.PrintWriter bug)
           
protected  Store getPen(AccountId acct, ItemId item)
          Get the Pending store from the account details.
protected  Store getPen(Store sub)
          Get the Pending store from the sub account store.
 PendingReceipt[] getPendingReceipts(AccountId acct, ItemId item)
          Return a list of pending receipts for a subaccount.
 StateReceipt getReceipt(AccountId acct, ItemId item, java.lang.String id)
          Get the current state machine for a transaction.
 Receipt[] getReceipts(AccountId acct, ItemId item)
          Get a list of receipts for a subaccount (acct / item).
protected  Store getSub(AccountId acct, ItemId item)
          Get the sub account store.
protected  void init(Store store)
           
 boolean isChanged(AccountId acct)
          Does not check the subaccounts? Not Needed?
 boolean isChanged(AccountId acct, ItemId item)
          Used to see if a re-count of value is needed.
 long pendingValue(AccountId acct, ItemId item)
          What this returns is peculiar.
protected  void removePending(java.lang.String id, AccountId acct, ItemId item)
          Remove a pending receipt, presumably because it failed or or it has moved to the normal store.
 
Methods inherited from class webfunds.utils.Debug
debug, debug, debug, debug, err, getDebug, logend, logmsg, logstart, logword
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StoreReceiptStore

public StoreReceiptStore(Store store,
                         java.io.PrintWriter bug)

StoreReceiptStore

public StoreReceiptStore(Store store)
Method Detail

init

protected void init(Store store)

getSub

protected Store getSub(AccountId acct,
                       ItemId item)
                throws StoreException
Get the sub account store.

getPen

protected Store getPen(Store sub)
                throws StoreException
Get the Pending store from the sub account store.

getPen

protected Store getPen(AccountId acct,
                       ItemId item)
                throws StoreException
Get the Pending store from the account details.

addReceipt

public void addReceipt(Receipt receipt)
                throws StoreException
A signed receipt has arrived. Find out which sub accounts it belongs to, and deal with it in the normal way. Idempotent.

addReceipt

protected void addReceipt(Store sub,
                          Receipt receipt)
                   throws StoreException
Add this signed receipt into the store.

addReceipt

public void addReceipt(Receipt receipt,
                       AccountId acct)
                throws StoreException
A signed receipt has arrived. Add it to the normal store, then drop any applicable pending. Idempotent. Also used by convert().
Specified by:
addReceipt in interface ReceiptsStore

getReceipts

public Receipt[] getReceipts(AccountId acct,
                             ItemId item)
                      throws StoreException
Get a list of receipts for a subaccount (acct / item).
Specified by:
getReceipts in interface ReceiptsStore

getReceipt

public StateReceipt getReceipt(AccountId acct,
                               ItemId item,
                               java.lang.String id)
                        throws StoreException
Get the current state machine for a transaction. This is only for payouts and completed payins, there is no recording of attempted payins (did used). Kludge: because we store it by (incorrect) xid, we can't get the info quickly.
Specified by:
getReceipt in interface ReceiptsStore
Parameters:
id - is either pid or (completed) did - overloaded
Returns:
a specific StateReceipt for a subaccount (acct / item).

addPendingReceipt

public void addPendingReceipt(PendingReceipt pending,
                              AccountId acct)
                       throws StoreException
A payment has been made/signed, indicating a receipt will come at some stage. Store the receipt as pending. Pending receipts are only for payments we write, not for deposits.
Specified by:
addPendingReceipt in interface ReceiptsStore

removePending

protected void removePending(java.lang.String id,
                             AccountId acct,
                             ItemId item)
                      throws StoreException
Remove a pending receipt, presumably because it failed or or it has moved to the normal store. Was public but there is no reason for this.

getPendingReceipts

public PendingReceipt[] getPendingReceipts(AccountId acct,
                                           ItemId item)
                                    throws StoreException
Return a list of pending receipts for a subaccount.
Specified by:
getPendingReceipts in interface ReceiptsStore

isChanged

public boolean isChanged(AccountId acct)
Does not check the subaccounts? Not Needed?
Specified by:
isChanged in interface ReceiptsStore
Returns:
true if the contents of the account's store have changed.

isChanged

public boolean isChanged(AccountId acct,
                         ItemId item)
Used to see if a re-count of value is needed.
Specified by:
isChanged in interface ReceiptsStore
Returns:
true if the contents of the SubAccount's store have changed.

pendingValue

public long pendingValue(AccountId acct,
                         ItemId item)
                  throws StoreException
What this returns is peculiar. It is the sum of payments going out, so all pending committments made, but not received. As it is a committment out, it should be negative.
Specified by:
pendingValue in interface ReceiptsStore
Tags copied from interface: ReceiptsStore
Returns:
the value of pending outgoing receipts within subaccount

confirmedValue

public long confirmedValue(AccountId acct,
                           ItemId item)
                    throws StoreException
Specified by:
confirmedValue in interface ReceiptsStore
Tags copied from interface: ReceiptsStore
Returns:
the value of confirmed receipts within subaccount

convert

public static void convert(Store store,
                           java.io.PrintWriter bug)