Documentation
¶
Index ¶
- Constants
- func AuthHandler(handler http.Handler, accessTokens *accesstoken.CredentialStore) http.Handler
- func RedirectHandler(next http.Handler) http.Handler
- type API
- func (a *API) GetNodeInfo() *NetInfo
- func (a *API) GetTxFeedByAlias(ctx context.Context, filter string) ([]byte, error)
- func (a *API) GetWork() (*GetWorkResp, error)
- func (a *API) IsMining() bool
- func (a *API) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (a *API) StartServer(address string)
- func (a *API) SubmitWork(bh *types.BlockHeader) error
- type BlockHeaderByHeight
- type BlockTx
- type BuildRequest
- type GetBlockReq
- type GetBlockResp
- type GetWorkResp
- type KeyImportParams
- type NetInfo
- type ResetPasswordResp
- type Response
- type SubmitWorkReq
Constants ¶
View Source
const ( // SUCCESS indicates the rpc calling is successful. SUCCESS = "success" // FAIL indicated the rpc calling is failed. FAIL = "fail" )
Variables ¶
This section is empty.
Functions ¶
func AuthHandler ¶
func AuthHandler(handler http.Handler, accessTokens *accesstoken.CredentialStore) http.Handler
AuthHandler access token auth Handler
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is the scheduling center for server
func NewAPI ¶
func NewAPI(sync *netsync.SyncManager, wallet *wallet.Wallet, txfeeds *txfeed.Tracker, cpuMiner *cpuminer.CPUMiner, miningPool *miningpool.MiningPool, chain *protocol.Chain, config *cfg.Config, token *accesstoken.CredentialStore) *API
NewAPI create and initialize the API
func (*API) GetNodeInfo ¶ added in v0.4.3
func (*API) GetTxFeedByAlias ¶ added in v0.4.3
func (*API) GetWork ¶ added in v0.4.3
func (a *API) GetWork() (*GetWorkResp, error)
func (*API) SubmitWork ¶ added in v0.4.3
func (a *API) SubmitWork(bh *types.BlockHeader) error
type BlockHeaderByHeight ¶
type BlockHeaderByHeight struct {
BlockHeader *types.BlockHeader `json:"block_header"`
Reward uint64 `json:"reward"`
}
BlockHeaderByHeight is resp struct for API
type BlockTx ¶
type BlockTx struct {
ID bc.Hash `json:"id"`
Version uint64 `json:"version"`
Size uint64 `json:"size"`
TimeRange uint64 `json:"time_range"`
Inputs []*query.AnnotatedInput `json:"inputs"`
Outputs []*query.AnnotatedOutput `json:"outputs"`
StatusFail bool `json:"status_fail"`
}
BlockTx is the tx struct for getBlock func
type BuildRequest ¶
type BuildRequest struct {
Tx *types.TxData `json:"base_transaction"`
Actions []map[string]interface{} `json:"actions"`
TTL json.Duration `json:"ttl"`
TimeRange uint64 `json:"time_range"`
}
BuildRequest is main struct when building transactions
type GetBlockReq ¶
type GetBlockReq struct {
BlockHeight uint64 `json:"block_height"`
BlockHash chainjson.HexBytes `json:"block_hash"`
}
GetBlockReq is used to handle getBlock req
type GetBlockResp ¶
type GetBlockResp struct {
Hash *bc.Hash `json:"hash"`
Size uint64 `json:"size"`
Version uint64 `json:"version"`
Height uint64 `json:"height"`
PreviousBlockHash *bc.Hash `json:"previous_block_hash"`
Timestamp uint64 `json:"timestamp"`
Nonce uint64 `json:"nonce"`
Bits uint64 `json:"bits"`
Difficulty string `json:"difficulty"`
TransactionsMerkleRoot *bc.Hash `json:"transaction_merkle_root"`
TransactionStatusHash *bc.Hash `json:"transaction_status_hash"`
Transactions []*BlockTx `json:"transactions"`
}
GetBlockResp is the resp for getBlock api
type GetWorkResp ¶ added in v0.4.3
type GetWorkResp struct {
BlockHeader *types.BlockHeader `json:"block_header"`
Seed *bc.Hash `json:"seed"`
}
GetWorkResp is resp struct for API
type KeyImportParams ¶
type KeyImportParams struct {
KeyAlias string `json:"alias"`
Password string `json:"password"`
XPrv string `json:"xprv"`
Index uint64 `json:"index"`
AccountAlias string `json:"account_alias"`
}
KeyImportParams private key import param
type ResetPasswordResp ¶
type ResetPasswordResp struct {
Changed bool `json:"changed"`
}
type Response ¶
type Response struct {
Status string `json:"status,omitempty"`
Msg string `json:"msg,omitempty"`
Data interface{} `json:"data,omitempty"`
}
Response describes the response standard.
func NewSuccessResponse ¶
func NewSuccessResponse(data interface{}) Response
NewSuccessResponse success response
type SubmitWorkReq ¶ added in v0.4.2
type SubmitWorkReq struct {
BlockHeader *types.BlockHeader `json:"block_header"`
}
Click to show internal directories.
Click to hide internal directories.