Documentation ¶
Index ¶
- func DisableLog()
- func ServiceReady(service string) error
- func UseLogger(logger czzlog.Logger)
- type GrpcServer
- func (s *GrpcServer) GetAddressTransactions(ctx context.Context, req *pb.GetAddressTransactionsRequest) (*pb.GetAddressTransactionsResponse, error)
- func (s *GrpcServer) GetAddressUnspentOutputs(ctx context.Context, req *pb.GetAddressUnspentOutputsRequest) (*pb.GetAddressUnspentOutputsResponse, error)
- func (s *GrpcServer) GetBlock(ctx context.Context, req *pb.GetBlockRequest) (*pb.GetBlockResponse, error)
- func (s *GrpcServer) GetBlockFilter(ctx context.Context, req *pb.GetBlockFilterRequest) (*pb.GetBlockFilterResponse, error)
- func (s *GrpcServer) GetBlockInfo(ctx context.Context, req *pb.GetBlockInfoRequest) (*pb.GetBlockInfoResponse, error)
- func (s *GrpcServer) GetBlockchainInfo(ctx context.Context, req *pb.GetBlockchainInfoRequest) (*pb.GetBlockchainInfoResponse, error)
- func (s *GrpcServer) GetHeaders(ctx context.Context, req *pb.GetHeadersRequest) (*pb.GetHeadersResponse, error)
- func (s *GrpcServer) GetMempoolInfo(ctx context.Context, req *pb.GetMempoolInfoRequest) (*pb.GetMempoolInfoResponse, error)
- func (s *GrpcServer) GetMerkleProof(ctx context.Context, req *pb.GetMerkleProofRequest) (*pb.GetMerkleProofResponse, error)
- func (s *GrpcServer) GetRawAddressTransactions(ctx context.Context, req *pb.GetRawAddressTransactionsRequest) (*pb.GetRawAddressTransactionsResponse, error)
- func (s *GrpcServer) GetRawBlock(ctx context.Context, req *pb.GetRawBlockRequest) (*pb.GetRawBlockResponse, error)
- func (s *GrpcServer) GetRawTransaction(ctx context.Context, req *pb.GetRawTransactionRequest) (*pb.GetRawTransactionResponse, error)
- func (s *GrpcServer) GetTransaction(ctx context.Context, req *pb.GetTransactionRequest) (*pb.GetTransactionResponse, error)
- func (s *GrpcServer) NotifyNewTransactions(txs []*mempool.TxDesc)
- func (s *GrpcServer) Start()
- func (s *GrpcServer) Stop() error
- func (s *GrpcServer) SubmitTransaction(ctx context.Context, req *pb.SubmitTransactionRequest) (*pb.SubmitTransactionResponse, error)
- func (s *GrpcServer) SubscribeBlocks(req *pb.SubscribeBlocksRequest, stream pb.Czzrpc_SubscribeBlocksServer) error
- func (s *GrpcServer) SubscribeTransactionStream(stream pb.Czzrpc_SubscribeTransactionStreamServer) error
- func (s *GrpcServer) SubscribeTransactions(req *pb.SubscribeTransactionsRequest, ...) error
- type GrpcServerConfig
- type NetManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
func ServiceReady ¶
ServiceReady returns nil when the service is ready and a gRPC error when not.
Types ¶
type GrpcServer ¶
type GrpcServer struct {
// contains filtered or unexported fields
}
GrpcServer is the gRPC server implementation. It holds all the objects necessary to serve the RPCs and implements the czzrpc.proto interface.
func NewGrpcServer ¶
func NewGrpcServer(cfg *GrpcServerConfig) *GrpcServer
NewGrpcServer returns a new GrpcServer which has not yet be started.
func (*GrpcServer) GetAddressTransactions ¶
func (s *GrpcServer) GetAddressTransactions(ctx context.Context, req *pb.GetAddressTransactionsRequest) (*pb.GetAddressTransactionsResponse, error)
GetAddressTransactions returns the transactions for the given address. Offers offset, limit, and from block options.
**Requires AddressIndex**
func (*GrpcServer) GetAddressUnspentOutputs ¶
func (s *GrpcServer) GetAddressUnspentOutputs(ctx context.Context, req *pb.GetAddressUnspentOutputsRequest) (*pb.GetAddressUnspentOutputsResponse, error)
GetAddressUnspentOutputs returns all the unspent transaction outpoints for the given address. Offers offset, limit, and from block options.
**Requires AddressIndex**
func (*GrpcServer) GetBlock ¶
func (s *GrpcServer) GetBlock(ctx context.Context, req *pb.GetBlockRequest) (*pb.GetBlockResponse, error)
GetBlock returns a full block.
func (*GrpcServer) GetBlockFilter ¶
func (s *GrpcServer) GetBlockFilter(ctx context.Context, req *pb.GetBlockFilterRequest) (*pb.GetBlockFilterResponse, error)
GetBlockFilter returns a block filter.
**Requires CfIndex**
func (*GrpcServer) GetBlockInfo ¶
func (s *GrpcServer) GetBlockInfo(ctx context.Context, req *pb.GetBlockInfoRequest) (*pb.GetBlockInfoResponse, error)
GetBlockInfo returns info about the given block.
func (*GrpcServer) GetBlockchainInfo ¶
func (s *GrpcServer) GetBlockchainInfo(ctx context.Context, req *pb.GetBlockchainInfoRequest) (*pb.GetBlockchainInfoResponse, error)
GetBlockchainInfo returns info about the blockchain including the most recent block hash and height.
func (*GrpcServer) GetHeaders ¶
func (s *GrpcServer) GetHeaders(ctx context.Context, req *pb.GetHeadersRequest) (*pb.GetHeadersResponse, error)
GetHeaders sends a block locator object to the server and the server responds with a batch of no more than 2000 headers. Upon parsing the block locator, if the server concludes there has been a fork, it will send headers starting at the fork point, or genesis if no blocks in the locator are in the best chain. If the locator is already at the tip no headers will be returned.
func (*GrpcServer) GetMempoolInfo ¶
func (s *GrpcServer) GetMempoolInfo(ctx context.Context, req *pb.GetMempoolInfoRequest) (*pb.GetMempoolInfoResponse, error)
GetMempoolInfo returns info about the mempool.
func (*GrpcServer) GetMerkleProof ¶
func (s *GrpcServer) GetMerkleProof(ctx context.Context, req *pb.GetMerkleProofRequest) (*pb.GetMerkleProofResponse, error)
GetMerkleProof returns a merkle (SPV) proof that the given transaction is in the provided block.
**Requires TxIndex***
func (*GrpcServer) GetRawAddressTransactions ¶
func (s *GrpcServer) GetRawAddressTransactions(ctx context.Context, req *pb.GetRawAddressTransactionsRequest) (*pb.GetRawAddressTransactionsResponse, error)
GetRawAddressTransactions returns the raw transactions for the given address. Offers offset, limit, and from block options.
**Requires AddressIndex**
func (*GrpcServer) GetRawBlock ¶
func (s *GrpcServer) GetRawBlock(ctx context.Context, req *pb.GetRawBlockRequest) (*pb.GetRawBlockResponse, error)
GetRawBlock returns a full serialized block.
func (*GrpcServer) GetRawTransaction ¶
func (s *GrpcServer) GetRawTransaction(ctx context.Context, req *pb.GetRawTransactionRequest) (*pb.GetRawTransactionResponse, error)
GetRawTransaction returns a serialized transaction given its hash.
**Requires TxIndex**
func (*GrpcServer) GetTransaction ¶
func (s *GrpcServer) GetTransaction(ctx context.Context, req *pb.GetTransactionRequest) (*pb.GetTransactionResponse, error)
GetTransaction returns a transaction given its hash.
**Requires TxIndex**
func (*GrpcServer) NotifyNewTransactions ¶
func (s *GrpcServer) NotifyNewTransactions(txs []*mempool.TxDesc)
NotifyNewTransactions is called by the server when new transactions are accepted in the mempool.
func (*GrpcServer) Start ¶
func (s *GrpcServer) Start()
Start will start the GrpcServer, subscribe to blockchain notifications and start the EventDispatcher in a new goroutine.
func (*GrpcServer) Stop ¶
func (s *GrpcServer) Stop() error
Stop is used by server.go to stop the gRPC listener.
func (*GrpcServer) SubmitTransaction ¶
func (s *GrpcServer) SubmitTransaction(ctx context.Context, req *pb.SubmitTransactionRequest) (*pb.SubmitTransactionResponse, error)
SubmitTransaction submits a transaction to all connected peers.
func (*GrpcServer) SubscribeBlocks ¶
func (s *GrpcServer) SubscribeBlocks(req *pb.SubscribeBlocksRequest, stream pb.Czzrpc_SubscribeBlocksServer) error
SubscribeBlocks subscribes to notifications of new blocks being connected to the blockchain or blocks being disconnected.
func (*GrpcServer) SubscribeTransactionStream ¶
func (s *GrpcServer) SubscribeTransactionStream(stream pb.Czzrpc_SubscribeTransactionStreamServer) error
SubscribeTransactionStream subscribes to relevant transactions based on the subscription requests. The parameters to filter transactions on can be updated by sending new SubscribeTransactionsRequest objects on the stream.
Because this RPC using bi-directional streaming it cannot be used with grpc-web.
**Requires TxIndex to receive input metadata**
func (*GrpcServer) SubscribeTransactions ¶
func (s *GrpcServer) SubscribeTransactions(req *pb.SubscribeTransactionsRequest, stream pb.Czzrpc_SubscribeTransactionsServer) error
SubscribeTransactions subscribes to relevant transactions based on the subscription requests. The parameters to filter transactions on can be updated by sending new SubscribeTransactionsRequest objects on the stream.
This RPC does not use bi-directional streams and therefore can be used with grpc-web. You will need to close and re-open the stream whenever you want to update the addresses. If you are not using grpc-web then SubscribeTransactionStream is more appropriate.
**Requires TxIndex to receive input metadata**
type GrpcServerConfig ¶
type GrpcServerConfig struct { Server *grpc.Server HTTPServer *http.Server TimeSource blockchain.MedianTimeSource Chain *blockchain.BlockChain ChainParams *chaincfg.Params DB database.DB TxMemPool *mempool.TxPool NetMgr NetManager TxIndex *indexers.TxIndex AddrIndex *indexers.AddrIndex CfIndex *indexers.CfIndex }
GrpcServerConfig hols the various objects needed by the GrpcServer to perform its functions.
type NetManager ¶
type NetManager interface { // AddRebroadcastInventory adds 'iv' to the list of inventories to be // rebroadcasted at random intervals until they show up in a block. AddRebroadcastInventory(iv *wire.InvVect, data interface{}) // AnnounceNewTransactions generates and relays inventory vectors and notifies // both websocket and getblocktemplate long poll clients of the passed // transactions. This function should be called whenever new transactions // are added to the mempool. AnnounceNewTransactions(txns []*mempool.TxDesc) }
NetManager is an interface which provides functions for handling new transactions. This is used by the SubmitTransaction RPC to notify the rest of the system a new transaction needs to be handled.