mirror of
https://github.com/LBRYFoundation/herald.go.git
synced 2025-08-29 08:21:24 +00:00
make record -> output it's own function
This commit is contained in:
parent
2c83e451b4
commit
acf7ce671d
1 changed files with 31 additions and 31 deletions
|
@ -462,32 +462,7 @@ func (s *Server) Search(ctx context.Context, in *pb.SearchRequest) (*pb.Outputs,
|
||||||
var j = 0
|
var j = 0
|
||||||
for i := from; i < from + finalLength && i < len(records) && j < finalLength; i++ {
|
for i := from; i < from + finalLength && i < len(records) && j < finalLength; i++ {
|
||||||
t := records[i]
|
t := records[i]
|
||||||
res := &pb.Output{
|
res := t.recordToOutput()
|
||||||
TxHash: util.ToHash(t.Txid),
|
|
||||||
Nout: t.Nout,
|
|
||||||
Height: t.Height,
|
|
||||||
Meta: &pb.Output_Claim{
|
|
||||||
Claim: &pb.ClaimMeta{
|
|
||||||
//Channel:
|
|
||||||
//Repost:
|
|
||||||
ShortUrl: t.ShortUrl,
|
|
||||||
CanonicalUrl: t.CanonicalUrl,
|
|
||||||
IsControlling: t.IsControlling,
|
|
||||||
TakeOverHeight: t.TakeOverHeight,
|
|
||||||
CreationHeight: t.CreationHeight,
|
|
||||||
ActivationHeight: t.ActivationHeight,
|
|
||||||
ExpirationHeight: t.ExpirationHeight,
|
|
||||||
ClaimsInChannel: t.ClaimsInChannel,
|
|
||||||
Reposted: t.Reposted,
|
|
||||||
EffectiveAmount: t.EffectiveAmount,
|
|
||||||
SupportAmount: t.SupportAmount,
|
|
||||||
TrendingGroup: t.TrendingGroup,
|
|
||||||
TrendingMixed: t.TrendingMixed,
|
|
||||||
TrendingLocal: t.TrendingLocal,
|
|
||||||
TrendingGlobal: t.TrendingGlobal,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
txos = append(txos, res)
|
txos = append(txos, res)
|
||||||
j += 1
|
j += 1
|
||||||
}
|
}
|
||||||
|
@ -586,6 +561,35 @@ func searchAhead(searchHits []*record, pageSize int, perChannelPerPage int) []*r
|
||||||
return finalHits
|
return finalHits
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *record) recordToOutput() *pb.Output {
|
||||||
|
return &pb.Output{
|
||||||
|
TxHash: util.ToHash(r.Txid),
|
||||||
|
Nout: r.Nout,
|
||||||
|
Height: r.Height,
|
||||||
|
Meta: &pb.Output_Claim{
|
||||||
|
Claim: &pb.ClaimMeta{
|
||||||
|
//Channel:
|
||||||
|
//Repost:
|
||||||
|
ShortUrl: r.ShortUrl,
|
||||||
|
CanonicalUrl: r.CanonicalUrl,
|
||||||
|
IsControlling: r.IsControlling,
|
||||||
|
TakeOverHeight: r.TakeOverHeight,
|
||||||
|
CreationHeight: r.CreationHeight,
|
||||||
|
ActivationHeight: r.ActivationHeight,
|
||||||
|
ExpirationHeight: r.ExpirationHeight,
|
||||||
|
ClaimsInChannel: r.ClaimsInChannel,
|
||||||
|
Reposted: r.Reposted,
|
||||||
|
EffectiveAmount: r.EffectiveAmount,
|
||||||
|
SupportAmount: r.SupportAmount,
|
||||||
|
TrendingGroup: r.TrendingGroup,
|
||||||
|
TrendingMixed: r.TrendingMixed,
|
||||||
|
TrendingLocal: r.TrendingLocal,
|
||||||
|
TrendingGlobal: r.TrendingGlobal,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (r *record) getHitId() string {
|
func (r *record) getHitId() string {
|
||||||
if r.RepostedClaimId != "" {
|
if r.RepostedClaimId != "" {
|
||||||
return r.RepostedClaimId
|
return r.RepostedClaimId
|
||||||
|
@ -638,11 +642,7 @@ func removeBlocked(searchHits []*record, blocked *[]*pb.Blocked) []*record {
|
||||||
if blockedChannels[r.ChannelId] == nil {
|
if blockedChannels[r.ChannelId] == nil {
|
||||||
blockedObj := &pb.Blocked{
|
blockedObj := &pb.Blocked{
|
||||||
Count: 1,
|
Count: 1,
|
||||||
Channel: &pb.Output{
|
Channel: r.recordToOutput(),
|
||||||
TxHash: util.ToHash(r.Txid),
|
|
||||||
Nout: r.Nout,
|
|
||||||
Height: r.Height,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
*blocked = append(*blocked, blockedObj)
|
*blocked = append(*blocked, blockedObj)
|
||||||
blockedChannels[r.ChannelId] = blockedObj
|
blockedChannels[r.ChannelId] = blockedObj
|
||||||
|
|
Loading…
Add table
Reference in a new issue