gitlab.com/jokerrs1/Sia@v1.3.2/node/api/client/gateway.go (about)

     1  package client
     2  
     3  import (
     4  	"github.com/NebulousLabs/Sia/modules"
     5  	"github.com/NebulousLabs/Sia/node/api"
     6  	"github.com/NebulousLabs/errors"
     7  )
     8  
     9  var (
    10  	// ErrPeerExists indicates that two peers are already connected. The string
    11  	// of this error needs to be updated if the string of errPeerExists in the
    12  	// gateway package is changed.
    13  	ErrPeerExists = errors.New("already connected to this peer")
    14  )
    15  
    16  // GatewayConnectPost uses the /gateway/connect/:address endpoint to connect to
    17  // the gateway at address
    18  func (c *Client) GatewayConnectPost(address modules.NetAddress) (err error) {
    19  	err = c.post("/gateway/connect/"+string(address), "", nil)
    20  	if err != nil && err.Error() == ErrPeerExists.Error() {
    21  		err = ErrPeerExists
    22  	}
    23  	return
    24  }
    25  
    26  // GatewayGet requests the /gateway api resource
    27  func (c *Client) GatewayGet() (gwg api.GatewayGET, err error) {
    28  	err = c.get("/gateway", &gwg)
    29  	return
    30  }