本文整理汇总了Java中com.ripple.core.coretypes.uint.UInt32类的典型用法代码示例。如果您正苦于以下问题:Java UInt32类的具体用法?Java UInt32怎么用?Java UInt32使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UInt32类属于com.ripple.core.coretypes.uint包,在下文中一共展示了UInt32类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: forType
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
private static TypeTranslator forType(Type type) {
switch (type) {
case STObject: return translate;
case Amount: return Amount.translate;
case UInt16: return UInt16.translate;
case UInt32: return UInt32.translate;
case UInt64: return UInt64.translate;
case Hash128: return Hash128.translate;
case Hash256: return Hash256.translate;
case Blob: return Blob.translate;
case AccountID: return AccountID.translate;
case STArray: return STArray.translate;
case UInt8: return UInt8.translate;
case Hash160: return Hash160.translate;
case PathSet: return PathSet.translate;
case Vector256: return Vector256.translate;
default: throw new RuntimeException("Unknown type");
}
}
示例2: doUpdate
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
private boolean doUpdate(UInt32 txnIndex, UInt32 ledgerIndex) {
if (le == null && !deleted) {
return true;
}
if (prevLedger == null) {
return true;
}
int ledgerCmp = ledgerIndex.compareTo(prevLedger);
if (ledgerCmp == 1) {
return true;
}
if (ledgerCmp == 0) {
if (prevTxnIndex == null) {
// We don't know, should log a warning or something
// Should we keep the first one that we have of this index
// or can we assume that the latest is the best?
return true;
}
if (txnIndex.compareTo(prevTxnIndex) == 1) {
// This happened AFTER
return true;
}
}
//ledgerCmp == -1 or txnIndex <= previousTxnIndex ss
return false;
}
示例3: updateFromTransactionResult
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
public void updateFromTransactionResult(TransactionResult tr) {
if (!tr.validated) {
return;
}
TransactionMeta meta = tr.meta;
UInt32 ledgerIndex = tr.ledgerIndex;
UInt32 txnIndex = meta.transactionIndex();
for (AffectedNode an : meta.affectedNodes()) {
Hash256 index = an.ledgerIndex();
CacheEntry ce = getOrCreate(index);
ce.upateLedgerEntry(an.isDeletedNode() ? null : (LedgerEntry) an.nodeAsFinal(),
ledgerIndex,
txnIndex);
}
}
示例4: cancelAllOffers
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
private void cancelAllOffers(JSONObject data) throws JSONException {
JSONArray offers = data.optJSONArray("offers");
if (offers == null) {
log.info("There is no offer for account" + data.toString(4));
return;
}
int offersLength = offers.length();
for (int i = 0; i < offersLength; i++) {
JSONObject offer = offers.getJSONObject(i);
OfferCancel offerCancel = new OfferCancel();
offerCancel.account(rippleAccount.id());
offerCancel.put(Field.OfferSequence, new UInt32(offer.optString("seq")));
log.info("Cancell All Offers " + offerCancel.toJSON());
template.convertAndSend(Channels.OFFER_CANCEL, offerCancel.toJSON().toString());
}
}
示例5: testSerializedPaymentTransaction
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
@Test
public void testSerializedPaymentTransaction() {
String expectedSerialization = "120000240000000561D4C44364C5BB00000000000000000000000000005553440000000000B5F762798A53D543A014CAF8B297CFF8F2F937E868400000000000000F73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0208114B5F762798A53D543A014CAF8B297CFF8F2F937E88314FD94A75318DE40B1D513E6764ECBCB6F1E7056ED";
IKeyPair kp = Seed.getKeyPair(TestFixtures.master_seed);
AccountID ac = AccountID.fromKeyPair(kp);
Payment payment = new Payment();
payment.put(AccountID.Account, ac);
payment.put(AccountID.Destination, TestFixtures.bob_account);
payment.putTranslated(UInt32.Sequence, 5);
payment.putTranslated(Amount.Fee, "15");
payment.putTranslated(Blob.SigningPubKey, kp.canonicalPubHex());
payment.putTranslated(Amount.Amount, "12/USD/" + ac.address);
assertEquals(expectedSerialization, payment.toHex());
}
示例6: testUINT
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
@Test
public void testUINT() {
STObject so = STObject.fromJSON("{\"Expiration\" : 21}");
assertEquals(21, so.get(UInt32.Expiration).longValue());
byte[] bytes = (new UInt8 (1)).toBytes();
byte[] bytes2 = (new UInt16(1)).toBytes();
byte[] bytes4 = (new UInt32(1)).toBytes();
byte[] bytes8 = (new UInt64(1)).toBytes();
assertEquals(bytes.length, 1);
assertEquals(bytes2.length, 2);
assertEquals(bytes4.length, 4);
assertEquals(bytes8.length, 8);
}
示例7: onTransactionResult
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
public void onTransactionResult(TransactionResult tr) {
log(Level.INFO, "Transaction {0} is validated", tr.hash);
Map<AccountID, STObject> affected = tr.modifiedRoots();
if (affected != null) {
Hash256 transactionHash = tr.hash;
UInt32 transactionLedgerIndex = tr.ledgerIndex;
for (Map.Entry<AccountID, STObject> entry : affected.entrySet()) {
Account account = accounts.get(entry.getKey());
if (account != null) {
STObject rootUpdates = entry.getValue();
account.getAccountRoot()
.updateFromTransaction(
transactionHash, transactionLedgerIndex, rootUpdates);
}
}
}
Account initator = accounts.get(tr.initiatingAccount());
if (initator != null) {
log(Level.INFO, "Found initiator {0}, notifying transactionManager", initator);
initator.transactionManager().notifyTransactionResult(tr);
} else {
log(Level.INFO, "Can't find initiating account!");
}
emit(OnValidatedTransaction.class, tr);
}
示例8: updateFromTransaction
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
public void updateFromTransaction(Hash256 transactionHash, UInt32 transactionLedgerIndex, STObject rootUpdates) {
// TODO, rethink this
// If transactionLedgerIndex is higher than current also apply it
// If we have a direct transaction chain, apply it
if (!updated || PreviousTxnID.equals(rootUpdates.get(Hash256.PreviousTxnID))) {
setFromSTObject(rootUpdates.get(STObject.FinalFields));
PreviousTxnID = transactionHash;
PreviousTxnLgrSeq = transactionLedgerIndex;
} else {
logger.fine("hrmmm .... "); // We should keep track of these and try and form a chain
}
}
示例9: setUnfundedAccount
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
public void setUnfundedAccount(AccountID account) {
Account = account;
Balance = Amount.fromString("0");
Sequence = new UInt32(1);
OwnerCount = new UInt32(0);
Flags = new UInt32(0);
PreviousTxnID = new Hash256(new byte[32]);
PreviousTxnLgrSeq = new UInt32(0);
notifyUpdate();
}
示例10: setFromSTObject
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
public void setFromSTObject(STObject so) {
if (so.has(AccountID.Account)) Account = so.get(AccountID.Account);
if (so.has(Amount.Balance)) Balance = so.get(Amount.Balance);
if (so.has(UInt32.Sequence)) Sequence = so.get(UInt32.Sequence);
if (so.has(UInt32.OwnerCount)) OwnerCount = so.get(UInt32.OwnerCount);
if (so.has(UInt32.Flags)) Flags = so.get(UInt32.Flags);
if (so.has(Hash256.PreviousTxnID)) PreviousTxnID = so.get(Hash256.PreviousTxnID);
if (so.has(UInt32.PreviousTxnLgrSeq)) PreviousTxnLgrSeq = so.get(UInt32.PreviousTxnLgrSeq);
notifyUpdate();
}
示例11: locallyPreemptedSubmissionSequence
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
private UInt32 locallyPreemptedSubmissionSequence() {
if (!accountRoot.primed()) {
throw new IllegalStateException("The AccountRoot hasn't been populated from the server");
}
long server = accountRoot.Sequence.longValue();
if (server > sequence) {
sequence = server;
}
return new UInt32(sequence++);
}
示例12: resubmitGreaterThan
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
private void resubmitGreaterThan(UInt32 submitSequence) {
for (ManagedTxn txn : getPending()) {
if (txn.sequence().compareTo(submitSequence) == 1) {
resubmitWithSameSequence(txn);
}
}
}
示例13: resubmitFirstTransactionWithTakenSequence
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
private void resubmitFirstTransactionWithTakenSequence(UInt32 sequence) {
for (ManagedTxn txn : getPending()) {
if (txn.sequence().compareTo(sequence) == 0) {
resubmitWithNewSequence(txn);
break;
}
}
}
示例14: resubmitWithNewSequence
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
private void resubmitWithNewSequence(final ManagedTxn txn) {
// A sequence plug's sole purpose is to plug a Sequence
// so that transactions may clear.
if (txn.isSequencePlug()) {
// The sequence has already been plugged (somehow)
// So:
return; // without further ado.
}
// ONLY ONLY ONLY if we've actually seen the Sequence
if (txnNotFinalizedAndSeenValidatedSequence(txn)) {
resubmit(txn, locallyPreemptedSubmissionSequence());
} else {
// requesting account_tx now and then (as we do) should ensure that
// this doesn't stall forever. We'll either finalize the transaction
// or Sequence will be seen to have been consumed by another txn.
on(OnValidatedSequence.class,
new CallbackContext() {
@Override
public boolean shouldExecute() {
return !txn.isFinalized();
}
@Override
public boolean shouldRemove() {
return txn.isFinalized();
}
},
new OnValidatedSequence() {
@Override
public void called(UInt32 uInt32) {
// Again, just to be safe.
if (txnNotFinalizedAndSeenValidatedSequence(txn)) {
resubmit(txn, locallyPreemptedSubmissionSequence());
}
}
});
}
}
示例15: trackSubmitRequest
import com.ripple.core.coretypes.uint.UInt32; //导入依赖的package包/类
public void trackSubmitRequest(Request submitRequest, long ledger_index) {
Submission submission = new Submission(submitRequest,
sequence(),
hash,
ledger_index,
txn.get(Amount.Fee),
txn.get(UInt32.LastLedgerSequence));
submissions.add(submission);
trackSubmittedID();
}