Documentation ¶
Overview ¶
Copyright (C) 2018 go-cloudcard authors
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func Dial(target string) (*grpc.ClientConn, error)
- func Run(config *RpcConfig) error
- func SetRpcConfig(config *config.Config, rpcCfg *RpcConfig)
- type AdminService
- func (s *AdminService) Accounts(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.AccountsResponse, error)
- func (s *AdminService) GeneratePrivateKey(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.PrivateKey, error)
- func (s *AdminService) ImportAccount(ctx context.Context, req *rpcpb.PrivKeyAndPassphrase) (*rpcpb.Address, error)
- func (s *AdminService) LockAccount(ctx context.Context, req *rpcpb.LockAccountRequest) (*rpcpb.BoolResponse, error)
- func (s *AdminService) Logging(ctx context.Context, req *rpcpb.LoggingInfo) (*rpcpb.LoggingInfo, error)
- func (s *AdminService) NewAccount(ctx context.Context, req *rpcpb.PassphraseRequest) (*rpcpb.NewAccountResponse, error)
- func (s *AdminService) SendTransaction(ctx context.Context, req *rpcpb.TransactionRequest) (*rpcpb.TransactionHash, error)
- func (s *AdminService) SendTransactionWithPassphrase(ctx context.Context, req *rpcpb.SendTransactionPassphraseRequest) (*rpcpb.TransactionHash, error)
- func (s *AdminService) Sign(ctx context.Context, req *rpcpb.SignHashRequest) (*rpcpb.SignHashResponse, error)
- func (s *AdminService) SignTransactionWithPassphrase(ctx context.Context, req *rpcpb.SignTransactionPassphraseRequest) (*rpcpb.SignTransactionPassphraseResponse, error)
- func (s *AdminService) StartMining(ctx context.Context, req *rpcpb.PassphraseRequest) (*rpcpb.BoolResponse, error)
- func (s *AdminService) StartPprof(ctx context.Context, req *rpcpb.PprofRequest) (*rpcpb.PprofResponse, error)
- func (s *AdminService) Stop(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.BoolResponse, error)
- func (s *AdminService) StopMining(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.BoolResponse, error)
- func (s *AdminService) UnlockAccount(ctx context.Context, req *rpcpb.UnlockAccountRequest) (*rpcpb.BoolResponse, error)
- func (s *AdminService) UpdateAccount(ctx context.Context, req *rpcpb.UpdateAccountRequest) (*rpcpb.BoolResponse, error)
- func (s *AdminService) VerifyMessage(ctx context.Context, req *rpcpb.VerifyMessageRequest) (*rpcpb.BoolResponse, error)
- type ApiService
- func (api *ApiService) GetAccount(ctx context.Context, req *rpcpb.Address) (*rpcpb.AccountInfo, error)
- func (s *ApiService) GetActiveCount(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.ActiveCountResponse, error)
- func (s *ApiService) GetBalance(ctx context.Context, req *rpcpb.Address) (*rpcpb.BalanceResponse, error)
- func (api *ApiService) GetBestBlockByHeight(ctx context.Context, req *rpcpb.BlockHeightAndFull) (*rpcpb.BlockResponse, error)
- func (api *ApiService) GetBestBlockHash(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.BlockHash, error)
- func (api *ApiService) GetBlockByHash(ctx context.Context, req *rpcpb.BlockHashAndFull) (*rpcpb.BlockResponse, error)
- func (api *ApiService) GetBlockChainInfo(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.BlockChainInfo, error)
- func (api *ApiService) GetBlocksByHeight(ctx context.Context, req *rpcpb.BlockHeightAndFull) (*rpcpb.BlockListResponse, error)
- func (api *ApiService) GetCreditIndex(ctx context.Context, req *rpcpb.Address) (*rpcpb.CreditIndexResponse, error)
- func (api *ApiService) GetMaxHeight(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.BlockHeight, error)
- func (s *ApiService) GetNetVersion(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.NetVersion, error)
- func (api *ApiService) GetPendingTransactionsByPage(ctx context.Context, req *rpcpb.GetPendingTransactionsByPageRequest) (*rpcpb.PendingTransaction, error)
- func (api *ApiService) GetPendingTransactionsSize(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.PendingTransactionsSize, error)
- func (s *ApiService) GetTransactionByContractAddress(ctx context.Context, req *rpcpb.ContractAddressRequest) (*rpcpb.TransactionReceipt, error)
- func (s *ApiService) GetTransactionByHash(ctx context.Context, req *rpcpb.TransactionHash) (*rpcpb.TransactionReceipt, error)
- func (s *ApiService) NodeInfo(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.NodeInfoResponse, error)
- func (s *ApiService) SendSignedTransaction(ctx context.Context, req *rpcpb.Transaction) (*rpcpb.BoolResponse, error)
- type GRPCServer
- type RpcConfig
- type Server
Constants ¶
const ( API = "api" Admin = "admin" )
const
const ( // DefaultHTTPLimit default max http conns DefaultHTTPLimit = 128 // MaxGateWayRecvMsgSize Deafult max message size gateway's grpc client can receive MaxGateWayRecvMsgSize = 64 * 1024 * 1024 )
const ( DefaultConnectionLimits = 128 MaxRecvMsgSize = 64 * 1024 * 1024 Rpc = "rpc" )
Const
Variables ¶
var ( CoinbaseAddressIsNilError = errors.New("the coinbase address is nil") PassphraseLengthIsZeroError = errors.New("passphrase length is 0") MiningProcessingError = errors.New("mining is in progress, please stop mining before starting") HasBeenStoppedError = errors.New("the mining has been stopped, please restart") MessageLengthIsZeroError = errors.New("message length must greater than 0") SignatureLengthIsZeroError = errors.New("signature length must greater than 0") NotHexStringError = errors.New("not hex string") LogLevelLengthIsZeroError = errors.New("the log level cannot be empty") LogAgeIsZeroError = errors.New("log age must be greater than 0") RotationTimeIsZeroError = errors.New("rotation time must be greater than 0") LogPathIsEmptyError = errors.New("the log path cannot be empty") BalanceNotEnoughError = errors.New("balance not enough") TxPoolIsNilError = errors.New("tx poll is nil") DataIsNotHexStringError = errors.New("data must be a hex string") PrivateKeyIsBlankError = errors.New("private key is blank") PrivateKeyIsNotHexStrError = errors.New("private key must be hex string") RotationTimeGreaterThanMaxAgeError = errors.New("rotation time must be less than max age") TxNonceLessThanAccountNonceError = errors.New("transaction nonce must be greater than account nonce") )
var ( HashLengthIsNot128Error = errors.New("hex hash length must be 128") SignLengthIsNot128Error = errors.New("hex signature length must be 128") BlockHeightError = errors.New("block height must be greater than 0") BlockNotExistError = errors.New("block not exist") NoConfirmBlockError = errors.New("no confirm block now") JsonTxHashIsNotHexStringError = errors.New("tx hash must be hex string") JsonTxValueInvalidError = errors.New("tx value invalid") JsonTxFeeInvalidError = errors.New("tx fee invalid") JsonTxChainIdInvalidError = errors.New("tx chain id invalid") JsonTxTypeIsEmptyError = errors.New("tx type is empty") TxPriorityInvalidError = errors.New("tx priority out of rang") PubKeyLengthInvalidError = errors.New("public key length is not 64") DataInvalidError = errors.New("tx data must be hex string") PubKeyIsNotHexStringError = errors.New("public key must be hex string") TxSignIsNotHexStringError = errors.New("tx signature must be hex string") CalculateTxHashInvalidError = errors.New("the calculated transaction hash is not equal to the transaction hash") CalculateTxFeeInvalidError = errors.New("the calculated transaction fee is not equal to the transaction fee") VerifyTxSignError = errors.New("verify signature failed") )
var (
ErrEmptyRPCListenList = errors.New("empty rpc listen list")
)
Errors
Functions ¶
func SetRpcConfig ¶
Types ¶
type AdminService ¶
type AdminService struct {
// contains filtered or unexported fields
}
AdminService implements the RPC admin service interface.
func (*AdminService) Accounts ¶
func (s *AdminService) Accounts(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.AccountsResponse, error)
Accounts is the RPC API handler.
func (*AdminService) GeneratePrivateKey ¶
func (s *AdminService) GeneratePrivateKey(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.PrivateKey, error)
Return the key pair
func (*AdminService) ImportAccount ¶
func (s *AdminService) ImportAccount(ctx context.Context, req *rpcpb.PrivKeyAndPassphrase) (*rpcpb.Address, error)
NewAccount create a new account with passphrase
func (*AdminService) LockAccount ¶
func (s *AdminService) LockAccount(ctx context.Context, req *rpcpb.LockAccountRequest) (*rpcpb.BoolResponse, error)
LockAccount lock address
func (*AdminService) Logging ¶
func (s *AdminService) Logging(ctx context.Context, req *rpcpb.LoggingInfo) (*rpcpb.LoggingInfo, error)
return Logging Info
func (*AdminService) NewAccount ¶
func (s *AdminService) NewAccount(ctx context.Context, req *rpcpb.PassphraseRequest) (*rpcpb.NewAccountResponse, error)
NewAccount generate a new address with passphrase
func (*AdminService) SendTransaction ¶
func (s *AdminService) SendTransaction(ctx context.Context, req *rpcpb.TransactionRequest) (*rpcpb.TransactionHash, error)
SendTransaction is the RPC API handler.
func (*AdminService) SendTransactionWithPassphrase ¶
func (s *AdminService) SendTransactionWithPassphrase(ctx context.Context, req *rpcpb.SendTransactionPassphraseRequest) (*rpcpb.TransactionHash, error)
SendTransactionWithPassphrase is the RPC API handler.
func (*AdminService) Sign ¶
func (s *AdminService) Sign(ctx context.Context, req *rpcpb.SignHashRequest) (*rpcpb.SignHashResponse, error)
SignHash is the RPC API handler.
func (*AdminService) SignTransactionWithPassphrase ¶
func (s *AdminService) SignTransactionWithPassphrase(ctx context.Context, req *rpcpb.SignTransactionPassphraseRequest) (*rpcpb.SignTransactionPassphraseResponse, error)
SignTransactionWithPassphrase is the RPC API handler.
func (*AdminService) StartMining ¶
func (s *AdminService) StartMining(ctx context.Context, req *rpcpb.PassphraseRequest) (*rpcpb.BoolResponse, error)
func (*AdminService) StartPprof ¶
func (s *AdminService) StartPprof(ctx context.Context, req *rpcpb.PprofRequest) (*rpcpb.PprofResponse, error)
StartPprof is the RPC API handler.
func (*AdminService) Stop ¶
func (s *AdminService) Stop(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.BoolResponse, error)
stop the server
func (*AdminService) StopMining ¶
func (s *AdminService) StopMining(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.BoolResponse, error)
func (*AdminService) UnlockAccount ¶
func (s *AdminService) UnlockAccount(ctx context.Context, req *rpcpb.UnlockAccountRequest) (*rpcpb.BoolResponse, error)
UnlockAccount unlock address with the passphrase
func (*AdminService) UpdateAccount ¶
func (s *AdminService) UpdateAccount(ctx context.Context, req *rpcpb.UpdateAccountRequest) (*rpcpb.BoolResponse, error)
NewAccount create a new account with passphrase
func (*AdminService) VerifyMessage ¶
func (s *AdminService) VerifyMessage(ctx context.Context, req *rpcpb.VerifyMessageRequest) (*rpcpb.BoolResponse, error)
Sign sign msg
type ApiService ¶
type ApiService struct {
// contains filtered or unexported fields
}
func (*ApiService) GetAccount ¶
func (api *ApiService) GetAccount(ctx context.Context, req *rpcpb.Address) (*rpcpb.AccountInfo, error)
get account info by address
func (*ApiService) GetActiveCount ¶
func (s *ApiService) GetActiveCount(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.ActiveCountResponse, error)
Return the p2p node info.
func (*ApiService) GetBalance ¶
func (s *ApiService) GetBalance(ctx context.Context, req *rpcpb.Address) (*rpcpb.BalanceResponse, error)
func (*ApiService) GetBestBlockByHeight ¶
func (api *ApiService) GetBestBlockByHeight(ctx context.Context, req *rpcpb.BlockHeightAndFull) (*rpcpb.BlockResponse, error)
get best block by height
func (*ApiService) GetBestBlockHash ¶
func (api *ApiService) GetBestBlockHash(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.BlockHash, error)
func (*ApiService) GetBlockByHash ¶
func (api *ApiService) GetBlockByHash(ctx context.Context, req *rpcpb.BlockHashAndFull) (*rpcpb.BlockResponse, error)
func (*ApiService) GetBlockChainInfo ¶
func (api *ApiService) GetBlockChainInfo(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.BlockChainInfo, error)
Return the block chain info
func (*ApiService) GetBlocksByHeight ¶
func (api *ApiService) GetBlocksByHeight(ctx context.Context, req *rpcpb.BlockHeightAndFull) (*rpcpb.BlockListResponse, error)
get best block by height
func (*ApiService) GetCreditIndex ¶
func (api *ApiService) GetCreditIndex(ctx context.Context, req *rpcpb.Address) (*rpcpb.CreditIndexResponse, error)
get creditIndex by address
func (*ApiService) GetMaxHeight ¶
func (api *ApiService) GetMaxHeight(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.BlockHeight, error)
get max block height
func (*ApiService) GetNetVersion ¶
func (s *ApiService) GetNetVersion(context.Context, *rpcpb.NonParamsRequest) (*rpcpb.NetVersion, error)
Return the p2p node info.
func (*ApiService) GetPendingTransactionsByPage ¶
func (api *ApiService) GetPendingTransactionsByPage(ctx context.Context, req *rpcpb.GetPendingTransactionsByPageRequest) (*rpcpb.PendingTransaction, error)
func (*ApiService) GetPendingTransactionsSize ¶
func (api *ApiService) GetPendingTransactionsSize(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.PendingTransactionsSize, error)
func (*ApiService) GetTransactionByContractAddress ¶
func (s *ApiService) GetTransactionByContractAddress(ctx context.Context, req *rpcpb.ContractAddressRequest) (*rpcpb.TransactionReceipt, error)
func (*ApiService) GetTransactionByHash ¶
func (s *ApiService) GetTransactionByHash(ctx context.Context, req *rpcpb.TransactionHash) (*rpcpb.TransactionReceipt, error)
func (*ApiService) NodeInfo ¶
func (s *ApiService) NodeInfo(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.NodeInfoResponse, error)
NodeInfo is the RPC API handler.
func (*ApiService) SendSignedTransaction ¶
func (s *ApiService) SendSignedTransaction(ctx context.Context, req *rpcpb.Transaction) (*rpcpb.BoolResponse, error)
send sign tx
type GRPCServer ¶
type GRPCServer interface { Start() error // Start start server Stop() // Stop stop server RunGateway() error }
GRPCServer server interface for api & management etc.
type RpcConfig ¶
type RpcConfig struct { RpcListen []string `yaml:"rpc_listen"` HttpListen []string `yaml:"http_listen"` HttpModule []string `yaml:"http_module"` HttpCors []string `yaml:"http_cors"` HttpLimits uint32 `yaml:"http_limits"` }
func GetRpcConfig ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the RPC server type.
func (*Server) RunGateway ¶
RunGateway run grpc mapping to http after apiserver have started.