forked from LBRYCommunity/lbry-sdk
regenerate protobufs
This commit is contained in:
parent
86cedfe8b2
commit
a01b52421e
2 changed files with 23 additions and 47 deletions
|
@ -44,15 +44,15 @@ class Censor:
|
||||||
for channel_hash, count in self.blocked_claims.items():
|
for channel_hash, count in self.blocked_claims.items():
|
||||||
block = outputs.blocked.add()
|
block = outputs.blocked.add()
|
||||||
block.count = count
|
block.count = count
|
||||||
block.ban_channel = channel_hash
|
block.reposted_in_channel = channel_hash
|
||||||
for channel_hash, count in self.blocked_channels.items():
|
for channel_hash, count in self.blocked_channels.items():
|
||||||
block = outputs.blocked.add()
|
block = outputs.blocked.add()
|
||||||
block.count = count
|
block.count = count
|
||||||
block.not_channel = channel_hash
|
block.in_channel = channel_hash
|
||||||
for tag, count in self.blocked_tags.items():
|
for tag, count in self.blocked_tags.items():
|
||||||
block = outputs.blocked.add()
|
block = outputs.blocked.add()
|
||||||
block.count = count
|
block.count = count
|
||||||
block.not_tag = tag
|
block.has_tag = tag
|
||||||
|
|
||||||
|
|
||||||
class Outputs:
|
class Outputs:
|
||||||
|
@ -74,7 +74,18 @@ class Outputs:
|
||||||
for txo_message in self.extra_txos:
|
for txo_message in self.extra_txos:
|
||||||
self.message_to_txo(txo_message, tx_map)
|
self.message_to_txo(txo_message, tx_map)
|
||||||
txos = [self.message_to_txo(txo_message, tx_map) for txo_message in self.txos]
|
txos = [self.message_to_txo(txo_message, tx_map) for txo_message in self.txos]
|
||||||
return txos, self.inflate_blocked(txs)
|
return txos, self.inflate_blocked()
|
||||||
|
|
||||||
|
def inflate_blocked(self):
|
||||||
|
result = {"total": self.blocked_total}
|
||||||
|
for blocked_message in self.blocked:
|
||||||
|
reason = blocked_message.WhichOneof('reason')
|
||||||
|
if reason == "has_tag":
|
||||||
|
key = blocked_message.has_tag
|
||||||
|
else:
|
||||||
|
key = hexlify(getattr(blocked_message, reason)[::-1]).decode()
|
||||||
|
result.setdefault(reason, {})[key] = blocked_message.count
|
||||||
|
return result
|
||||||
|
|
||||||
def message_to_txo(self, txo_message, tx_map):
|
def message_to_txo(self, txo_message, tx_map):
|
||||||
if txo_message.WhichOneof('meta') == 'error':
|
if txo_message.WhichOneof('meta') == 'error':
|
||||||
|
@ -109,41 +120,6 @@ class Outputs:
|
||||||
pass
|
pass
|
||||||
return txo
|
return txo
|
||||||
|
|
||||||
def inflate_blocked(self, txs):
|
|
||||||
blocked = {}
|
|
||||||
return
|
|
||||||
if txo_message.WhichOneof('meta') == 'error':
|
|
||||||
return None
|
|
||||||
txo = tx_map[txo_message.tx_hash].outputs[txo_message.nout]
|
|
||||||
if txo_message.WhichOneof('meta') == 'claim':
|
|
||||||
claim = txo_message.claim
|
|
||||||
txo.meta = {
|
|
||||||
'short_url': f'lbry://{claim.short_url}',
|
|
||||||
'canonical_url': f'lbry://{claim.canonical_url or claim.short_url}',
|
|
||||||
'reposted': claim.reposted,
|
|
||||||
'is_controlling': claim.is_controlling,
|
|
||||||
'take_over_height': claim.take_over_height,
|
|
||||||
'creation_height': claim.creation_height,
|
|
||||||
'activation_height': claim.activation_height,
|
|
||||||
'expiration_height': claim.expiration_height,
|
|
||||||
'effective_amount': claim.effective_amount,
|
|
||||||
'support_amount': claim.support_amount,
|
|
||||||
'trending_group': claim.trending_group,
|
|
||||||
'trending_mixed': claim.trending_mixed,
|
|
||||||
'trending_local': claim.trending_local,
|
|
||||||
'trending_global': claim.trending_global,
|
|
||||||
}
|
|
||||||
if claim.HasField('channel'):
|
|
||||||
txo.channel = tx_map[claim.channel.tx_hash].outputs[claim.channel.nout]
|
|
||||||
if claim.HasField('repost'):
|
|
||||||
txo.reposted_claim = tx_map[claim.repost.tx_hash].outputs[claim.repost.nout]
|
|
||||||
try:
|
|
||||||
if txo.claim.is_channel:
|
|
||||||
txo.meta['claims_in_channel'] = claim.claims_in_channel
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
return txo
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_base64(cls, data: str) -> 'Outputs':
|
def from_base64(cls, data: str) -> 'Outputs':
|
||||||
return cls.from_bytes(base64.b64decode(data))
|
return cls.from_bytes(base64.b64decode(data))
|
||||||
|
|
|
@ -19,7 +19,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
|
||||||
name='result.proto',
|
name='result.proto',
|
||||||
package='pb',
|
package='pb',
|
||||||
syntax='proto3',
|
syntax='proto3',
|
||||||
serialized_pb=_b('\n\x0cresult.proto\x12\x02pb\"\x97\x01\n\x07Outputs\x12\x18\n\x04txos\x18\x01 \x03(\x0b\x32\n.pb.Output\x12\x1e\n\nextra_txos\x18\x02 \x03(\x0b\x32\n.pb.Output\x12\x1c\n\x07\x62locked\x18\x03 \x03(\x0b\x32\x0b.pb.Blocked\x12\r\n\x05total\x18\x04 \x01(\r\x12\x0e\n\x06offset\x18\x05 \x01(\r\x12\x15\n\rblocked_total\x18\x06 \x01(\r\"{\n\x06Output\x12\x0f\n\x07tx_hash\x18\x01 \x01(\x0c\x12\x0c\n\x04nout\x18\x02 \x01(\r\x12\x0e\n\x06height\x18\x03 \x01(\r\x12\x1e\n\x05\x63laim\x18\x07 \x01(\x0b\x32\r.pb.ClaimMetaH\x00\x12\x1a\n\x05\x65rror\x18\x0f \x01(\x0b\x32\t.pb.ErrorH\x00\x42\x06\n\x04meta\"\xaf\x03\n\tClaimMeta\x12\x1b\n\x07\x63hannel\x18\x01 \x01(\x0b\x32\n.pb.Output\x12\x1a\n\x06repost\x18\x02 \x01(\x0b\x32\n.pb.Output\x12\x11\n\tshort_url\x18\x03 \x01(\t\x12\x15\n\rcanonical_url\x18\x04 \x01(\t\x12\x16\n\x0eis_controlling\x18\x05 \x01(\x08\x12\x18\n\x10take_over_height\x18\x06 \x01(\r\x12\x17\n\x0f\x63reation_height\x18\x07 \x01(\r\x12\x19\n\x11\x61\x63tivation_height\x18\x08 \x01(\r\x12\x19\n\x11\x65xpiration_height\x18\t \x01(\r\x12\x19\n\x11\x63laims_in_channel\x18\n \x01(\r\x12\x10\n\x08reposted\x18\x0b \x01(\r\x12\x18\n\x10\x65\x66\x66\x65\x63tive_amount\x18\x14 \x01(\x04\x12\x16\n\x0esupport_amount\x18\x15 \x01(\x04\x12\x16\n\x0etrending_group\x18\x16 \x01(\r\x12\x16\n\x0etrending_mixed\x18\x17 \x01(\x02\x12\x16\n\x0etrending_local\x18\x18 \x01(\x02\x12\x17\n\x0ftrending_global\x18\x19 \x01(\x02\"\x94\x01\n\x05\x45rror\x12\x1c\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x0e.pb.Error.Code\x12\x0c\n\x04text\x18\x02 \x01(\t\x12\x1c\n\x07\x62locked\x18\x03 \x01(\x0b\x32\x0b.pb.Blocked\"A\n\x04\x43ode\x12\x10\n\x0cUNKNOWN_CODE\x10\x00\x12\r\n\tNOT_FOUND\x10\x01\x12\x0b\n\x07INVALID\x10\x02\x12\x0b\n\x07\x42LOCKED\x10\x03\"j\n\x07\x42locked\x12\r\n\x05\x63ount\x18\x01 \x01(\r\x12\x1d\n\x13reposted_in_channel\x18\x02 \x01(\x0cH\x00\x12\x14\n\nin_channel\x18\x03 \x01(\x0cH\x00\x12\x11\n\x07has_tag\x18\x04 \x01(\tH\x00\x42\x08\n\x06reasonb\x06proto3')
|
serialized_pb=_b('\n\x0cresult.proto\x12\x02pb\"\x97\x01\n\x07Outputs\x12\x18\n\x04txos\x18\x01 \x03(\x0b\x32\n.pb.Output\x12\x1e\n\nextra_txos\x18\x02 \x03(\x0b\x32\n.pb.Output\x12\r\n\x05total\x18\x03 \x01(\r\x12\x0e\n\x06offset\x18\x04 \x01(\r\x12\x1c\n\x07\x62locked\x18\x05 \x03(\x0b\x32\x0b.pb.Blocked\x12\x15\n\rblocked_total\x18\x06 \x01(\r\"{\n\x06Output\x12\x0f\n\x07tx_hash\x18\x01 \x01(\x0c\x12\x0c\n\x04nout\x18\x02 \x01(\r\x12\x0e\n\x06height\x18\x03 \x01(\r\x12\x1e\n\x05\x63laim\x18\x07 \x01(\x0b\x32\r.pb.ClaimMetaH\x00\x12\x1a\n\x05\x65rror\x18\x0f \x01(\x0b\x32\t.pb.ErrorH\x00\x42\x06\n\x04meta\"\xaf\x03\n\tClaimMeta\x12\x1b\n\x07\x63hannel\x18\x01 \x01(\x0b\x32\n.pb.Output\x12\x1a\n\x06repost\x18\x02 \x01(\x0b\x32\n.pb.Output\x12\x11\n\tshort_url\x18\x03 \x01(\t\x12\x15\n\rcanonical_url\x18\x04 \x01(\t\x12\x16\n\x0eis_controlling\x18\x05 \x01(\x08\x12\x18\n\x10take_over_height\x18\x06 \x01(\r\x12\x17\n\x0f\x63reation_height\x18\x07 \x01(\r\x12\x19\n\x11\x61\x63tivation_height\x18\x08 \x01(\r\x12\x19\n\x11\x65xpiration_height\x18\t \x01(\r\x12\x19\n\x11\x63laims_in_channel\x18\n \x01(\r\x12\x10\n\x08reposted\x18\x0b \x01(\r\x12\x18\n\x10\x65\x66\x66\x65\x63tive_amount\x18\x14 \x01(\x04\x12\x16\n\x0esupport_amount\x18\x15 \x01(\x04\x12\x16\n\x0etrending_group\x18\x16 \x01(\r\x12\x16\n\x0etrending_mixed\x18\x17 \x01(\x02\x12\x16\n\x0etrending_local\x18\x18 \x01(\x02\x12\x17\n\x0ftrending_global\x18\x19 \x01(\x02\"\x94\x01\n\x05\x45rror\x12\x1c\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x0e.pb.Error.Code\x12\x0c\n\x04text\x18\x02 \x01(\t\x12\x1c\n\x07\x62locked\x18\x03 \x01(\x0b\x32\x0b.pb.Blocked\"A\n\x04\x43ode\x12\x10\n\x0cUNKNOWN_CODE\x10\x00\x12\r\n\tNOT_FOUND\x10\x01\x12\x0b\n\x07INVALID\x10\x02\x12\x0b\n\x07\x42LOCKED\x10\x03\"j\n\x07\x42locked\x12\r\n\x05\x63ount\x18\x01 \x01(\r\x12\x1d\n\x13reposted_in_channel\x18\x02 \x01(\x0cH\x00\x12\x14\n\nin_channel\x18\x03 \x01(\x0cH\x00\x12\x11\n\x07has_tag\x18\x04 \x01(\tH\x00\x42\x08\n\x06reasonb\x06proto3')
|
||||||
)
|
)
|
||||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||||
|
|
||||||
|
@ -78,23 +78,23 @@ _OUTPUTS = _descriptor.Descriptor(
|
||||||
is_extension=False, extension_scope=None,
|
is_extension=False, extension_scope=None,
|
||||||
options=None),
|
options=None),
|
||||||
_descriptor.FieldDescriptor(
|
_descriptor.FieldDescriptor(
|
||||||
name='blocked', full_name='pb.Outputs.blocked', index=2,
|
name='total', full_name='pb.Outputs.total', index=2,
|
||||||
number=3, type=11, cpp_type=10, label=3,
|
number=3, type=13, cpp_type=3, label=1,
|
||||||
has_default_value=False, default_value=[],
|
has_default_value=False, default_value=0,
|
||||||
message_type=None, enum_type=None, containing_type=None,
|
message_type=None, enum_type=None, containing_type=None,
|
||||||
is_extension=False, extension_scope=None,
|
is_extension=False, extension_scope=None,
|
||||||
options=None),
|
options=None),
|
||||||
_descriptor.FieldDescriptor(
|
_descriptor.FieldDescriptor(
|
||||||
name='total', full_name='pb.Outputs.total', index=3,
|
name='offset', full_name='pb.Outputs.offset', index=3,
|
||||||
number=4, type=13, cpp_type=3, label=1,
|
number=4, type=13, cpp_type=3, label=1,
|
||||||
has_default_value=False, default_value=0,
|
has_default_value=False, default_value=0,
|
||||||
message_type=None, enum_type=None, containing_type=None,
|
message_type=None, enum_type=None, containing_type=None,
|
||||||
is_extension=False, extension_scope=None,
|
is_extension=False, extension_scope=None,
|
||||||
options=None),
|
options=None),
|
||||||
_descriptor.FieldDescriptor(
|
_descriptor.FieldDescriptor(
|
||||||
name='offset', full_name='pb.Outputs.offset', index=4,
|
name='blocked', full_name='pb.Outputs.blocked', index=4,
|
||||||
number=5, type=13, cpp_type=3, label=1,
|
number=5, type=11, cpp_type=10, label=3,
|
||||||
has_default_value=False, default_value=0,
|
has_default_value=False, default_value=[],
|
||||||
message_type=None, enum_type=None, containing_type=None,
|
message_type=None, enum_type=None, containing_type=None,
|
||||||
is_extension=False, extension_scope=None,
|
is_extension=False, extension_scope=None,
|
||||||
options=None),
|
options=None),
|
||||||
|
|
Loading…
Reference in a new issue