Skip to content

Commit

Permalink
Eliminate the need for TransactionContext
Browse files Browse the repository at this point in the history
- Functionality related to block information is added to KernelInterface
- SideEffects are added to TransactionResult
  • Loading branch information
arajasek committed Apr 9, 2019
1 parent 9033989 commit d1d5e7c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/org/aion/interfaces/tx/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ public interface Transaction extends Cloneable, TransactionInterface {
long getNrgConsume();

void setNrgConsume(long _nrg);

Address getContractAddress();
}
37 changes: 37 additions & 0 deletions src/org/aion/vm/api/interfaces/KernelInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,41 @@ public interface KernelInterface {
* @return True if this address can be invoked from the calling {@link VirtualMachine}.
*/
boolean destinationAddressIsSafeForThisVM(Address address);

/**
* Returns the number of the block that this kernel interface is at.
*
* @return The block number.
*/
long getBlockNumber();

/**
* Returns the timestamp of the block that this kernel interface is at.
*
* @return The block timestamp.
*/
long getBlockTimestamp();

// TODO: block energy limit can probably be removed.

/**
* Returns the energy limit of the block that this kernel interface is at.
*
* @return The block energy limit.
*/
long getBlockEnergyLimit();

/**
* Returns the difficulty of the block that this kernel interface is at.
*
* @return The block difficulty.
*/
long getBlockDifficulty();

/**
* Returns the address of the miner of the block that this kernel interface is at.
*
* @return The miner's address.
*/
Address getMinerAddress();
}
13 changes: 13 additions & 0 deletions src/org/aion/vm/api/interfaces/TransactionInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public interface TransactionInterface {
*/
Address getDestinationAddress();

/**
* Returns the address of the contract that this transaction will create.
*
* @return The destination address.
*/ Address getContractAddress();

/**
* Returns the nonce of this transaction, which is the nonce of the sender account.
*
Expand Down Expand Up @@ -92,4 +98,11 @@ public interface TransactionInterface {
* @return True if this transaction creates a new contract.
*/
boolean isContractCreationTransaction();

/**
* Returns the kind of the corresponding transaction. For example, CREATE or CALL.
*
* @return The transaction kind.
*/
byte getKind();
}
7 changes: 7 additions & 0 deletions src/org/aion/vm/api/interfaces/TransactionResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,12 @@ public interface TransactionResult {
*/
void setEnergyRemaining(long energyRemaining);

/**
* Returns the side-effects that were the result of executing the corresponding transaction.
*
* @return The execution side-effects of the transaction.
*/
TransactionSideEffects getSideEffects();

byte[] toBytes();
}
8 changes: 4 additions & 4 deletions src/org/aion/vm/api/interfaces/VirtualMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ public interface VirtualMachine {
void shutdown();

/**
* Executes the transactions contained in the array of contexts in such a way that the logical
* ordering of the transactions is preserved.
* Executes the transactions in such a way that the logical ordering of the transactions is
* preserved.
*
* <p>This method possibly runs asynchronously and returns its results to the caller via a non-
* blocking {@link SimpleFuture} array.
*
* @param kernel The {@link KernelInterface} representing the blockchain state for these transactions.
* @param contexts The transaction contexts to execute.
* @param transactions The transactions to execute.
* @return The results of the execution.
* @throws ClosedVirtualMachineException if no long-lived instance of this class currently
* exists.
*/
SimpleFuture<TransactionResult>[] run(KernelInterface kernel, TransactionContext[] contexts);
SimpleFuture<TransactionResult>[] run(KernelInterface kernel, TransactionInterface[] transactions);
}

0 comments on commit d1d5e7c

Please sign in to comment.