本文整理汇总了Java中com.ripple.client.transactions.TransactionManager类的典型用法代码示例。如果您正苦于以下问题:Java TransactionManager类的具体用法?Java TransactionManager怎么用?Java TransactionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionManager类属于com.ripple.client.transactions包,在下文中一共展示了TransactionManager类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkMaxRequestPayment
import com.ripple.client.transactions.TransactionManager; //导入依赖的package包/类
public void checkMaxRequestPayment(Account account, TransactionManager transactionManager, Payment payment,
int maxOrdersOffers, int currentOpenOffers) {
log.info("checkMaxRequestPayment maxOrdersOffers: " + maxOrdersOffers + " currentOpenOffers: "
+ currentOpenOffers + " Payment: " + payment.accountTxnID());
int x = countTransactionManagerPayment(transactionManager);
int c = transactionManager.txnsPending() - x;
if (c > currentOpenOffers) {
log.warn("transactionManager " + c + " currentOpenOffers: " + currentOpenOffers);
return;
}
// TODO check and count for ask and bid
if (arbitragerCreateOffersEnabled) {
prepareAndQueuePayment(payment);
}
}
示例2: Account
import com.ripple.client.transactions.TransactionManager; //导入依赖的package包/类
public Account(AccountID id,
IKeyPair keyPair, TrackedAccountRoot root,
TransactionManager tm) {
this.id = id;
this.accountRoot = root;
this.tm = tm;
this.keyPair = keyPair;
}
示例3: countTransactionManagerPayment
import com.ripple.client.transactions.TransactionManager; //导入依赖的package包/类
private int countTransactionManagerPayment(TransactionManager transactionManager) {
Iterator<ManagedTxn> it = transactionManager.getPending().iterator();
int a = 0;
while (it.hasNext()) {
ManagedTxn t = it.next();
if (t.transactionType() == TransactionType.Payment) {
a++;
}
}
return a;
}
示例4: checkMaxRequestOffer
import com.ripple.client.transactions.TransactionManager; //导入依赖的package包/类
public void checkMaxRequestOffer(Account account, TransactionManager transactionManager, OfferCreate offer,
int maxOrdersOpenAsks, int countCreateAsks, int maxOrdersOpenBids, int countCreateBids)
throws InvalidCipherTextException, JSONException, IOException {
log.info("checkMaxRequestOffer maxOrdersOpenAsks: " + maxOrdersOpenAsks + " countCreateAsks: " + countCreateAsks
+ " maxOrdersOpenBids: " + maxOrdersOpenBids + " countCreateBids: " + countCreateBids + " Offer: "
+ offer.accountTxnID());
int x = countTransactionManagerOfferCancel(transactionManager);
int c = transactionManager.txnsPending() - x;
int count = (maxOrdersOpenAsks - countCreateAsks) + (maxOrdersOpenBids - countCreateBids);
if (c > count) {
log.warn("transactionManager " + c + " countAsks " + countCreateAsks + " countBids " + countCreateBids
+ " countCancel " + x);
return;
}
boolean isAsk = RippleAccountOffersPublisher.isOfferAsk(offer, baseAsset);
if (isAsk) {
if (countCreateAsks >= maxOrdersOpenAsks) {
log.info("Max countCreateAsks " + countCreateAsks);
return;
}
} else {
if (countCreateBids >= maxOrdersOpenBids) {
log.info("Max countCreateBids " + countCreateBids);
return;
}
}
if (enableOpportunityTaker) {
prepareAndQueueOfferCreate(offer, isAsk);
}
}
示例5: countTransactionManagerOfferCancel
import com.ripple.client.transactions.TransactionManager; //导入依赖的package包/类
private int countTransactionManagerOfferCancel(TransactionManager transactionManager) {
Iterator<ManagedTxn> it = transactionManager.getPending().iterator();
int a = 0;
while (it.hasNext()) {
ManagedTxn t = it.next();
if (t.transactionType() == TransactionType.OfferCancel) {
a++;
}
}
return a;
}
示例6: CreateOffer
import com.ripple.client.transactions.TransactionManager; //导入依赖的package包/类
public CreateOffer (Client client, String seed) {
Account account = client.accountFromSeed(seed);
TransactionManager tm = account.transactionManager();
OfferCreate offer = new OfferCreate();
offer.as(Amount.TakerPays, "1000000")
.as(Amount.TakerGets, "1/USD/" + account.id());
tm.queue(tm.manage(offer)
.onValidated(this::onValidated)
.onError(this::onError));
}
示例7: transactionManager
import com.ripple.client.transactions.TransactionManager; //导入依赖的package包/类
public TransactionManager transactionManager() {
return tm;
}
示例8: example
import com.ripple.client.transactions.TransactionManager; //导入依赖的package包/类
public static void example(Client client, String secret) {
Account account = client.accountFromSeed(secret);
PaymentFlow flow = new PaymentFlow(client);
TransactionManager tm = account.transactionManager();
// We could get these from user input
AccountID destination = fromAddress("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B");
BigDecimal slippageFactor = new BigDecimal("1.001");
BigDecimal amount = new BigDecimal("0.0000001");
Currency USD = Currency.fromString("USD");
// We use this not for its atomic properties, but because
// it's `effectively final` and can be mutated from inside
// a lambda below.
AtomicInteger attempts = new AtomicInteger(1);
flow.source(account)
.destination(destination)
.destinationAmountValue(amount)
.destinationAmountCurrency(USD)
.onAlternatives((alts) -> {
if (alts.size() > 0) {
// Create a payment, bind the handlers
// No more onAlternatives events will be emitted
// after createPayment has been invoked.
ManagedTxn payment =
flow.createPayment(alts.get(0), slippageFactor)
.onError(PaymentPaths::onError)
.onValidated(PaymentPaths::onValidated);
// Set the destination tag
payment.txn.as(UInt32.DestinationTag, 1337);
// Tell the manager to submit it
tm.queue(payment);
} else {
printErr("Message {0} had no payment paths", attempts);
if (attempts.incrementAndGet() > 3) {
printErr("Aborting!");
System.exit(1);
}
}
});
}