예제 #1
0
// Returns pending transactions
func getTransactionsHandler(gateway *daemon.Gateway) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		V := gateway.V
		ret := make([]*visor.ReadableUnconfirmedTxn, 0, len(V.Unconfirmed.Txns))

		for _, unconfirmedTxn := range V.Unconfirmed.Txns {
			readable := visor.NewReadableUnconfirmedTxn(&unconfirmedTxn)
			ret = append(ret, &readable)
		}
		SendOr404(w, ret)
	}
}
예제 #2
0
// Returns pending transactions
func getPendingTxs(gateway *daemon.Gateway) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		if r.Method != "GET" {
			wh.Error405(w, "")
			return
		}

		V := gateway.V
		ret := make([]*visor.ReadableUnconfirmedTxn, 0, len(V.Unconfirmed.Txns))
		for _, unconfirmedTxn := range V.Unconfirmed.Txns {
			readable := visor.NewReadableUnconfirmedTxn(&unconfirmedTxn)
			ret = append(ret, &readable)
		}

		wh.SendOr404(w, &ret)
	}
}