fix: controlling and channel claim count meta

Controlling means controlling claims, not channels. Added so we only return claims with valid signatures (safer for now, can add options to show invalid later). Also, the claim count in channel is in the signed channel meta object, not the high level one.
This commit is contained in:
Thomas Zarebczan 2019-06-11 12:22:44 -04:00
parent 157711207b
commit c73ea00941
3 changed files with 19 additions and 17 deletions

26
dist/bundle.es.js vendored
View file

@ -1997,7 +1997,7 @@ function doResolveUris(uris, returnCachedClaims = false) {
result.stream = uriResolveInfo; result.stream = uriResolveInfo;
if (uriResolveInfo.signing_channel) { if (uriResolveInfo.signing_channel) {
result.channel = uriResolveInfo.signing_channel; result.channel = uriResolveInfo.signing_channel;
result.claimsInChannel = uriResolveInfo.signing_channel.meta.claims_in_channel; result.claimsInChannel = uriResolveInfo.signing_channel.meta && uriResolveInfo.signing_channel.meta.claims_in_channel || 0;
} }
} }
@ -2117,7 +2117,12 @@ function doFetchClaimsByChannel(uri, page = 1) {
data: { uri, page } data: { uri, page }
}); });
lbryProxy.claim_search({ channel: uri, is_controlling: true, page: page || 1, order_by: ['release_time'] }).then(result => { lbryProxy.claim_search({
channel: uri,
valid_channel_signatures: true,
page: page || 1,
order_by: ['release_time']
}).then(result => {
const { items: claimsInChannel, page: returnedPage } = result; const { items: claimsInChannel, page: returnedPage } = result;
dispatch({ dispatch({
@ -2738,20 +2743,15 @@ reducers[RESOLVE_URIS_COMPLETED] = (state, action) => {
// $FlowFixMe // $FlowFixMe
Object.entries(resolveInfo).forEach(([uri, { channel, stream }]) => { Object.entries(resolveInfo).forEach(([uri, { channel, stream }]) => {
if (stream && !channel) { if (stream) {
byId[stream.claim_id] = stream; byId[stream.claim_id] = stream;
byUri[uri] = stream.claim_id; byUri[uri] = stream.claim_id;
} else if (stream && channel) { }
byId[stream.claim_id] = stream; if (channel) {
byUri[uri] = stream.claim_id;
byId[channel.claim_id] = channel; byId[channel.claim_id] = channel;
const channelUri = channel.permanent_url; byUri[stream ? channel.permanent_url : uri] = channel.claim_id;
byUri[channelUri] = channel.claim_id; }
} else if (!stream && channel) { if (!stream && !channel) {
byId[channel.claim_id] = channel;
byUri[uri] = channel.claim_id;
} else {
byUri[uri] = null; byUri[uri] = null;
} }
}); });

View file

@ -4,13 +4,13 @@ declare type Claim = StreamClaim | ChannelClaim;
declare type ChannelClaim = GenericClaim & { declare type ChannelClaim = GenericClaim & {
is_channel_signature_valid?: boolean, // we may have signed channels in the future, fixes some flow issues for now. is_channel_signature_valid?: boolean, // we may have signed channels in the future, fixes some flow issues for now.
signing_channel?: ChannelMetadata, signing_channel?: ChannelClaim,
value: ChannelMetadata, value: ChannelMetadata,
}; };
declare type StreamClaim = GenericClaim & { declare type StreamClaim = GenericClaim & {
is_channel_signature_valid?: boolean, is_channel_signature_valid?: boolean,
signing_channel?: ChannelMetadata, signing_channel?: ChannelClaim,
value: StreamMetadata, value: StreamMetadata,
}; };

View file

@ -64,7 +64,9 @@ export function doResolveUris(uris: Array<string>, returnCachedClaims: boolean =
if (uriResolveInfo.signing_channel) { if (uriResolveInfo.signing_channel) {
result.channel = uriResolveInfo.signing_channel; result.channel = uriResolveInfo.signing_channel;
result.claimsInChannel = result.claimsInChannel =
(uriResolveInfo.meta && uriResolveInfo.meta.claims_in_channel) || 0; (uriResolveInfo.signing_channel.meta &&
uriResolveInfo.signing_channel.meta.claims_in_channel) ||
0;
} }
} }
@ -198,7 +200,7 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1) {
Lbry.claim_search({ Lbry.claim_search({
channel: uri, channel: uri,
is_controlling: true, valid_channel_signatures: true,
page: page || 1, page: page || 1,
order_by: ['release_time'], order_by: ['release_time'],
}).then((result: ClaimSearchResponse) => { }).then((result: ClaimSearchResponse) => {