optimize Git3HubStorage

main
cyl19970726 2 years ago
parent 547491ab96
commit 2c91e456c2

@ -5,23 +5,7 @@ pragma solidity ^0.8.0;
// import "@openzeppelin/contracts/access/Ownable.sol";
import "./v2/LargeStorageManagerV2.sol";
contract Git3HubStorage {
struct refInfo {
bytes20 hash;
uint96 index;
}
struct refData {
bytes20 hash;
bytes name;
}
mapping(bytes => address) public repoNameToOwner;
mapping(bytes => refInfo) public nameToRefInfo; // dev => {hash: 0x1234..., index: 1 }
mapping(bytes => bytes[]) public repoNameToRefs; // [main, dev, test, staging]
}
contract Git3Hub is Git3HubStorage, LargeStorageManagerV2 {
contract Git3Hub is LargeStorageManagerV2 {
event RepoCreated(bytes repoName, address owner);
event RepoOwnerTransfer(bytes repoName, address oldOwner, address newOwner);
event PushRef(bytes repoName, bytes ref);

@ -0,0 +1,23 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
contract Git3HubStorage {
struct refInfo {
bytes20 hash;
uint96 index;
}
struct refData {
bytes20 hash;
bytes name;
}
// LargeStorageManagerV2 Storage Layout
mapping(bytes32 => mapping(uint256 => bytes32)) internal keyToMetadata;
mapping(bytes32 => mapping(uint256 => mapping(uint256 => bytes32)))
internal keyToSlots;
// Git3Hub Storage Layout
mapping(bytes => address) public repoNameToOwner;
mapping(bytes => refInfo) public nameToRefInfo; // dev => {hash: 0x1234..., index: 1 }
mapping(bytes => bytes[]) public repoNameToRefs; // [main, dev, test, staging]
}

@ -4,19 +4,16 @@ pragma solidity ^0.8.0;
import "./optimize/SlotHelper.sol";
import "./StorageHelperV2.sol";
import "./StorageSlotSelfDestructableV2.sol";
import "../Git3HubStorage.sol";
// Large storage manager to support arbitrarily-sized data with multiple chunk
contract LargeStorageManagerV2 {
contract LargeStorageManagerV2 is Git3HubStorage {
using SlotHelper for bytes32;
using SlotHelper for address;
uint8 internal constant SLOT_LIMIT = 0;
mapping(bytes32 => mapping(uint256 => bytes32)) internal keyToMetadata;
mapping(bytes32 => mapping(uint256 => mapping(uint256 => bytes32)))
internal keyToSlots;
function isOptimize() public view returns (bool) {
function isOptimize() public pure returns (bool) {
return SLOT_LIMIT > 0;
}

Loading…
Cancel
Save