Documentation ¶
Index ¶
- Constants
- func AddPemToCertPool(pemCerts []byte, pool *x509.CertPool) error
- func BuildGetBlockByNumberProposal(creator []byte, signer *ecdsa.PrivateKey, channel string, number uint64) (*pb.SignedProposal, error)
- func BuildGetChainInfoProposal(creator []byte, signer *ecdsa.PrivateKey, channel string) (*pb.SignedProposal, error)
- func BuildQueryTxProposal(creator []byte, signer *ecdsa.PrivateKey, channel, txID string) (*pb.SignedProposal, error)
- func GetBlockByNumber(peerClient *PeerClient, channel string, number uint64, creator []byte, ...) (*common.Block, error)
- func GetChainInfo(peerClient *PeerClient, channel string, creator []byte, ...) (*common.BlockchainInfo, error)
- func GetHeight(peerClient *PeerClient, channel string, creator []byte, ...) (uint64, error)
- func InitRetracer(config RetraceConf) *retracer
- func UnmarshalBlockFromProposalResponse(response *pb.ProposalResponse) (*common.Block, error)
- func UnmarshalChainInfoFromProposalResponse(response *pb.ProposalResponse) (*common.BlockchainInfo, error)
- type ChaincodeEventInfo
- type ClientConfig
- type GRPCClient
- func (client *GRPCClient) Certificate() tls.Certificate
- func (client *GRPCClient) MutualTLSRequired() bool
- func (client *GRPCClient) NewConnection(address string, serverNameOverride string) (*grpc.ClientConn, error)
- func (client *GRPCClient) SetMaxRecvMsgSize(size int)
- func (client *GRPCClient) SetMaxSendMsgSize(size int)
- func (client *GRPCClient) SetServerRootCAs(serverRoots [][]byte) error
- func (client *GRPCClient) TLSEnabled() bool
- type KeepaliveOptions
- type PeerClient
- func (pc *PeerClient) Broadcast() (ab.AtomicBroadcast_BroadcastClient, error)
- func (pc *PeerClient) Endorser() (pb.EndorserClient, error)
- func (pc *PeerClient) SetEndorserClient(grpcClient *GRPCClient)
- func (pc *PeerClient) SetOrdererClient(ordererClient *GRPCClient)
- func (pc *PeerClient) StartEvent(adapter consumer.EventAdapter) (*consumer.EventsClient, error)
- type RetraceConf
- type SecureOptions
- type TransactionHandler
- func (th *TransactionHandler) CreateProposal(chainId string, chaincodeName string, chaincodeVersion string, funcName string, ...) (*pb.Proposal, string, error)
- func (th *TransactionHandler) CreateProposalWithTxGenerator(chainId string, chaincodeName string, chaincodeVersion string, funcName string, ...) (*pb.Proposal, string, error)
- func (th *TransactionHandler) HandleUserToCEvent(userToC ChaincodeEventInfo, ...)
- func (th *TransactionHandler) Init(signer interface{}, creator []byte) error
- func (th *TransactionHandler) ListenEvent(userToCChan chan ChaincodeEventInfo)
- func (th *TransactionHandler) ProcessProposal(signer *ecdsa.PrivateKey, prop *pb.Proposal) (*pb.ProposalResponse, error)
- func (th *TransactionHandler) RegisterTxId(txid string, c chan int, cid string, cc chan interface{})
- func (th *TransactionHandler) SendTransaction(prop *pb.Proposal, signer *ecdsa.PrivateKey, creator []byte, ...) error
- func (th *TransactionHandler) UnregisterCId(cid string)
- func (th *TransactionHandler) UnregisterTxId(txid string)
Constants ¶
const (
AttemptCount = 3
)
const RETRACE_FILE_NAME = "./retrace.json"
Variables ¶
This section is empty.
Functions ¶
func AddPemToCertPool ¶
AddPemToCertPool adds PEM-encoded certs to a cert pool
func BuildGetBlockByNumberProposal ¶
func BuildGetBlockByNumberProposal(creator []byte, signer *ecdsa.PrivateKey, channel string, number uint64) (*pb.SignedProposal, error)
func BuildGetChainInfoProposal ¶
func BuildGetChainInfoProposal(creator []byte, signer *ecdsa.PrivateKey, channel string) (*pb.SignedProposal, error)
func BuildQueryTxProposal ¶
func BuildQueryTxProposal(creator []byte, signer *ecdsa.PrivateKey, channel, txID string) (*pb.SignedProposal, error)
func GetBlockByNumber ¶
func GetBlockByNumber(peerClient *PeerClient, channel string, number uint64, creator []byte, signer *ecdsa.PrivateKey) (*common.Block, error)
func GetChainInfo ¶
func GetChainInfo(peerClient *PeerClient, channel string, creator []byte, signer *ecdsa.PrivateKey) (*common.BlockchainInfo, error)
func GetHeight ¶
func GetHeight(peerClient *PeerClient, channel string, creator []byte, signer *ecdsa.PrivateKey) (uint64, error)
func InitRetracer ¶
func InitRetracer(config RetraceConf) *retracer
func UnmarshalBlockFromProposalResponse ¶
func UnmarshalBlockFromProposalResponse(response *pb.ProposalResponse) (*common.Block, error)
func UnmarshalChainInfoFromProposalResponse ¶
func UnmarshalChainInfoFromProposalResponse(response *pb.ProposalResponse) (*common.BlockchainInfo, error)
Types ¶
type ChaincodeEventInfo ¶
type ClientConfig ¶
type ClientConfig struct { // SecOpts defines the security parameters SecOpts *SecureOptions // KaOpts defines the keepalive parameters KaOpts *KeepaliveOptions // Timeout specifies how long the client will block when attempting to // establish a connection Timeout time.Duration }
ClientConfig defines the parameters for configuring a GRPCClient instance
func ConfigFromEnv ¶
func ConfigFromEnv(env map[interface{}]interface{}) (address, override, eventAddress string, clientConfig ClientConfig, err error)
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
func NewGRPCClient ¶
func NewGRPCClient(config ClientConfig) (*GRPCClient, error)
NewGRPCClient creates a new implementation of GRPCClient given an address and client configuration
func (*GRPCClient) Certificate ¶
func (client *GRPCClient) Certificate() tls.Certificate
Certificate returns the tls.Certificate used to make TLS connections when client certificates are required by the server
func (*GRPCClient) MutualTLSRequired ¶
func (client *GRPCClient) MutualTLSRequired() bool
MutualTLSRequired is a flag indicating whether the client must send a certificate when making TLS connections
func (*GRPCClient) NewConnection ¶
func (client *GRPCClient) NewConnection(address string, serverNameOverride string) ( *grpc.ClientConn, error)
NewConnection returns a grpc.ClientConn for the target address and overrides the server name used to verify the hostname on the certificate returned by a server when using TLS
func (*GRPCClient) SetMaxRecvMsgSize ¶
func (client *GRPCClient) SetMaxRecvMsgSize(size int)
SetMaxRecvMsgSize sets the maximum message size the client can receive
func (*GRPCClient) SetMaxSendMsgSize ¶
func (client *GRPCClient) SetMaxSendMsgSize(size int)
SetMaxSendMsgSize sets the maximum message size the client can send
func (*GRPCClient) SetServerRootCAs ¶
func (client *GRPCClient) SetServerRootCAs(serverRoots [][]byte) error
SetServerRootCAs sets the list of authorities used to verify server certificates based on a list of PEM-encoded X509 certificate authorities
func (*GRPCClient) TLSEnabled ¶
func (client *GRPCClient) TLSEnabled() bool
TLSEnabled is a flag indicating whether to use TLS for client connections
type KeepaliveOptions ¶
type KeepaliveOptions struct { // ClientInterval is the duration after which if the client does not see // any activity from the server it pings the server to see if it is alive ClientInterval time.Duration // ClientTimeout is the duration the client waits for a response // from the server after sending a ping before closing the connection ClientTimeout time.Duration // ServerInterval is the duration after which if the server does not see // any activity from the client it pings the client to see if it is alive ServerInterval time.Duration // ServerTimeout is the duration the server waits for a response // from the client after sending a ping before closing the connection ServerTimeout time.Duration // ServerMinInterval is the minimum permitted time between client pings. // If clients send pings more frequently, the server will disconnect them ServerMinInterval time.Duration }
KeepAliveOptions is used to set the gRPC keepalive settings for both clients and servers
type PeerClient ¶
type PeerClient struct {
// contains filtered or unexported fields
}
func NewPeerClient ¶
func NewPeerClient( grpcClient *GRPCClient, ordererClient *GRPCClient, endorserAddress string, sn string, eventAddress string, ordererAddress string, orderersn string) *PeerClient
func (*PeerClient) Broadcast ¶
func (pc *PeerClient) Broadcast() (ab.AtomicBroadcast_BroadcastClient, error)
func (*PeerClient) Endorser ¶
func (pc *PeerClient) Endorser() (pb.EndorserClient, error)
func (*PeerClient) SetEndorserClient ¶
func (pc *PeerClient) SetEndorserClient(grpcClient *GRPCClient)
func (*PeerClient) SetOrdererClient ¶
func (pc *PeerClient) SetOrdererClient(ordererClient *GRPCClient)
func (*PeerClient) StartEvent ¶
func (pc *PeerClient) StartEvent(adapter consumer.EventAdapter) (*consumer.EventsClient, error)
type RetraceConf ¶
type RetraceConf struct { PeerClient *PeerClient Channel string RetraceInterval time.Duration Creator []byte Signer interface{} }
type SecureOptions ¶
type SecureOptions struct { // PEM-encoded X509 public key to be used for TLS communication Certificate []byte // PEM-encoded private key to be used for TLS communication Key []byte // Set of PEM-encoded X509 certificate authorities used by clients to // verify server certificates ServerRootCAs [][]byte // Set of PEM-encoded X509 certificate authorities used by servers to // verify client certificates ClientRootCAs [][]byte // Whether or not to use TLS for communication UseTLS bool // Whether or not TLS client must present certificates for authentication RequireClientCert bool // CipherSuites is a list of supported cipher suites for TLS CipherSuites []uint16 }
SecureOptions defines the security parameters (e.g. TLS) for a GRPCServer instance
type TransactionHandler ¶
type TransactionHandler struct { PeerClient *PeerClient RegisteredTxEvent map[string]chan int RegisteredEventByCId map[string]chan interface{} // contains filtered or unexported fields }
func (*TransactionHandler) CreateProposal ¶
func (*TransactionHandler) CreateProposalWithTxGenerator ¶
func (*TransactionHandler) HandleUserToCEvent ¶
func (th *TransactionHandler) HandleUserToCEvent(userToC ChaincodeEventInfo, sendRawTransaction func(bool, string, ...interface{}) (string, error), getTransactionReceipt func(string) (map[string]interface{}, error), rollback func(ChaincodeEventInfo))
func (*TransactionHandler) Init ¶
func (th *TransactionHandler) Init(signer interface{}, creator []byte) error
func (*TransactionHandler) ListenEvent ¶
func (th *TransactionHandler) ListenEvent(userToCChan chan ChaincodeEventInfo)
func (*TransactionHandler) ProcessProposal ¶
func (th *TransactionHandler) ProcessProposal(signer *ecdsa.PrivateKey, prop *pb.Proposal) (*pb.ProposalResponse, error)
func (*TransactionHandler) RegisterTxId ¶
func (th *TransactionHandler) RegisterTxId(txid string, c chan int, cid string, cc chan interface{})
c=1 重新发送 mytx c=2 mytx 成功 c=3 所有节点发送成功,整体事件成功 c=4 回滚 c=5 回滚成功
func (*TransactionHandler) SendTransaction ¶
func (th *TransactionHandler) SendTransaction(prop *pb.Proposal, signer *ecdsa.PrivateKey, creator []byte, proposalResp *pb.ProposalResponse) error
func (*TransactionHandler) UnregisterCId ¶
func (th *TransactionHandler) UnregisterCId(cid string)
func (*TransactionHandler) UnregisterTxId ¶
func (th *TransactionHandler) UnregisterTxId(txid string)