本文整理汇总了Golang中github.com/skycoin/skycoin/src/daemon.Gateway类的典型用法代码示例。如果您正苦于以下问题:Golang Gateway类的具体用法?Golang Gateway怎么用?Golang Gateway使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Gateway类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getAddrUxOuts
func getAddrUxOuts(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
wh.Error405(w, "")
return
}
addr := r.FormValue("address")
if addr == "" {
wh.Error400(w, "address is empty")
return
}
cipherAddr, err := cipher.DecodeBase58Address(addr)
if err != nil {
wh.Error400(w, err.Error())
return
}
uxs, err := gateway.GetAddrUxOuts(cipherAddr)
if err != nil {
wh.Error400(w, err.Error())
return
}
wh.SendOr404(w, uxs)
}
}
开发者ID:skycoin,项目名称:skycoin,代码行数:27,代码来源:uxout.go
示例2: walletSpendHandler
func walletSpendHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
sdst := r.FormValue("dst")
if sdst == "" {
Error400(w, "Missing destination address \"dst\"")
return
}
dst, err := coin.DecodeBase58Address(sdst)
if err != nil {
Error400(w, "Invalid destination address")
return
}
sfee := r.FormValue("fee")
fee, err := strconv.ParseUint(sfee, 10, 64)
if err != nil {
Error400(w, "Invalid \"fee\" value")
return
}
scoins := r.FormValue("coins")
shours := r.FormValue("hours")
coins, err := strconv.ParseUint(scoins, 10, 64)
if err != nil {
Error400(w, "Invalid \"coins\" value")
return
}
hours, err := strconv.ParseUint(shours, 10, 64)
if err != nil {
Error400(w, "Invalid \"hours\" value")
return
}
SendOr404(w, gateway.Spend(visor.NewBalance(coins, hours), fee, dst))
}
}
开发者ID:RagnarDanneskjold,项目名称:skycoin,代码行数:33,代码来源:wallet.go
示例3: getUxOutByID
func getUxOutByID(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
wh.Error405(w, "")
return
}
uxid := r.FormValue("uxid")
if uxid == "" {
wh.Error400(w, "uxid is empty")
return
}
id, err := cipher.SHA256FromHex(uxid)
if err != nil {
wh.Error400(w, err.Error())
return
}
uxout, err := gateway.GetUxOutByID(id)
if err != nil {
wh.Error400(w, err.Error())
return
}
if uxout == nil {
wh.Error404(w, "not found")
return
}
wh.SendOr404(w, uxout)
}
}
开发者ID:skycoin,项目名称:skycoin,代码行数:33,代码来源:uxout.go
示例4: walletsReloadHandler
// Loads/unloads wallets from the wallet directory
func walletsReloadHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
err := gateway.ReloadWallets()
if err != nil {
Error500(w, err.(error).Error())
}
}
}
开发者ID:notsoshifty,项目名称:skycoin,代码行数:9,代码来源:wallet.go
示例5: connectionHandler
func connectionHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if addr := r.FormValue("addr"); addr == "" {
Error404(w)
} else {
SendOr404(w, gateway.GetConnection(addr))
}
}
}
开发者ID:keepwalking1234,项目名称:skycoin,代码行数:9,代码来源:network.go
示例6: walletTransactionResendHandler
func walletTransactionResendHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
hash, err := coin.SHA256FromHex(r.FormValue("hash"))
if err != nil {
Error404(w)
return
}
SendOr404(w, gateway.ResendTransaction(hash))
}
}
开发者ID:RagnarDanneskjold,项目名称:skycoin,代码行数:10,代码来源:wallet.go
示例7: walletAddressTransactionsHandler
func walletAddressTransactionsHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
saddr := r.FormValue("addr")
addr, err := coin.DecodeBase58Address(saddr)
if err != nil {
Error404(w)
return
}
SendOr404(w, gateway.GetAddressTransactions(addr))
}
}
开发者ID:RagnarDanneskjold,项目名称:skycoin,代码行数:11,代码来源:wallet.go
示例8: blockchainBlockHandler
func blockchainBlockHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
sseq := r.FormValue("seq")
seq, err := strconv.ParseUint(sseq, 10, 64)
if err != nil {
Error400(w, fmt.Sprintf("Invalid seq value \"%s\"", sseq))
return
}
SendOr404(w, gateway.GetBlock(seq))
}
}
开发者ID:JmAbuDabi,项目名称:skycoin,代码行数:11,代码来源:blockchain.go
示例9: walletHandler
// Returns a wallet by ID if GET. Creates or updates a wallet if POST.
func walletHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
SendOr404(w, gateway.GetWallet(wallet.WalletID(r.FormValue("id"))))
} else if r.Method == "POST" {
walletHandlerPOST(gateway, w, r)
} else {
Error405(w)
}
}
}
开发者ID:notsoshifty,项目名称:skycoin,代码行数:12,代码来源:wallet.go
示例10: walletsSaveHandler
// Saves all loaded wallets
func walletsSaveHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
errs := gateway.SaveWallets().(map[wallet.WalletID]error)
if len(errs) != 0 {
err := ""
for id, e := range errs {
err += string(id) + ": " + e.Error()
}
Error500(w, err)
}
}
}
开发者ID:notsoshifty,项目名称:skycoin,代码行数:13,代码来源:wallet.go
示例11: walletHandlerPOST
// Create a wallet if no ID provided. Otherwise update an existing wallet.
// Name the wallet with "name".
func walletHandlerPOST(gateway *daemon.Gateway, w http.ResponseWriter,
r *http.Request) {
id := wallet.WalletID(r.FormValue("id"))
name := r.FormValue("name")
if id == "" {
// Create wallet
iw := gateway.CreateWallet()
if iw != nil {
w := iw.(wallet.Wallet)
w.SetName(name)
if err := gateway.SaveWallet(w.GetID()); err != nil {
m := "Failed to save wallet after renaming: %v"
logger.Critical(m, err)
}
}
SendOr500(w, iw)
} else {
// Update wallet
iw := gateway.GetWallet(id)
if iw != nil {
w := iw.(wallet.Wallet)
w.SetName(name)
if err := gateway.SaveWallet(w.GetID()); err != nil {
m := "Failed to save wallet after renaming: %v"
logger.Critical(m, err)
}
}
SendOr404(w, iw)
}
}
开发者ID:notsoshifty,项目名称:skycoin,代码行数:32,代码来源:wallet.go
示例12: blockchainBlocksHandler
func blockchainBlocksHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
sstart := r.FormValue("start")
start, err := strconv.ParseUint(sstart, 10, 64)
if err != nil {
Error400(w, fmt.Sprintf("Invalid start value \"%s\"", sstart))
return
}
send := r.FormValue("end")
end, err := strconv.ParseUint(send, 10, 64)
if err != nil {
Error400(w, fmt.Sprintf("Invalid end value \"%s\"", send))
return
}
SendOr404(w, gateway.GetBlocks(start, end))
}
}
开发者ID:JmAbuDabi,项目名称:skycoin,代码行数:17,代码来源:blockchain.go
示例13: walletBalanceHandler
func walletBalanceHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
saddr := r.FormValue("addr")
predicted := r.FormValue("predicted")
var m interface{}
if saddr == "" {
m = gateway.GetTotalBalance(predicted != "")
} else {
addr, err := coin.DecodeBase58Address(saddr)
if err != nil {
Error400(w, "Invalid address")
return
}
m = gateway.GetBalance(addr, predicted != "")
}
SendOr404(w, m)
}
}
开发者ID:RagnarDanneskjold,项目名称:skycoin,代码行数:18,代码来源:wallet.go
示例14: getBlocks
func getBlocks(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
wh.Error405(w, "")
return
}
sstart := r.FormValue("start")
start, err := strconv.ParseUint(sstart, 10, 64)
if err != nil {
wh.Error400(w, fmt.Sprintf("Invalid start value \"%s\"", sstart))
return
}
send := r.FormValue("end")
end, err := strconv.ParseUint(send, 10, 64)
if err != nil {
wh.Error400(w, fmt.Sprintf("Invalid end value \"%s\"", send))
return
}
wh.SendOr404(w, gateway.GetBlocks(start, end))
}
}
开发者ID:skycoin,项目名称:skycoin,代码行数:22,代码来源:blockchain.go
示例15: getLastBlocks
// get last N blocks
func getLastBlocks(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
wh.Error405(w, "")
return
}
num := r.FormValue("num")
if num == "" {
wh.Error400(w, "Param: num is empty")
return
}
n, err := strconv.ParseUint(num, 10, 64)
if err != nil {
wh.Error400(w, err.Error())
return
}
wh.SendOr404(w, gateway.GetLastBlocks(n))
}
}
开发者ID:skycoin,项目名称:skycoin,代码行数:23,代码来源:blockchain.go
示例16: getOutputsHandler
// getOutputsHandler get utxos base on the filters in url params.
// mode: GET
// url: /outputs?addrs=[:addrs]&hashes=[:hashes]
// if addrs and hashes are not specificed, return all unspent outputs.
// if both addrs and hashes are specificed, then both those filters are need to be matched.
// if only specify one filter, then return outputs match the filter.
func getOutputsHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
var addrs []string
var hashes []string
trimSpace := func(vs []string) []string {
for i := range vs {
vs[i] = strings.TrimSpace(vs[i])
}
return vs
}
addrStr := r.FormValue("addrs")
if addrStr != "" {
addrs = trimSpace(strings.Split(addrStr, ","))
}
hashStr := r.FormValue("hashes")
if hashStr != "" {
hashes = trimSpace(strings.Split(hashStr, ","))
}
filters := []daemon.OutputsFilter{}
if len(addrs) > 0 {
filters = append(filters, daemon.FbyAddresses(addrs))
}
if len(hashes) > 0 {
filters = append(filters, daemon.FbyHashes(hashes))
}
outs := gateway.GetUnspentOutputs(filters...)
wh.SendOr404(w, outs)
}
}
}
开发者ID:skycoin,项目名称:skycoin,代码行数:44,代码来源:wallet.go
示例17: connectionsHandler
func connectionsHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
SendOr404(w, gateway.GetConnections())
}
}
开发者ID:keepwalking1234,项目名称:skycoin,代码行数:5,代码来源:network.go
示例18: blockchainHandler
func blockchainHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
SendOr404(w, gateway.GetBlockchainMetadata())
}
}
开发者ID:JmAbuDabi,项目名称:skycoin,代码行数:5,代码来源:blockchain.go
示例19: blockchainProgressHandler
func blockchainProgressHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
wh.SendOr404(w, gateway.GetBlockchainProgress())
}
}
开发者ID:skycoin,项目名称:skycoin,代码行数:5,代码来源:blockchain.go
示例20: walletBalanceHandler
// Returns the wallet's balance, both confirmed and predicted. The predicted
// balance is the confirmed balance minus the pending spends.
func walletBalanceHandler(gateway *daemon.Gateway) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
id := r.FormValue("id")
SendOr404(w, gateway.GetWalletBalance(wallet.WalletID(id)))
}
}
开发者ID:notsoshifty,项目名称:skycoin,代码行数:8,代码来源:wallet.go
注:本文中的github.com/skycoin/skycoin/src/daemon.Gateway类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论