From 3c7423eabf7beb56631501103acd6a0a521f5833 Mon Sep 17 00:00:00 2001 From: cyhhao Date: Sat, 18 Feb 2023 21:09:37 +0800 Subject: [PATCH] add batch upload function --- contracts/SLI/Git3Hub.sol | 13 +++++++++++++ scripts/deploy-sli.ts | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/contracts/SLI/Git3Hub.sol b/contracts/SLI/Git3Hub.sol index 4d1e0a3..f496811 100644 --- a/contracts/SLI/Git3Hub.sol +++ b/contracts/SLI/Git3Hub.sol @@ -64,6 +64,19 @@ contract Git3Hub_SLI is Git3HubStorage_SLI { pathToHash[keccak256(bytes.concat(repoName, "/", path))] = data; } + function batchUpload( + bytes memory repoName, + bytes[] memory path, + bytes[] calldata data + ) external payable onlyOwner(repoName) { + require(path.length == data.length, "path and data length mismatch"); + for (uint i = 0; i < path.length; i++) { + pathToHash[keccak256(bytes.concat(repoName, "/", path[i]))] = data[ + i + ]; + } + } + function remove( bytes memory repoName, bytes memory path diff --git a/scripts/deploy-sli.ts b/scripts/deploy-sli.ts index 346a4d4..3f74174 100644 --- a/scripts/deploy-sli.ts +++ b/scripts/deploy-sli.ts @@ -16,7 +16,6 @@ async function main() { type: 2, maxFeePerGas: price.maxFeePerGas!, maxPriorityFeePerGas: price.maxPriorityFeePerGas!, - gasLimit: 3000000, }); let logicReceipt = await git3.deployed();