[Webfunds-commits] java/webfunds/sox SubAccount.java
Ian Grigg
iang@cypherpunks.ai
Wed, 11 Apr 2001 15:21:05 -0400 (AST)
iang 01/04/11 15:21:05
Modified: webfunds/sox SubAccount.java
Log:
cleaned up some diags, changed "issuer" words to "server"
Revision Changes Path
1.32 +35 -32 java/webfunds/sox/SubAccount.java
Index: SubAccount.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/SubAccount.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- SubAccount.java 2001/04/06 23:55:02 1.31
+++ SubAccount.java 2001/04/11 19:21:04 1.32
@@ -1,4 +1,4 @@
-/* $Id: SubAccount.java,v 1.31 2001/04/06 23:55:02 iang Exp $
+/* $Id: SubAccount.java,v 1.32 2001/04/11 19:21:04 iang Exp $
*
* Copyright (c) Systemics Inc. 1995-2000 on behalf of
* The WebFunds Development Team. All Rights Reserved.
@@ -26,7 +26,7 @@
/**
* Is capable of sending requests to the server.
*/
- protected Issuer issuer;
+ protected Issuer server;
/**
* The item identifier - contract hash - of this account.
@@ -48,11 +48,11 @@
*/
protected transient int reqNo = 0;
- protected static final int NEW = 0;
- protected static final int REGISTERED = 1; // issuer has been told
- protected static final int ACTIVE = 2; // when we see a receipt
- protected static final int RETRY = 4; // re-deposit in progress
- protected static final int FROZEN = 32; // no more action allowed
+ protected static final int NEW = 0,
+ REGISTERED = 1, // server has been told
+ ACTIVE = 2, // when we see a receipt
+ RETRY = 4, // re-deposit in progress
+ FROZEN = 32; // no more action allowed
/**
* Status of subaccount.
@@ -67,7 +67,9 @@
public boolean isFrozen() { return(status & FROZEN) == FROZEN ; }
public int getStatus() { return status ; }
- public void logmsg(String s) { System.err.println(s); }
+ private static final String TAB = " ";
+ protected static String fix = "subAc ";
+ public void logmsg(String s) { System.err.println(TAB + fix + s); }
@@ -109,8 +111,8 @@
/**
- * @return an issuer for use with this subaccount.
- * @except SOXSubAccountException if the account cannot find an issuer.
+ * @return an server for use with this subaccount.
+ * @except SOXSubAccountException if the account cannot find an server.
*/
public Issuer getIssuer()
throws SOXSubAccountException, SOXLaterException
@@ -118,11 +120,11 @@
if (acct == null)
throw new SOXSubAccountException("no acct, not ready for ops") ;
checkNet();
- if (issuer != null)
- return issuer ;
+ if (server != null)
+ return server ;
try {
- issuer = acct.getIssuer(itemId);
+ server = acct.getIssuer(itemId);
} catch (SOXIssuerException ex) {
if (ex.isNoContract())
throw new SOXSubAccountException(
@@ -133,20 +135,20 @@
"no SOX server available for " + itemId + " : " + ex);
}
- if (issuer == null)
+ if (server == null)
throw new SOXSubAccountException(SOXSubAccountException.NO_SERVER,
"no SOX server available for " + itemId);
- return issuer ;
+ return server ;
}
/**
- * @return an issuer for use with this subaccount.
- * @except SOXSubAccountException if the account cannot find an issuer.
+ * @return an server for use with this subaccount.
+ * @except SOXSubAccountException if the account cannot find an server.
*/
- public void setIssuer(Issuer issuer)
+ public void setIssuer(Issuer server)
{
- this.issuer = issuer;
+ this.server = server;
}
private long lastDiff = 0;
@@ -182,10 +184,10 @@
if (NetWatcher.netAvailability())
{
try {
- Issuer issuer = getIssuer();
- logmsg("adjustTime() with issuer " + issuer);
- diff = issuer.getTimeDifference();
- deviation = issuer.getTimeDeviation();
+ Issuer server = getIssuer();
+ logmsg("adjustTime() with server " + server);
+ diff = server.getTimeDifference();
+ deviation = server.getTimeDeviation();
} catch (SOXException ex) {
}
}
@@ -193,7 +195,7 @@
logmsg("no net - using old times");
logmsg("adjustTime(" + tim + ") minus diff " + diff +
- (earliest ? " subtract deviation " : " add deviation ") +
+ (earliest ? " minus dev " : " add dev ") +
deviation);
long millis = tim - diff;
@@ -272,6 +274,7 @@
throw new SOXSubAccountException(err,
"Failed (" + err + ") " + txt);
+ // XXX: why only when isNew()?
if (isNew())
status |= REGISTERED;
@@ -285,13 +288,13 @@
protected byte[] requestExtra(Request req)
throws SOXSubAccountException, SOXLaterException
{
- Issuer issuer;
+ Issuer server;
byte[] replyBuf;
- issuer = getIssuer(); // returns a working issuer, or bust
- logmsg("requestExtra() with issuer " + issuer);
+ server = getIssuer(); // returns a working server, or bust
+ logmsg("requestExtra() with server " + server);
try {
- replyBuf = issuer.request(req);
+ replyBuf = server.request(req);
} catch (SOXIssuerException iex) {
throw new SOXSubAccountException(SOXSubAccountException.SERVER_DOWN,
"SOXIEx: " + iex);
@@ -400,7 +403,7 @@
* by the SOX Server, corrects them, and retries.
* As there are a number of SOX Server used by this account
* it is hard to keep track of who has registered where
- * (bearing in mind that there are few issuers, and many contracts).
+ * (bearing in mind that there are few server, and many subaccounts).
* So, we do it by feedback for the moment.
*
* @param retry true if this call is already recursive
@@ -450,7 +453,7 @@
* if it does, fix it or move it above.
*/
else
- throw new SOXSubAccountException(err, "Deposit Failure: " + txt);
+ throw new SOXSubAccountException(err, "Request Failure: " + txt);
}
@@ -499,7 +502,7 @@
return ;
- // a chance to tell the server that data is no longer required!
+ // XXX: a chance to tell the server that data is no longer required!
// deposit(createPayment(acct.getId(), 0, "Delete", true), "DELETE");
// what is this supposed to do?
}
@@ -574,7 +577,7 @@
String retval = this.getClass().getName() + ":\n";
retval += "ItemId = " + itemId;
retval += "\nStatus = " + status + "\t";
- retval += "Issuer set = " + (issuer != null);
+ retval += "Server set = " + (server != null);
retval += "\tAccount = " + (acct == null ? "<null>" : ""+acct.getId());
return retval;
}