public static EngineResult engineResult(STObject obj) { return (EngineResult) obj.get(Field.TransactionResult); }
static public LedgerEntryType ledgerEntryType(STObject obj) { return (LedgerEntryType) obj.get(Field.LedgerEntryType); }
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 } }
public AccountID get(AccountIDField f) { return (AccountID) get(f.getField()); }
public UInt16 get(UInt16Field f) { return (UInt16) get(f.getField()); }
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(); }
public STArray get(STArrayField f) { return (STArray) get(f.getField()); }
public Hash160 get(Hash160Field f) { return (Hash160) get(f.getField()); }
public Hash256 get(Hash256Field f) { return (Hash256) get(f.getField()); }
public STObject get(STObjectField f) { return (STObject) get(f.getField()); }
public Blob get(BlobField f) { return (Blob) get(f.getField()); }
public Amount get(AmountField f) { return (Amount) get(f.getField()); }
public Hash128 get(Hash128Field f) { return (Hash128) get(f.getField()); }
public PathSet get(PathSetField f) { return (PathSet) get(f.getField()); }
public UInt32 get(UInt32Field f) { return (UInt32) get(f.getField()); }
public Vector256 get(Vector256Field f) { return (Vector256) get(f.getField()); }
@Override public JSONObject toJSONObject(STObject obj) { JSONObject json = new JSONObject(); for (Field f : obj) { SerializedType obj1 = obj.get(f); Object object = obj1.toJSON(); json.put(f.name(), object); } return json; }
private static void printTrade(TransactionResult tr, Offer before, Offer after) { // Executed define non negative amount of Before - After STObject executed = after.executed(before); Amount takerGot = executed.get(Amount.TakerGets); // Only print trades that executed if (!takerGot.isZero()) { print("In {0} tx: {1}, Offer owner {2}, was paid: {3}, gave: {4} ", tr.transactionType(), tr.hash, before.account(), executed.get(Amount.TakerPays), takerGot); } } }
public STObject executed(STObject finalFields) { // where `this` is an AffectedNode nodeAsPrevious STObject executed = new STObject(); executed.put(Amount.TakerPays, finalFields.get(Amount.TakerPays).subtract(takerPays())); executed.put(Amount.TakerGets, finalFields.get(Amount.TakerGets).subtract(takerGets())); return executed; }