-
Notifications
You must be signed in to change notification settings - Fork 43
fix process_piece_deal multiples #925
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
Open
snadrus
wants to merge
4
commits into
main
Choose a base branch
from
fix-index-err
base: main
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
Changes from 1 commit
Commits
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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,53 @@ | ||
| DO $$ | ||
| DECLARE | ||
| r record; | ||
| BEGIN | ||
| FOR r IN | ||
| SELECT | ||
| p.oid::regprocedure AS sig | ||
| FROM pg_proc p | ||
| JOIN pg_namespace n ON n.oid = p.pronamespace | ||
| WHERE n.nspname = 'curio' | ||
| AND p.proname = 'process_piece_deal' | ||
| LOOP | ||
| EXECUTE format('DROP FUNCTION %s;', r.sig); | ||
| END LOOP; | ||
| END | ||
| $$; | ||
|
|
||
| CREATE OR REPLACE FUNCTION process_piece_deal( | ||
| _id TEXT, | ||
| _piece_cid TEXT, | ||
| _boost_deal BOOLEAN, | ||
| _sp_id BIGINT, | ||
| _sector_num BIGINT, | ||
| _piece_offset BIGINT, | ||
| _piece_length BIGINT, -- padded length | ||
| _raw_size BIGINT, | ||
| _indexed BOOLEAN, | ||
| _piece_ref BIGINT DEFAULT NULL, | ||
| _legacy_deal BOOLEAN DEFAULT FALSE, | ||
| _chain_deal_id BIGINT DEFAULT 0 | ||
| ) | ||
| RETURNS VOID AS $$ | ||
| BEGIN | ||
| -- Insert or update the market_piece_metadata table | ||
| INSERT INTO market_piece_metadata (piece_cid, piece_size, indexed) | ||
| VALUES (_piece_cid, _piece_length, _indexed) | ||
| ON CONFLICT (piece_cid, piece_size) DO UPDATE SET | ||
| indexed = CASE | ||
| WHEN market_piece_metadata.indexed = FALSE THEN EXCLUDED.indexed | ||
| ELSE market_piece_metadata.indexed | ||
| END; | ||
|
|
||
| -- Insert into the market_piece_deal table | ||
| INSERT INTO market_piece_deal ( | ||
| id, piece_cid, boost_deal, legacy_deal, chain_deal_id, | ||
| sp_id, sector_num, piece_offset, piece_length, raw_size, piece_ref | ||
| ) VALUES ( | ||
| _id, _piece_cid, _boost_deal, _legacy_deal, _chain_deal_id, | ||
| _sp_id, _sector_num, _piece_offset, _piece_length, _raw_size, _piece_ref | ||
| ) ON CONFLICT (id, sp_id, piece_cid, piece_length) DO NOTHING; | ||
|
|
||
| END; | ||
| $$ LANGUAGE plpgsql; | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.