Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
d4389749
Commit
d4389749
authored
Dec 05, 2023
by
pcw109550
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-chain-ops: Apply Delta checker bash script suggestions
parent
406c2ca9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
check-delta.sh
op-chain-ops/cmd/check-delta/check-delta.sh
+16
-3
No files found.
op-chain-ops/cmd/check-delta/check-delta.sh
View file @
d4389749
#!/bin/bash
#!/bin/bash
set
-uo
pipefail
# Check if a directory path is provided
# Check if a directory path is provided
# Directory must contain the output of batch_decoder's reassemble command
# Directory must contain the output of batch_decoder's reassemble command
if
[
-z
"
$
1
"
]
;
then
if
[
-z
"
$
{
1
:-}
"
]
;
then
echo
"Usage:
$0
/path/to/directory"
echo
"Usage:
$0
/path/to/directory"
exit
1
exit
1
fi
fi
# Check if jq is installed
if
!
command
-v
jq &> /dev/null
;
then
echo
"Error: jq is not installed"
exit
1
fi
directory_path
=
$1
directory_path
=
$1
# Check if directory exists and is not empty
if
[
!
-d
"
$directory_path
"
]
||
[
-z
"
$(
ls
-A
"
$directory_path
"
)
"
]
;
then
echo
"Error: Directory does not exist or is empty"
exit
1
fi
valid_count
=
0
valid_count
=
0
invalid_count
=
0
invalid_count
=
0
invalid_channels
=()
invalid_channels
=()
...
@@ -16,10 +28,11 @@ invalid_channels=()
...
@@ -16,10 +28,11 @@ invalid_channels=()
for
file
in
"
$directory_path
"
/
*
.json
;
do
for
file
in
"
$directory_path
"
/
*
.json
;
do
# If channel is ready, all batches must valid.
# If channel is ready, all batches must valid.
# If delta is activated, all batch types must be span batch.
# If delta is activated, all batch types must be span batch.
result
=
$(
jq
'if .is_ready then (.invalid_batches == false and all(.batch_types[]; . == 1)) else empty end'
"
$file
"
)
result
=
$(
jq
'if .is_ready then (.invalid_batches == false and all(.batch_types[]; . == 1)) else empty end'
"
$file
"
2>&1
)
if
[[
$result
==
"true"
]]
;
then
if
[[
$result
==
"true"
]]
;
then
((
valid_count++
))
((
valid_count++
))
elif
[[
$result
==
"false"
]]
;
then
else
# supplied json is invalid or does not satisfy condition
((
invalid_count++
))
((
invalid_count++
))
invalid_channels+
=(
"
$file
"
)
invalid_channels+
=(
"
$file
"
)
fi
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment