-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: alternative script for generating indexing rules
- Loading branch information
Showing
9 changed files
with
181 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module CLI | ||
using Formatting | ||
include("action.jl") | ||
|
||
function reallocate_actions( | ||
proposed_ipfs::Vector{T}, | ||
existing_ipfs::Vector{T}, | ||
proposed_allocations::Dict{T,<:Real}, | ||
existing_allocations::Dict{T,T}, | ||
) where {T<:AbstractString} | ||
ipfses = reallocate_ipfs(existing_ipfs, proposed_ipfs) | ||
actions = map( | ||
ipfs -> | ||
"\e[0mgraph indexer rules stop $(ipfs)\n\e[1m\e[38;2;255;0;0;249mCheck before submitting: \e[0mgraph indexer rules set $(ipfs) decisionBasis always allocationAmount $(format(proposed_allocations[ipfs]))", | ||
ipfses, | ||
) | ||
return actions, ipfses | ||
end | ||
|
||
function allocate_actions( | ||
proposed_ipfs::Vector{T}, | ||
reallocate_ipfs::Vector{T}, | ||
proposed_allocations::Dict{T,<:Real}, | ||
) where {T<:AbstractString} | ||
ipfses = open_ipfs(proposed_ipfs, reallocate_ipfs) | ||
actions = map( | ||
ipfs -> | ||
"\e[0mgraph indexer rules set $(ipfs) decisionBasis always allocationAmount $(format(proposed_allocations[ipfs]))", | ||
ipfses, | ||
) | ||
return actions, ipfses | ||
end | ||
|
||
function unallocate_actions( | ||
existing_ipfs::Vector{T}, reallocate_ipfs::Vector{T}, frozenlist::Vector{T} | ||
) where {T<:AbstractString} | ||
ipfses = setdiff(setdiff(existing_ipfs, reallocate_ipfs), frozenlist) | ||
actions = map(ipfs -> "\e[0mgraph indexer rules stop $(ipfs)", ipfses) | ||
return actions, ipfses | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function reallocate_ipfs( | ||
existing_ipfs::Vector{T}, proposed_ipfs::Vector{T} | ||
) where {T<:AbstractString} | ||
return existing_ipfs ∩ proposed_ipfs | ||
end | ||
function open_ipfs( | ||
proposed_ipfs::Vector{T}, reallocate_ipfs::Vector{T} | ||
) where {T<:AbstractString} | ||
return setdiff(proposed_ipfs, reallocate_ipfs) | ||
end | ||
function close_ipfs( | ||
existing_ipfs::Vector{T}, reallocate_ipfs::Vector{T}, frozenlist::Vector{T} | ||
) where {T<:AbstractString} | ||
return setdiff(setdiff(existing_ipfs, reallocate_ipfs), frozenlist) | ||
end |