Commit 753b3098 authored by Karl Floersch's avatar Karl Floersch Committed by GitHub

Make getNextQueueIndex public (#32)

parent 134b5d77
...@@ -110,6 +110,21 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -110,6 +110,21 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
return uint256(batches.getLength()); return uint256(batches.getLength());
} }
/**
* @inheritdoc iOVM_CanonicalTransactionChain
*/
function getNextQueueIndex()
override
public
view
returns (
uint40
)
{
(, uint40 nextQueueIndex) = _getBatchExtraData();
return nextQueueIndex;
}
/** /**
* @inheritdoc iOVM_CanonicalTransactionChain * @inheritdoc iOVM_CanonicalTransactionChain
*/ */
...@@ -227,7 +242,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -227,7 +242,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
"Must append more than zero transactions." "Must append more than zero transactions."
); );
uint40 nextQueueIndex = _getNextQueueIndex(); uint40 nextQueueIndex = getNextQueueIndex();
bytes32[] memory leaves = new bytes32[](_numQueuedTransactions); bytes32[] memory leaves = new bytes32[](_numQueuedTransactions);
for (uint256 i = 0; i < _numQueuedTransactions; i++) { for (uint256 i = 0; i < _numQueuedTransactions; i++) {
leaves[i] = _getQueueLeafHash(nextQueueIndex); leaves[i] = _getQueueLeafHash(nextQueueIndex);
...@@ -297,7 +312,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -297,7 +312,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
bytes32[] memory leaves = new bytes32[](totalElementsToAppend); bytes32[] memory leaves = new bytes32[](totalElementsToAppend);
uint32 transactionIndex = 0; uint32 transactionIndex = 0;
uint32 numSequencerTransactionsProcessed = 0; uint32 numSequencerTransactionsProcessed = 0;
uint40 nextQueueIndex = _getNextQueueIndex(); uint40 nextQueueIndex = getNextQueueIndex();
for (uint32 i = 0; i < numContexts; i++) { for (uint32 i = 0; i < numContexts; i++) {
BatchContext memory context = _getBatchContext(i); BatchContext memory context = _getBatchContext(i);
...@@ -418,21 +433,6 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -418,21 +433,6 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
}); });
} }
/**
* Returns the index of the next element to be enqueued.
* @return Index for the next queue element.
*/
function _getNextQueueIndex()
internal
view
returns (
uint40
)
{
(, uint40 nextQueueIndex) = _getBatchExtraData();
return nextQueueIndex;
}
/** /**
* Parses the batch context from the extra data. * Parses the batch context from the extra data.
* @return Total number of elements submitted. * @return Total number of elements submitted.
......
...@@ -74,6 +74,17 @@ interface iOVM_CanonicalTransactionChain { ...@@ -74,6 +74,17 @@ interface iOVM_CanonicalTransactionChain {
uint256 _totalBatches uint256 _totalBatches
); );
/**
* Returns the index of the next element to be enqueued.
* @return Index for the next queue element.
*/
function getNextQueueIndex()
external
view
returns (
uint40
);
/** /**
* Gets the queue element at a particular index. * Gets the queue element at a particular index.
* @param _index Index of the queue element to access. * @param _index Index of the queue element to access.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment