Commit ab9bce3d authored by 李伟@五瓣科技's avatar 李伟@五瓣科技

reverse hash list

parent 0c6ea0bb
...@@ -95,7 +95,7 @@ func Start(redisAddr, passwd string) { ...@@ -95,7 +95,7 @@ func Start(redisAddr, passwd string) {
//fmt.Printf("batchTxHash %s listLen: %d list: %v \n", fmt.Sprintf("%x", batchTxs.Hash), len(hashstr), hashstr) //fmt.Printf("batchTxHash %s listLen: %d list: %v \n", fmt.Sprintf("%x", batchTxs.Hash), len(hashstr), hashstr)
if err := client.LPush(context.Background(), fmt.Sprintf("%x", batchTxs.Hash), hashstr); err != nil { if err := client.LPush(context.Background(), fmt.Sprintf("%x", batchTxs.Hash), reverse(hashstr)); err != nil {
} }
...@@ -117,3 +117,10 @@ type RedisBatchTxs struct { ...@@ -117,3 +117,10 @@ type RedisBatchTxs struct {
Txs []TxBytes `json:"Txs"` Txs []TxBytes `json:"Txs"`
Hash []byte `json:"Hash"` Hash []byte `json:"Hash"`
} }
func reverse(s []string) []string {
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
s[i], s[j] = s[j], s[i]
}
return s
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment