Commit 6693d3a8 authored by Kevin Ho's avatar Kevin Ho Committed by GitHub

remove pushTwo and getTwo (#324)

parent 6ac40bad
...@@ -313,14 +313,12 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -313,14 +313,12 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
iOVM_ChainStorageContainer queueRef = queue(); iOVM_ChainStorageContainer queueRef = queue();
queueRef.pushTwo( queueRef.push(transactionHash);
transactionHash, queueRef.push(timestampAndBlockNumber);
timestampAndBlockNumber
);
// The underlying queue data structure stores 2 elements // The underlying queue data structure stores 2 elements
// per insertion, so to get the real queue length we need // per insertion, so to get the real queue length we need
// to divide by 2 and subtract 1. See the usage of `pushTwo(..)`. // to divide by 2 and subtract 1.
uint256 queueIndex = queueRef.length() / 2 - 1; uint256 queueIndex = queueRef.length() / 2 - 1;
emit TransactionEnqueued( emit TransactionEnqueued(
msg.sender, msg.sender,
...@@ -751,11 +749,10 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -751,11 +749,10 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
{ {
// The underlying queue data structure stores 2 elements // The underlying queue data structure stores 2 elements
// per insertion, so to get the actual desired queue index // per insertion, so to get the actual desired queue index
// we need to multiply by 2. See the usage of `pushTwo(..)`. // we need to multiply by 2.
( uint40 trueIndex = uint40(_index * 2);
bytes32 transactionHash, bytes32 transactionHash = _queueRef.get(trueIndex);
bytes32 timestampAndBlockNumber bytes32 timestampAndBlockNumber = _queueRef.get(trueIndex + 1);
) = _queueRef.getTwo(uint40(_index * 2));
uint40 elementTimestamp; uint40 elementTimestamp;
uint40 elementBlockNumber; uint40 elementBlockNumber;
...@@ -786,7 +783,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -786,7 +783,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
{ {
// The underlying queue data structure stores 2 elements // The underlying queue data structure stores 2 elements
// per insertion, so to get the real queue length we need // per insertion, so to get the real queue length we need
// to divide by 2. See the usage of `pushTwo(..)`. // to divide by 2.
return uint40(_queueRef.length() / 2); return uint40(_queueRef.length() / 2);
} }
......
...@@ -142,35 +142,6 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes ...@@ -142,35 +142,6 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes
buffer.push(_object, _globalMetadata); buffer.push(_object, _globalMetadata);
} }
/**
* @inheritdoc iOVM_ChainStorageContainer
*/
function pushTwo(
bytes32 _objectA,
bytes32 _objectB
)
override
public
onlyOwner
{
buffer.pushTwo(_objectA, _objectB);
}
/**
* @inheritdoc iOVM_ChainStorageContainer
*/
function pushTwo(
bytes32 _objectA,
bytes32 _objectB,
bytes27 _globalMetadata
)
override
public
onlyOwner
{
buffer.pushTwo(_objectA, _objectB, _globalMetadata);
}
/** /**
* @inheritdoc iOVM_ChainStorageContainer * @inheritdoc iOVM_ChainStorageContainer
*/ */
...@@ -186,23 +157,6 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes ...@@ -186,23 +157,6 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes
{ {
return buffer.get(uint40(_index)); return buffer.get(uint40(_index));
} }
/**
* @inheritdoc iOVM_ChainStorageContainer
*/
function getTwo(
uint256 _index
)
override
public
view
returns (
bytes32,
bytes32
)
{
return buffer.getTwo(uint40(_index));
}
/** /**
* @inheritdoc iOVM_ChainStorageContainer * @inheritdoc iOVM_ChainStorageContainer
......
...@@ -65,31 +65,6 @@ interface iOVM_ChainStorageContainer { ...@@ -65,31 +65,6 @@ interface iOVM_ChainStorageContainer {
) )
external; external;
/**
* Pushes two objects into the container at the same time. A useful optimization.
* @param _objectA First 32 byte value to insert into the container.
* @param _objectB Second 32 byte value to insert into the container.
*/
function pushTwo(
bytes32 _objectA,
bytes32 _objectB
)
external;
/**
* Pushes two objects into the container at the same time. Also allows setting the global
* metadata field.
* @param _objectA First 32 byte value to insert into the container.
* @param _objectB Second 32 byte value to insert into the container.
* @param _globalMetadata New global metadata for the container.
*/
function pushTwo(
bytes32 _objectA,
bytes32 _objectB,
bytes27 _globalMetadata
)
external;
/** /**
* Retrieves an object from the container. * Retrieves an object from the container.
* @param _index Index of the particular object to access. * @param _index Index of the particular object to access.
...@@ -104,22 +79,6 @@ interface iOVM_ChainStorageContainer { ...@@ -104,22 +79,6 @@ interface iOVM_ChainStorageContainer {
bytes32 bytes32
); );
/**
* Retrieves two consecutive objects from the container.
* @param _index Index of the particular objects to access.
* @return 32 byte object value at index `_index`.
* @return 32 byte object value at index `_index + 1`.
*/
function getTwo(
uint256 _index
)
external
view
returns (
bytes32,
bytes32
);
/** /**
* Removes all objects after and including a given index. * Removes all objects after and including a given index.
* @param _index Object index to delete from. * @param _index Object index to delete from.
......
...@@ -111,47 +111,6 @@ library Lib_RingBuffer { ...@@ -111,47 +111,6 @@ library Lib_RingBuffer {
); );
} }
/**
* Pushes a two elements to the buffer.
* @param _self Buffer to access.
* @param _valueA First value to push to the buffer.
* @param _valueA Second value to push to the buffer.
* @param _extraData Optional global extra data.
*/
function pushTwo(
RingBuffer storage _self,
bytes32 _valueA,
bytes32 _valueB,
bytes27 _extraData
)
internal
{
_self.push(_valueA, _extraData);
_self.push(_valueB, _extraData);
}
/**
* Pushes a two elements to the buffer.
* @param _self Buffer to access.
* @param _valueA First value to push to the buffer.
* @param _valueA Second value to push to the buffer.
*/
function pushTwo(
RingBuffer storage _self,
bytes32 _valueA,
bytes32 _valueB
)
internal
{
RingBufferContext memory ctx = _self.getContext();
_self.pushTwo(
_valueA,
_valueB,
ctx.extraData
);
}
/** /**
* Retrieves an element from the buffer. * Retrieves an element from the buffer.
* @param _self Buffer to access. * @param _self Buffer to access.
...@@ -211,30 +170,6 @@ library Lib_RingBuffer { ...@@ -211,30 +170,6 @@ library Lib_RingBuffer {
} }
} }
/**
* Retrieves two consecutive elements from the buffer.
* @param _self Buffer to access.
* @param _index Element index to retrieve.
* @return Value of the element at index `_index`.
* @return Value of the element at index `_index + 1`.
*/
function getTwo(
RingBuffer storage _self,
uint256 _index
)
internal
view
returns (
bytes32,
bytes32
)
{
return (
_self.get(_index),
_self.get(_index + 1)
);
}
/** /**
* Deletes all elements after (and including) a given index. * Deletes all elements after (and including) a given index.
* @param _self Buffer to access. * @param _self Buffer to access.
......
...@@ -25,20 +25,6 @@ contract TestLib_RingBuffer { ...@@ -25,20 +25,6 @@ contract TestLib_RingBuffer {
); );
} }
function pushTwo(
bytes32 _valueA,
bytes32 _valueB,
bytes27 _extraData
)
public
{
buf.pushTwo(
_valueA,
_valueB,
_extraData
);
}
function get( function get(
uint256 _index uint256 _index
) )
......
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