-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V2 migration #655
Open
emmanueldenloye
wants to merge
16
commits into
develop
Choose a base branch
from
emmanuel/frontend-migration
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
V2 migration #655
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
40ff87e
init commit
emmanueldenloye 72e76f3
1st cut of migration
emmanueldenloye b837e7b
compose migrations
emmanueldenloye ac59840
bump version on restoreBackup
emmanueldenloye 1d53d87
don't care about power users
emmanueldenloye eaa6f84
add V1->V2 test, fix V0->V2 test
emmanueldenloye 10051b8
actually run both upgrade tests
emmanueldenloye 40ced78
mocking new test cases
emmanueldenloye 1b59cc9
add OverloadedStrings pragma
emmanueldenloye 17588f2
finished previously mocked tests (last commit)
emmanueldenloye 1594e25
take out unnecessary MonadIO constraints
emmanueldenloye a5c3e57
unconditionally alter refs for networks in local storage
emmanueldenloye 712eb9d
create simplified version of "These" (Cheese)
emmanueldenloye 5167b87
Use an even simpler datatype for processing the map merge
emmanueldenloye e5d7d24
another simple refactor
emmanueldenloye 84eaa4b
for JM
emmanueldenloye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,32 +153,37 @@ fromMultiSet = ($ []) . Map.foldrWithKey (\k i -> (.) (dlrep k i)) id | |
| n == 0 = id | ||
| otherwise = (v:) . dlrep v (n - 1) | ||
|
||
data Cheese a b = That b | These a b | ||
|
||
instance Functor (Cheese a) where | ||
fmap f (That b) = That (f b) | ||
fmap f (These a b) = These a (f b) | ||
|
||
instance (Semigroup a) => Applicative (Cheese a) where | ||
pure = That | ||
That f <*> That x = That (f x) | ||
That f <*> These b x = These b (f x) | ||
These a f <*> That x = These a (f x) | ||
These a f <*> These b x = These (a <> b) (f x) | ||
-- It is equivalent to "These () a" except that we take out the | ||
-- "This" constructor. With it gone, we still get the same applicative | ||
-- operations from "These" (sans "This") but we don't have to account for | ||
-- the "This" constructor in situations where we know it is impossible to | ||
-- produce it. This is also morally equivalent to Either () b with a | ||
-- different applicative instance | ||
data Deez b = Dis b | Dat b | ||
|
||
instance Functor Deez where | ||
fmap f (Dis b) = Dis (f b) | ||
fmap f (Dat b) = Dat (f b) | ||
|
||
instance Applicative Deez where | ||
pure = Dis | ||
Dis f <*> Dis x = Dis (f x) | ||
Dis f <*> Dat x = Dat (f x) | ||
Dat f <*> Dis x = Dat (f x) | ||
Dat f <*> Dat x = Dat (f x) | ||
|
||
convertNodeRefs :: Map NetworkName [NodeRef] -> Map NetworkName [NodeRef] | ||
convertNodeRefs = fmap migrate | ||
where | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the nested |
||
migrate = replaceRefsWith "api.chainweb.com" mainnetNodeRefs . replaceRefsWith "api.testnet.chainweb.com" testnetNodeRefs | ||
where | ||
replaceRefsWith ref baseRefs refs = | ||
refs | ||
& on (Map.mergeA Map.dropMissing Map.preserveMissing (Map.zipWithMaybeAMatched (\_ _ _ -> These () Nothing))) toMultiSet baseRefs | ||
& \case | ||
That m -> m | ||
These () m -> addRef ref m -- if we hit this case, there were matching keys | ||
& fromMultiSet | ||
addRef (unsafeParseNodeRef -> ref) = Map.insert ref 1 | ||
replaceRefsWith ref baseRefs refs = | ||
refs | ||
& on (Map.mergeA Map.dropMissing Map.preserveMissing (Map.zipWithMaybeAMatched (\_ _ _ -> Dat Nothing))) toMultiSet baseRefs | ||
& \case | ||
Dis m -> m | ||
Dat m -> addRef ref m -- if we hit this case, there were matching keys | ||
& fromMultiSet | ||
addRef (unsafeParseNodeRef -> ref) = Map.insert ref 1 | ||
testnetNodeRefs = unsafeParseNodeRef <$> | ||
[ "us1.testnet.chainweb.com" | ||
, "us2.testnet.chainweb.com" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slightly misleading comment.
But
and
You want a newtype for
Either a a
here to get the modifiedApplicative
.