2021-04-19 21:25:34 +02:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/hex"
|
2021-05-31 03:34:57 +02:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
2021-05-13 22:06:19 +02:00
|
|
|
pb "github.com/lbryio/hub/protobuf/go"
|
2021-04-19 21:25:34 +02:00
|
|
|
"log"
|
|
|
|
"reflect"
|
|
|
|
|
2021-05-16 05:13:14 +02:00
|
|
|
"github.com/btcsuite/btcutil/base58"
|
2021-04-19 21:25:34 +02:00
|
|
|
"github.com/olivere/elastic/v7"
|
2021-05-31 03:34:57 +02:00
|
|
|
"golang.org/x/text/cases"
|
|
|
|
"golang.org/x/text/unicode/norm"
|
2021-04-19 21:25:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type record struct {
|
2021-05-31 03:34:57 +02:00
|
|
|
Txid string `json:"tx_id"`
|
|
|
|
Nout uint32 `json:"tx_nout"`
|
|
|
|
Height uint32 `json:"height"`
|
2021-04-19 21:25:34 +02:00
|
|
|
}
|
|
|
|
|
2021-05-18 12:02:55 +02:00
|
|
|
type orderField struct {
|
|
|
|
Field string
|
|
|
|
is_asc bool
|
|
|
|
}
|
|
|
|
|
2021-05-16 05:13:14 +02:00
|
|
|
func ReverseBytes(s []byte) {
|
2021-05-13 22:06:19 +02:00
|
|
|
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
|
|
|
|
s[i], s[j] = s[j], s[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-16 05:13:14 +02:00
|
|
|
func StrArrToInterface(arr []string) []interface{} {
|
|
|
|
searchVals := make([]interface{}, len(arr))
|
|
|
|
for i := 0; i < len(arr); i++ {
|
|
|
|
searchVals[i] = arr[i]
|
|
|
|
}
|
|
|
|
return searchVals
|
|
|
|
}
|
|
|
|
|
2021-05-18 12:02:55 +02:00
|
|
|
func AddTermsField(arr []string, name string, q *elastic.BoolQuery) *elastic.BoolQuery {
|
2021-05-16 05:13:14 +02:00
|
|
|
if len(arr) > 0 {
|
|
|
|
searchVals := StrArrToInterface(arr)
|
|
|
|
return q.Must(elastic.NewTermsQuery(name, searchVals...))
|
|
|
|
}
|
|
|
|
return q
|
|
|
|
}
|
|
|
|
|
2021-05-18 12:02:55 +02:00
|
|
|
func AddRangeField(rq *pb.RangeField, name string, q *elastic.BoolQuery) *elastic.BoolQuery {
|
2021-05-16 05:13:14 +02:00
|
|
|
if rq == nil {
|
|
|
|
return q
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(rq.Value) > 1 {
|
2021-05-18 12:02:55 +02:00
|
|
|
if rq.Op != pb.RangeField_EQ {
|
2021-05-16 05:13:14 +02:00
|
|
|
return q
|
|
|
|
}
|
2021-05-18 12:02:55 +02:00
|
|
|
return AddTermsField(rq.Value, name, q)
|
2021-05-16 05:13:14 +02:00
|
|
|
}
|
2021-05-18 12:02:55 +02:00
|
|
|
if rq.Op == pb.RangeField_EQ {
|
|
|
|
return AddTermsField(rq.Value, name, q)
|
|
|
|
} else if rq.Op == pb.RangeField_LT {
|
2021-05-16 05:13:14 +02:00
|
|
|
return q.Must(elastic.NewRangeQuery(name).Lt(rq.Value))
|
2021-05-18 12:02:55 +02:00
|
|
|
} else if rq.Op == pb.RangeField_LTE {
|
2021-05-16 05:13:14 +02:00
|
|
|
return q.Must(elastic.NewRangeQuery(name).Lte(rq.Value))
|
2021-05-18 12:02:55 +02:00
|
|
|
} else if rq.Op == pb.RangeField_GT {
|
2021-05-16 05:13:14 +02:00
|
|
|
return q.Must(elastic.NewRangeQuery(name).Gt(rq.Value))
|
2021-05-18 12:02:55 +02:00
|
|
|
} else { // pb.RangeField_GTE
|
2021-05-16 05:13:14 +02:00
|
|
|
return q.Must(elastic.NewRangeQuery(name).Gte(rq.Value))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-18 12:02:55 +02:00
|
|
|
func AddInvertibleField(field *pb.InvertibleField, name string, q *elastic.BoolQuery) *elastic.BoolQuery {
|
|
|
|
if field == nil {
|
|
|
|
return q
|
|
|
|
}
|
|
|
|
searchVals := StrArrToInterface(field.Value)
|
|
|
|
if field.Invert {
|
|
|
|
return q.MustNot(elastic.NewTermsQuery(name, searchVals...))
|
|
|
|
} else {
|
|
|
|
return q.Must(elastic.NewTermsQuery(name, searchVals...))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-31 03:34:57 +02:00
|
|
|
func normalize(s string) string {
|
|
|
|
c := cases.Fold()
|
|
|
|
return c.String(norm.NFD.String(s))
|
|
|
|
}
|
|
|
|
|
2021-04-19 21:25:34 +02:00
|
|
|
func (s *Server) Search(ctx context.Context, in *pb.SearchRequest) (*pb.SearchReply, error) {
|
2021-04-21 22:19:05 +02:00
|
|
|
// TODO: reuse elastic client across requests
|
2021-05-13 18:02:03 +02:00
|
|
|
client, err := elastic.NewClient(elastic.SetSniff(false))
|
2021-04-19 21:25:34 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-05-13 22:06:19 +02:00
|
|
|
claimTypes := map[string]int {
|
|
|
|
"stream": 1,
|
|
|
|
"channel": 2,
|
|
|
|
"repost": 3,
|
|
|
|
"collection": 4,
|
|
|
|
}
|
2021-05-18 12:02:55 +02:00
|
|
|
|
|
|
|
streamTypes := map[string]int {
|
|
|
|
"video": 1,
|
|
|
|
"audio": 2,
|
|
|
|
"image": 3,
|
|
|
|
"document": 4,
|
|
|
|
"binary": 5,
|
|
|
|
"model": 6,
|
|
|
|
}
|
|
|
|
|
|
|
|
replacements := map[string]string {
|
|
|
|
"name": "normalized",
|
|
|
|
"txid": "tx_id",
|
|
|
|
"claim_hash": "_id",
|
|
|
|
}
|
|
|
|
|
|
|
|
textFields := map[string]bool {
|
|
|
|
"author": true,
|
|
|
|
"canonical_url": true,
|
|
|
|
"channel_id": true,
|
|
|
|
"claim_name": true,
|
|
|
|
"description": true,
|
|
|
|
"claim_id": true,
|
|
|
|
"media_type": true,
|
|
|
|
"normalized": true,
|
|
|
|
"public_key_bytes": true,
|
|
|
|
"public_key_hash": true,
|
|
|
|
"short_url": true,
|
|
|
|
"signature": true,
|
|
|
|
"signature_digest": true,
|
|
|
|
"stream_type": true,
|
|
|
|
"title": true,
|
|
|
|
"tx_id": true,
|
|
|
|
"fee_currency": true,
|
|
|
|
"reposted_claim_id": true,
|
|
|
|
"tags": true,
|
|
|
|
}
|
|
|
|
|
|
|
|
var from = 0
|
|
|
|
var size = 10
|
|
|
|
var orderBy []orderField
|
|
|
|
|
2021-04-19 21:25:34 +02:00
|
|
|
// Ping the Elasticsearch server to get e.g. the version number
|
2021-04-21 22:19:05 +02:00
|
|
|
//_, code, err := client.Ping("http://127.0.0.1:9200").Do(ctx)
|
|
|
|
//if err != nil {
|
|
|
|
// return nil, err
|
|
|
|
//}
|
|
|
|
//if code != 200 {
|
|
|
|
// return nil, errors.New("ping failed")
|
|
|
|
//}
|
2021-04-19 21:25:34 +02:00
|
|
|
|
2021-04-21 22:19:05 +02:00
|
|
|
// TODO: support all of this https://github.com/lbryio/lbry-sdk/blob/master/lbry/wallet/server/db/elasticsearch/search.py#L385
|
2021-05-13 22:06:19 +02:00
|
|
|
|
|
|
|
q := elastic.NewBoolQuery()
|
|
|
|
|
|
|
|
if in.AmountOrder > 0 {
|
|
|
|
in.Limit = 1
|
2021-05-18 12:02:55 +02:00
|
|
|
in.OrderBy = []string{"effective_amount"}
|
2021-05-13 22:06:19 +02:00
|
|
|
in.Offset = in.AmountOrder - 1
|
|
|
|
}
|
|
|
|
|
2021-05-18 12:02:55 +02:00
|
|
|
if in.Limit > 0 {
|
|
|
|
size = int(in.Limit)
|
|
|
|
}
|
|
|
|
|
|
|
|
if in.Offset > 0 {
|
|
|
|
from = int(in.Offset)
|
|
|
|
}
|
|
|
|
|
2021-05-25 05:28:43 +02:00
|
|
|
if len(in.Name) > 0 {
|
2021-05-31 03:34:57 +02:00
|
|
|
normalized := make([]string, len(in.Name))
|
|
|
|
for i := 0; i < len(in.Name); i++ {
|
|
|
|
normalized[i] = normalize(in.Name[i])
|
|
|
|
}
|
|
|
|
in.Normalized = normalized
|
2021-05-25 05:28:43 +02:00
|
|
|
}
|
|
|
|
|
2021-05-18 12:02:55 +02:00
|
|
|
if len(in.OrderBy) > 0 {
|
|
|
|
for _, x := range in.OrderBy {
|
|
|
|
var toAppend string
|
|
|
|
var is_asc = false
|
|
|
|
if x[0] == '^' {
|
|
|
|
is_asc = true
|
|
|
|
x = x[1:]
|
|
|
|
}
|
|
|
|
if _, ok := replacements[x]; ok {
|
|
|
|
toAppend = replacements[x]
|
|
|
|
}
|
|
|
|
if _, ok := textFields[x]; ok {
|
|
|
|
toAppend = x + ".keyword"
|
|
|
|
}
|
|
|
|
orderBy = append(orderBy, orderField{toAppend, is_asc})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-13 22:06:19 +02:00
|
|
|
if len(in.ClaimType) > 0 {
|
|
|
|
searchVals := make([]interface{}, len(in.ClaimType))
|
|
|
|
for i := 0; i < len(in.ClaimType); i++ {
|
|
|
|
searchVals[i] = claimTypes[in.ClaimType[i]]
|
|
|
|
}
|
|
|
|
q = q.Must(elastic.NewTermsQuery("claim_type", searchVals...))
|
|
|
|
}
|
|
|
|
|
2021-05-18 12:02:55 +02:00
|
|
|
// FIXME is this a text field or not?
|
|
|
|
if len(in.StreamType) > 0 {
|
|
|
|
searchVals := make([]interface{}, len(in.StreamType))
|
|
|
|
for i := 0; i < len(in.StreamType); i++ {
|
|
|
|
searchVals[i] = streamTypes[in.StreamType[i]]
|
|
|
|
}
|
|
|
|
q = q.Must(elastic.NewTermsQuery("stream_type.keyword", searchVals...))
|
|
|
|
}
|
|
|
|
|
2021-05-13 22:06:19 +02:00
|
|
|
if len(in.XId) > 0 {
|
|
|
|
searchVals := make([]interface{}, len(in.XId))
|
|
|
|
for i := 0; i < len(in.XId); i++ {
|
2021-05-16 05:13:14 +02:00
|
|
|
ReverseBytes(in.XId[i])
|
2021-05-13 22:06:19 +02:00
|
|
|
searchVals[i] = hex.Dump(in.XId[i])
|
|
|
|
}
|
2021-05-16 05:13:14 +02:00
|
|
|
if len(in.XId) == 1 && len(in.XId[0]) < 20 {
|
|
|
|
q = q.Must(elastic.NewPrefixQuery("_id", string(in.XId[0])))
|
|
|
|
} else {
|
|
|
|
q = q.Must(elastic.NewTermsQuery("_id", searchVals...))
|
|
|
|
}
|
2021-05-13 22:06:19 +02:00
|
|
|
}
|
|
|
|
|
2021-05-16 05:13:14 +02:00
|
|
|
|
2021-05-18 12:02:55 +02:00
|
|
|
if in.ClaimId != nil {
|
|
|
|
searchVals := StrArrToInterface(in.ClaimId.Value)
|
|
|
|
if len(in.ClaimId.Value) == 1 && len(in.ClaimId.Value[0]) < 20 {
|
|
|
|
if in.ClaimId.Invert {
|
|
|
|
q = q.MustNot(elastic.NewPrefixQuery("claim_id.keyword", in.ClaimId.Value[0]))
|
|
|
|
} else {
|
|
|
|
q = q.Must(elastic.NewPrefixQuery("claim_id.keyword", in.ClaimId.Value[0]))
|
|
|
|
}
|
2021-05-16 05:13:14 +02:00
|
|
|
} else {
|
2021-05-18 12:02:55 +02:00
|
|
|
if in.ClaimId.Invert {
|
|
|
|
q = q.MustNot(elastic.NewTermsQuery("claim_id.keyword", searchVals...))
|
|
|
|
} else {
|
|
|
|
q = q.Must(elastic.NewTermsQuery("claim_id.keyword", searchVals...))
|
|
|
|
}
|
2021-05-16 05:13:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if in.PublicKeyId != "" {
|
|
|
|
value := hex.Dump(base58.Decode(in.PublicKeyId)[1:21])
|
|
|
|
q = q.Must(elastic.NewTermQuery("public_key_hash.keyword", value))
|
|
|
|
}
|
|
|
|
|
2021-05-18 12:02:55 +02:00
|
|
|
if in.HasChannelSignature {
|
|
|
|
q = q.Should(elastic.NewBoolQuery().Must(elastic.NewExistsQuery("signature_digest")))
|
|
|
|
if in.SignatureValid {
|
|
|
|
q = q.Should(elastic.NewTermQuery("signature_valid", in.SignatureValid))
|
|
|
|
}
|
|
|
|
} else if in.SignatureValid {
|
|
|
|
//FIXME Might need to abstract this to another message so we can tell if the param is passed
|
|
|
|
//without relying on it's truth value
|
|
|
|
q = q.MinimumNumberShouldMatch(1)
|
|
|
|
q = q.Should(elastic.NewBoolQuery().MustNot(elastic.NewExistsQuery("signature_digest")))
|
|
|
|
q = q.Should(elastic.NewTermQuery("signature_valid", in.SignatureValid))
|
|
|
|
}
|
|
|
|
|
|
|
|
if in.HasSource {
|
|
|
|
q = q.MinimumNumberShouldMatch(1)
|
|
|
|
isStreamOrReport := elastic.NewTermsQuery("claim_type", claimTypes["stream"], claimTypes["repost"])
|
|
|
|
q = q.Should(elastic.NewBoolQuery().Must(isStreamOrReport, elastic.NewMatchQuery("has_source", in.HasSource)))
|
|
|
|
q = q.Should(elastic.NewBoolQuery().MustNot(isStreamOrReport))
|
|
|
|
q = q.Should(elastic.NewBoolQuery().Must(elastic.NewTermQuery("reposted_claim_type", claimTypes["channel"])))
|
|
|
|
}
|
|
|
|
|
|
|
|
var collapse *elastic.CollapseBuilder
|
|
|
|
if in.LimitClaimsPerChannel > 0 {
|
|
|
|
innerHit := elastic.NewInnerHit().Size(int(in.LimitClaimsPerChannel)).Name("channel_id.keyword")
|
|
|
|
collapse = elastic.NewCollapseBuilder("channel_id.keyword").InnerHit(innerHit)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
q = AddTermsField(in.PublicKeyHash, "public_key_hash.keyword", q)
|
|
|
|
q = AddTermsField(in.Author, "author.keyword", q)
|
|
|
|
q = AddTermsField(in.Title, "title.keyword", q)
|
|
|
|
q = AddTermsField(in.CanonicalUrl, "canonical_url.keyword", q)
|
|
|
|
q = AddTermsField(in.ClaimName, "claim_name.keyword", q)
|
|
|
|
q = AddTermsField(in.Description, "description.keyword", q)
|
|
|
|
q = AddTermsField(in.MediaType, "media_type.keyword", q)
|
|
|
|
q = AddTermsField(in.Normalized, "normalized.keyword", q)
|
|
|
|
q = AddTermsField(in.PublicKeyBytes, "public_key_bytes.keyword", q)
|
|
|
|
q = AddTermsField(in.ShortUrl, "short_url.keyword", q)
|
|
|
|
q = AddTermsField(in.Signature, "signature.keyword", q)
|
|
|
|
q = AddTermsField(in.SignatureDigest, "signature_digest.keyword", q)
|
|
|
|
q = AddTermsField(in.TxId, "tx_id.keyword", q)
|
|
|
|
q = AddTermsField(in.FeeCurrency, "fee_currency.keyword", q)
|
|
|
|
q = AddTermsField(in.RepostedClaimId, "reposted_claim_id.keyword", q)
|
|
|
|
|
|
|
|
q = AddInvertibleField(in.ChannelId, "channel_id.keyword", q)
|
|
|
|
q = AddInvertibleField(in.Tags, "tags.keyword", q)
|
|
|
|
|
|
|
|
q = AddRangeField(in.TxPosition, "tx_position", q)
|
|
|
|
q = AddRangeField(in.Amount, "amount", q)
|
|
|
|
q = AddRangeField(in.Timestamp, "timestamp", q)
|
|
|
|
q = AddRangeField(in.CreationTimestamp, "creation_timestamp", q)
|
|
|
|
q = AddRangeField(in.Height, "height", q)
|
|
|
|
q = AddRangeField(in.CreationHeight, "creation_height", q)
|
|
|
|
q = AddRangeField(in.ActivationHeight, "activation_height", q)
|
|
|
|
q = AddRangeField(in.ExpirationHeight, "expiration_height", q)
|
|
|
|
q = AddRangeField(in.ReleaseTime, "release_time", q)
|
|
|
|
q = AddRangeField(in.Reposted, "reposted", q)
|
|
|
|
q = AddRangeField(in.FeeAmount, "fee_amount", q)
|
|
|
|
q = AddRangeField(in.Duration, "duration", q)
|
|
|
|
q = AddRangeField(in.CensorType, "censor_type", q)
|
|
|
|
q = AddRangeField(in.ChannelJoin, "channel_join", q)
|
|
|
|
q = AddRangeField(in.EffectiveAmount, "effective_amount", q)
|
|
|
|
q = AddRangeField(in.SupportAmount, "support_amount", q)
|
|
|
|
q = AddRangeField(in.TrendingGroup, "trending_group", q)
|
|
|
|
q = AddRangeField(in.TrendingMixed, "trending_mixed", q)
|
|
|
|
q = AddRangeField(in.TrendingLocal, "trending_local", q)
|
|
|
|
q = AddRangeField(in.TrendingGlobal, "trending_global", q)
|
2021-05-16 05:13:14 +02:00
|
|
|
|
2021-05-13 22:06:19 +02:00
|
|
|
if in.Query != "" {
|
|
|
|
textQuery := elastic.NewSimpleQueryStringQuery(in.Query).
|
|
|
|
FieldWithBoost("claim_name", 4).
|
|
|
|
FieldWithBoost("channel_name", 8).
|
|
|
|
FieldWithBoost("title", 1).
|
|
|
|
FieldWithBoost("description", 0.5).
|
|
|
|
FieldWithBoost("author", 1).
|
|
|
|
FieldWithBoost("tags", 0.5)
|
|
|
|
|
|
|
|
q = q.Must(textQuery)
|
|
|
|
}
|
|
|
|
|
2021-05-31 03:34:57 +02:00
|
|
|
|
|
|
|
fsc := elastic.NewFetchSourceContext(true).Exclude("description", "title")
|
2021-05-18 12:02:55 +02:00
|
|
|
search := client.Search().
|
2021-05-31 03:34:57 +02:00
|
|
|
FetchSourceContext(fsc).
|
2021-04-19 21:25:34 +02:00
|
|
|
//Index("twitter"). // search in index "twitter"
|
|
|
|
Query(q). // specify the query
|
2021-05-18 12:02:55 +02:00
|
|
|
From(from).Size(size)
|
|
|
|
if in.LimitClaimsPerChannel > 0 {
|
|
|
|
search = search.Collapse(collapse)
|
|
|
|
}
|
|
|
|
for _, x := range orderBy {
|
|
|
|
search = search.Sort(x.Field, x.is_asc)
|
|
|
|
}
|
|
|
|
|
|
|
|
searchResult, err := search.Do(ctx) // execute
|
2021-04-19 21:25:34 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("%s: found %d results in %dms\n", in.Query, len(searchResult.Hits.Hits), searchResult.TookInMillis)
|
|
|
|
|
|
|
|
txos := make([]*pb.Output, len(searchResult.Hits.Hits))
|
|
|
|
|
|
|
|
var r record
|
|
|
|
for i, item := range searchResult.Each(reflect.TypeOf(r)) {
|
|
|
|
if t, ok := item.(record); ok {
|
|
|
|
txos[i] = &pb.Output{
|
|
|
|
TxHash: toHash(t.Txid),
|
|
|
|
Nout: t.Nout,
|
2021-05-31 03:34:57 +02:00
|
|
|
Height: t.Height,
|
2021-04-19 21:25:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// or if you want more control
|
2021-05-31 03:34:57 +02:00
|
|
|
for _, hit := range searchResult.Hits.Hits {
|
|
|
|
// hit.Index contains the name of the index
|
|
|
|
|
|
|
|
var t map[string]interface{} // or could be a Record
|
|
|
|
err := json.Unmarshal(hit.Source, &t)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
b, err := json.MarshalIndent(t, "", " ")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("error:", err)
|
|
|
|
}
|
|
|
|
fmt.Print(string(b))
|
|
|
|
//for k := range t {
|
|
|
|
// fmt.Println(k)
|
|
|
|
//}
|
|
|
|
//return nil, nil
|
|
|
|
}
|
2021-04-19 21:25:34 +02:00
|
|
|
|
|
|
|
return &pb.SearchReply{
|
|
|
|
Txos: txos,
|
|
|
|
Total: uint32(searchResult.TotalHits()),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// convert txid to txHash
|
|
|
|
func toHash(txid string) []byte {
|
|
|
|
t, err := hex.DecodeString(txid)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// reverse the bytes. thanks, Satoshi 😒
|
|
|
|
for i, j := 0, len(t)-1; i < j; i, j = i+1, j-1 {
|
|
|
|
t[i], t[j] = t[j], t[i]
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
|
|
|
// convert txHash to txid
|
|
|
|
func FromHash(txHash []byte) string {
|
|
|
|
t := make([]byte, len(txHash))
|
|
|
|
copy(t, txHash)
|
|
|
|
|
|
|
|
// reverse the bytes. thanks, Satoshi 😒
|
|
|
|
for i, j := 0, len(txHash)-1; i < j; i, j = i+1, j-1 {
|
|
|
|
txHash[i], txHash[j] = txHash[j], txHash[i]
|
|
|
|
}
|
|
|
|
|
|
|
|
return hex.EncodeToString(t)
|
|
|
|
|
|
|
|
}
|