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

add txs list

parent 67c4ca2e
......@@ -11,6 +11,7 @@ import (
"sync/atomic"
"time"
"encoding/base64"
"sync"
"github.com/ethereum/go-ethereum/common"
......@@ -139,6 +140,10 @@ func (web *WebServicer) GetTreeHandler(w http.ResponseWriter, r *http.Request) {
consTxWithBatchHash = append(consTxWithBatchHash, v.ConsTxWithBatchHash...)
}
for k, v := range consTxWithBatchHash {
fmt.Printf("idx: %d v: %d \n", k, len(v.BatchTxsHash))
}
recordAsJon, err := json.Marshal(consTxWithBatchHash)
if err != nil {
......@@ -160,6 +165,28 @@ func (web *WebServicer) GetTreeHandler(w http.ResponseWriter, r *http.Request) {
}
func (web *WebServicer) GetTxsList(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
hashStr := vars["hash"]
// hashAsBytes := []byte(hashStr)
hashAsBytes, err := base64.StdEncoding.DecodeString(hashStr)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
// if err := json.Unmarshal(hashStr, &hashAsBytes); err != nil {
// http.Error(w, err.Error(), http.StatusBadRequest)
// return
// }
fmt.Printf("hashStr: %s len(hashStr): %d len(hashAsBytes): %d \n", hashStr, len(hashStr), len(hashAsBytes))
}
func (web *WebServicer) WebService(config Config) error {
r := mux.NewRouter()
// Routes consist of a path and a handler function.
......@@ -167,6 +194,7 @@ func (web *WebServicer) WebService(config Config) error {
//r.HandleFunc("/faucet/{addr}", web.FaucetHandler)
r.HandleFunc("/process/{uuid}", web.ProcessHandler)
r.HandleFunc("/tree/{uuid}", web.GetTreeHandler)
r.HandleFunc("/txslist/{hash}", web.GetTxsList)
r.HandleFunc("/txs", web.TxsHandler).Methods("POST")
clientFactory, exists := clientFactories["ethclient"]
......
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