Skip to content

Commit

Permalink
Remove unnecessary magic checks
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Feb 7, 2025
1 parent fc69e70 commit 74beae2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions backend/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ export default async () => {
// Remember to keep these values up-to-date.
const HASH_LENGTH = 56

const CONTRACT_MANIFEST_MAGIC = '{"head":"{\\"manifestVersion\\"'
const CONTRACT_SOURCE_MAGIC = '"use strict";'
// Preload contract source files and contract manifests into Chelonia DB.
// Note: the data folder may contain other files if the `fs` persistence mode
// has been used before. We won't load them here; that's the job of `chel migrate`.
Expand All @@ -202,8 +200,8 @@ export default async () => {
const value = await readFile(path.join(dataFolder, key), 'utf8')
// Load only contract source files and contract manifests.
if (
(CONTRACT_MANIFEST_REGEX.test(key) && value.startsWith(CONTRACT_MANIFEST_MAGIC)) ||
(CONTRACT_SOURCE_REGEX.test(key) && value.startsWith(CONTRACT_SOURCE_MAGIC))
CONTRACT_MANIFEST_REGEX.test(key) ||
CONTRACT_SOURCE_REGEX.test(key)
) {
await sbp('chelonia/db/set', key, value)
numNewKeys++
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 74beae2

Please sign in to comment.