Documentation ¶
Overview ¶
Package api provides the local go-spacemesh API endpoints. e.g. json-http and grpc-http2
Index ¶
- Constants
- func ApproveAPIGossipMessages(ctx context.Context, s Service)
- type GenesisTimeAPI
- type JSONHTTPServer
- type LoggingAPI
- type MiningAPI
- type NetworkAPI
- type OracleAPI
- type PeerCounter
- type PostAPI
- type Service
- type SpacemeshGrpcService
- func (s SpacemeshGrpcService) Broadcast(ctx context.Context, in *pb.BroadcastMessage) (*pb.SimpleMessage, error)
- func (s SpacemeshGrpcService) BroadcastPoet(ctx context.Context, in *pb.BinaryMessage) (*pb.SimpleMessage, error)
- func (s SpacemeshGrpcService) Close() error
- func (s SpacemeshGrpcService) Echo(ctx context.Context, in *pb.SimpleMessage) (*pb.SimpleMessage, error)
- func (s SpacemeshGrpcService) GetAccountRewards(ctx context.Context, account *pb.AccountId) (*pb.AccountRewards, error)
- func (s SpacemeshGrpcService) GetAccountTxs(ctx context.Context, txsSinceLayer *pb.GetTxsSinceLayer) (*pb.AccountTxs, error)
- func (s SpacemeshGrpcService) GetBalance(ctx context.Context, in *pb.AccountId) (*pb.SimpleMessage, error)
- func (s SpacemeshGrpcService) GetGenesisTime(ctx context.Context, empty *empty.Empty) (*pb.SimpleMessage, error)
- func (s SpacemeshGrpcService) GetMiningStats(ctx context.Context, empty *empty.Empty) (*pb.MiningStats, error)
- func (s SpacemeshGrpcService) GetNodeStatus(context.Context, *empty.Empty) (*pb.NodeStatus, error)
- func (s SpacemeshGrpcService) GetNonce(ctx context.Context, in *pb.AccountId) (*pb.SimpleMessage, error)
- func (s SpacemeshGrpcService) GetStateRoot(ctx context.Context, empty *empty.Empty) (*pb.SimpleMessage, error)
- func (s SpacemeshGrpcService) GetTransaction(ctx context.Context, txId *pb.TransactionId) (*pb.Transaction, error)
- func (s SpacemeshGrpcService) GetUpcomingAwards(ctx context.Context, empty *empty.Empty) (*pb.EligibleLayers, error)
- func (s SpacemeshGrpcService) ResetPost(ctx context.Context, empty *empty.Empty) (*pb.SimpleMessage, error)
- func (s SpacemeshGrpcService) SetAwardsAddress(ctx context.Context, id *pb.AccountId) (*pb.SimpleMessage, error)
- func (s SpacemeshGrpcService) SetLoggerLevel(ctx context.Context, msg *pb.SetLogLevel) (*pb.SimpleMessage, error)
- func (s SpacemeshGrpcService) StartMining(ctx context.Context, message *pb.InitPost) (*pb.SimpleMessage, error)
- func (s SpacemeshGrpcService) StartService()
- func (s SpacemeshGrpcService) SubmitTransaction(ctx context.Context, in *pb.SignedTransaction) (*pb.TxConfirmation, error)
- type StateAPI
- type Syncer
- type TxAPI
Constants ¶
const APIGossipProtocol = "api_test_gossip"
Variables ¶
This section is empty.
Functions ¶
func ApproveAPIGossipMessages ¶
ApproveAPIGossipMessages registers the gossip api test protocol and approves every message as valid
Types ¶
type GenesisTimeAPI ¶
type JSONHTTPServer ¶
JSONHTTPServer is a JSON http server providing the Spacemesh API. It is implemented using a grpc-gateway. See https://github.com/grpc-ecosystem/grpc-gateway .
func NewJSONHTTPServer ¶
func NewJSONHTTPServer(port int, grpcPort int) *JSONHTTPServer
NewJSONHTTPServer creates a new json http server.
func (*JSONHTTPServer) Close ¶ added in v0.1.6
func (s *JSONHTTPServer) Close() error
Close stops the server.
func (*JSONHTTPServer) StartService ¶
func (s *JSONHTTPServer) StartService()
StartService starts the json api server and listens for status (started, stopped).
type LoggingAPI ¶
type MiningAPI ¶
type MiningAPI interface { StartPost(address types.Address, datadir string, space uint64) error SetCoinbaseAccount(rewardAddress types.Address) // MiningStats returns state of post init, coinbase reward account and data directory path for post commitment MiningStats() (postStatus int, remainingBytes uint64, coinbaseAccount string, postDatadir string) }
type NetworkAPI ¶
type PeerCounter ¶
type PeerCounter interface {
PeerCount() uint64
}
type Service ¶
type Service interface {
RegisterGossipProtocol(string, priorityq.Priority) chan service.GossipMessage
}
type SpacemeshGrpcService ¶
type SpacemeshGrpcService struct { Server *grpc.Server Port uint StateApi StateAPI // State DB Network NetworkAPI // P2P Swarm Tx TxAPI // Mesh TxMempool *miner.TxMempool // TX Mempool Mining MiningAPI // ATX Builder Oracle OracleAPI GenTime GenesisTimeAPI Post PostAPI LayerDuration time.Duration PeerCounter PeerCounter Syncer Syncer Config *config.Config Logging LoggingAPI }
SpacemeshGrpcService is a grpc server providing the Spacemesh api
func NewGrpcService ¶
func NewGrpcService(port int, net NetworkAPI, state StateAPI, tx TxAPI, txMempool *miner.TxMempool, mining MiningAPI, oracle OracleAPI, genTime GenesisTimeAPI, post PostAPI, layerDurationSec int, syncer Syncer, cfg *config.Config, logging LoggingAPI) *SpacemeshGrpcService
NewGrpcService create a new grpc service using config data.
func (SpacemeshGrpcService) Broadcast ¶
func (s SpacemeshGrpcService) Broadcast(ctx context.Context, in *pb.BroadcastMessage) (*pb.SimpleMessage, error)
func (SpacemeshGrpcService) BroadcastPoet ¶
func (s SpacemeshGrpcService) BroadcastPoet(ctx context.Context, in *pb.BinaryMessage) (*pb.SimpleMessage, error)
func (SpacemeshGrpcService) Close ¶ added in v0.1.6
func (s SpacemeshGrpcService) Close() error
Close stops the grpc service.
func (SpacemeshGrpcService) Echo ¶
func (s SpacemeshGrpcService) Echo(ctx context.Context, in *pb.SimpleMessage) (*pb.SimpleMessage, error)
Echo returns the response for an echo api request
func (SpacemeshGrpcService) GetAccountRewards ¶
func (s SpacemeshGrpcService) GetAccountRewards(ctx context.Context, account *pb.AccountId) (*pb.AccountRewards, error)
func (SpacemeshGrpcService) GetAccountTxs ¶
func (s SpacemeshGrpcService) GetAccountTxs(ctx context.Context, txsSinceLayer *pb.GetTxsSinceLayer) (*pb.AccountTxs, error)
func (SpacemeshGrpcService) GetBalance ¶
func (s SpacemeshGrpcService) GetBalance(ctx context.Context, in *pb.AccountId) (*pb.SimpleMessage, error)
GetBalance returns the current account balance for the provided account ID. The balance is based on the global state and all known transactions in unapplied blocks and the mempool that originate from the given account. Unapplied transactions coming INTO the given account (from mempool or unapplied blocks) are NOT counted.
func (SpacemeshGrpcService) GetGenesisTime ¶
func (s SpacemeshGrpcService) GetGenesisTime(ctx context.Context, empty *empty.Empty) (*pb.SimpleMessage, error)
func (SpacemeshGrpcService) GetMiningStats ¶
func (s SpacemeshGrpcService) GetMiningStats(ctx context.Context, empty *empty.Empty) (*pb.MiningStats, error)
func (SpacemeshGrpcService) GetNodeStatus ¶
func (s SpacemeshGrpcService) GetNodeStatus(context.Context, *empty.Empty) (*pb.NodeStatus, error)
func (SpacemeshGrpcService) GetNonce ¶
func (s SpacemeshGrpcService) GetNonce(ctx context.Context, in *pb.AccountId) (*pb.SimpleMessage, error)
GetNonce returns the current account nonce for the provided account ID. The nonce is based on the global state and all known transactions in unapplied blocks and the mempool.
func (SpacemeshGrpcService) GetStateRoot ¶
func (s SpacemeshGrpcService) GetStateRoot(ctx context.Context, empty *empty.Empty) (*pb.SimpleMessage, error)
func (SpacemeshGrpcService) GetTransaction ¶
func (s SpacemeshGrpcService) GetTransaction(ctx context.Context, txId *pb.TransactionId) (*pb.Transaction, error)
func (SpacemeshGrpcService) GetUpcomingAwards ¶
func (s SpacemeshGrpcService) GetUpcomingAwards(ctx context.Context, empty *empty.Empty) (*pb.EligibleLayers, error)
func (SpacemeshGrpcService) ResetPost ¶
func (s SpacemeshGrpcService) ResetPost(ctx context.Context, empty *empty.Empty) (*pb.SimpleMessage, error)
func (SpacemeshGrpcService) SetAwardsAddress ¶
func (s SpacemeshGrpcService) SetAwardsAddress(ctx context.Context, id *pb.AccountId) (*pb.SimpleMessage, error)
func (SpacemeshGrpcService) SetLoggerLevel ¶
func (s SpacemeshGrpcService) SetLoggerLevel(ctx context.Context, msg *pb.SetLogLevel) (*pb.SimpleMessage, error)
func (SpacemeshGrpcService) StartMining ¶
func (s SpacemeshGrpcService) StartMining(ctx context.Context, message *pb.InitPost) (*pb.SimpleMessage, error)
func (SpacemeshGrpcService) StartService ¶
func (s SpacemeshGrpcService) StartService()
StartService starts the grpc service.
func (SpacemeshGrpcService) SubmitTransaction ¶
func (s SpacemeshGrpcService) SubmitTransaction(ctx context.Context, in *pb.SignedTransaction) (*pb.TxConfirmation, error)
type TxAPI ¶
type TxAPI interface { AddressExists(addr types.Address) bool ValidateNonceAndBalance(transaction *types.Transaction) error GetRewards(account types.Address) (rewards []types.Reward, err error) GetTransactionsByDestination(l types.LayerID, account types.Address) (txs []types.TransactionId) GetTransactionsByOrigin(l types.LayerID, account types.Address) (txs []types.TransactionId) LatestLayer() types.LayerID GetLayerApplied(txId types.TransactionId) *types.LayerID GetTransaction(id types.TransactionId) (*types.Transaction, error) GetProjection(addr types.Address, prevNonce, prevBalance uint64) (nonce, balance uint64, err error) LatestLayerInState() types.LayerID GetStateRoot() types.Hash32 }