[Webfunds-commits] java/webfunds/client/sox SOXWallet.java

Ian Grigg iang@cypherpunks.ai
Sun, 4 Jun 2000 20:48:48 -0400 (AST)


iang        00/06/04 20:48:48

  Modified:    webfunds/client/sox SOXWallet.java
  Log:
  diags, minor changes, new internalUpdate with one mail argument, comments

Revision  Changes    Path
1.118     +47 -14    java/webfunds/client/sox/SOXWallet.java

Index: SOXWallet.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/sox/SOXWallet.java,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- SOXWallet.java	2000/06/04 19:57:32	1.117
+++ SOXWallet.java	2000/06/05 00:48:48	1.118
@@ -1,4 +1,4 @@
-/* $Id: SOXWallet.java,v 1.117 2000/06/04 19:57:32 gelderen Exp $
+/* $Id: SOXWallet.java,v 1.118 2000/06/05 00:48:48 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -60,7 +60,7 @@
     protected   SOXServerStore          soxes;
     protected   ReceiptsStore           receiptStore;
     protected   Store                   store;
-    protected   ContractStore           contracts;
+    protected   ContractStore           contracts = null;
     protected   Vector                  confirmmails = new Vector();
     //protected final WalletAction[]      actions;
 
@@ -76,6 +76,7 @@
     // bug gets set directly by WalletManager
     public SOXWallet()                          { super(); debug(fix); }
 
+    // these are therefore no use...
     public SOXWallet(PrintWriter bug)           { super(); debug(bug, fix); }
     public SOXWallet(PrintWriter bug, String f) { super(); debug(bug, f); }
 
@@ -297,17 +298,20 @@
     public Account getAccount(AccountId id)
         throws StoreException
     {
-        // is the name needed in the accountStore context?
-        // AccountInfo info = new AccountInfo(id.getId(), null, this);
         return accountStore.getAccount(id) ;
     }
 
     public Account getAccount(AccountInfo info)
         throws StoreException
     {
+        return accountStore.getAccount(getAccountId(info)) ;
+    }
+
+    public AccountId getAccountId(AccountInfo info)
+    {
         AccountId acct = new AccountId();
         acct.setId(info.getId());
-        return accountStore.getAccount(acct) ;
+        return acct;
     }
 
     public AccountInfo[] getAccounts()
@@ -823,27 +827,34 @@
      */
     public String checkReceipt(Receipt receipt,
                                AccountId p_src, AccountId p_tgt,
-                               ItemId p_item, long amount)
+                               ItemId p_item, long p_qty)
     {
         String statString = "";
 
         String s = "";
 
         AccountId tgt = receipt.getTarget();
+        AccountId src = receipt.getSource();
+        ItemId item = receipt.getItem();
+        long qty = receipt.getQty();
+
+        logmsg("checking: " +
+               tgt + "==" + p_tgt + "   " +
+               src + "==" + p_src + "   " +
+               item + "==" + p_item + "   " +
+               qty + "==" + p_qty);
+
         if (!tgt.equals(p_tgt))
             statString += "\nTarget " + tgt + " is not expected " + p_tgt;
 
-        AccountId src = receipt.getSource();
         if (!src.equals(p_src))
             statString += "\nSource " + tgt + " is not expected " + p_src;
 
-        ItemId item = receipt.getItem();
         if (!item.equals(p_item))
             statString += "\nItem " + item + " is not expected " + p_item;
 
-        long am = receipt.getQty();
-        if (am != amount)
-            statString += "\nAmount " + am + " is not expected " + amount;
+        if (qty != p_qty)
+            statString += "\nAmount " + qty + " is not expected " + qty;
 
         return (s.length() == 0) ? null : s ;
     }
@@ -948,6 +959,7 @@
 
         AccountId acct = getAccountId(sub);
         ItemId item = sub.getItemId();
+        logmsg("internalCancel("+acct+"/"+item+", pid["+pids.length+"])");
         Vector updates = new Vector();
         SOXLaterException soxlater = null;
         StoreException storex = null;
@@ -1045,6 +1057,7 @@
 
         AccountId acct = getAccountId(sub);
         ItemId item = sub.getItemId();
+        logmsg("internalCancel(" + acct + "/" + item + ", " + pid + ")");
 
         StateReceipt sr;
         try {
@@ -1480,6 +1493,8 @@
 
     /**
      *  Get and sign for the mail from the issuer for this account.
+     *  Will drag in all items that are handled by this account at
+     *  this issuer - part of the account request structure.
      *  Client Wallet Interface
      */
     public void update(AccountInfo accountinfo, ItemId item)
@@ -1505,7 +1520,7 @@
         }
         SubAccount sub = account.getSub(item);
 
-        manyUpdates(sub, null);
+        manyUpdates(sub, null);           // sub is surrogate for account
     }
 
     /**
@@ -1533,6 +1548,8 @@
     /**
      *  Handle this mail that came via another request.
      *  OTOH, the subaccount does identify the account.
+     *  All mail items must come from the same SOXServer,
+     *  (but are not necessarily the same subaccount, etc).
      */
     protected void internalUpdate(SubAccount sub, MailItem[] mails)
     {
@@ -1540,6 +1557,13 @@
         manyUpdates(sub, mails);
     }
 
+    protected void internalUpdate(SubAccount sub, MailItem mail)
+    {
+        MailItem[] mm = new MailItem[1];
+        mm[0] = mail;
+        manyUpdates(sub, mm);
+    }
+
     /**
      * Get and sign for the mail from the issuer for this account.
      */
@@ -1547,6 +1571,7 @@
     {
         MailId[] confirms = null;
 
+        logmsg("manyUpdates(" + ((mails == null)? 0: mails.length) + ")");
         if (mails != null && (mails.length > 0))
             confirms = tryHandle(sub, mails);
 
@@ -1562,6 +1587,7 @@
             mails = tryUpdate(sub, confirms);
             if (mails == null || (mails.length == 0))
                 return ;
+            logmsg("for(;" + i + "<4; ++) on " + mails.length + " mails");
 
             //
             //  Did I get some more mail in that update?
@@ -1579,7 +1605,13 @@
     }
 
     /**
-     * Do an update - one single cycle of request with sigs.
+     *  Do an update - one single cycle of request with sigs.
+     *  Bummer.  There is a problem here.  Mail is requested
+     *  at the Account/Issuer level.  Which means that some
+     *  of the mail here is in fact for other subs.  So, the
+     *  the sub is simply passed here as an active sub from
+     *  which we can do the request to the Issuer, the item
+     *  of the sub forms no part of the data.
      */
     protected MailItem[] tryUpdate(SubAccount sub, MailId[] confirms)
     {
@@ -1656,7 +1688,8 @@
         if (mail.isReceipt())
             ok = handleReceiptData(mail.getMessage(), getAccountId(sub));
         else
-            logmsg("Unknown mail: " + mail.getType() + " ... ignoring");
+            logmsg("Unknown mail: " + mail.getType() + " ... ignoring:\n\n" +
+                   Hex.data2hex(mail.getMail()) + "\n\n");
 
         return ok ;
     }