Documentation ¶
Index ¶
- Variables
- type Info
- type MockPeer
- type Peer
- type TRISAPeer
- func (p *TRISAPeer) Close() (err error)
- func (p *TRISAPeer) ConfirmAddress(ctx context.Context, in *api.Address, opts ...grpc.CallOption) (*api.AddressConfirmation, error)
- func (p *TRISAPeer) Connect(opts ...grpc.DialOption) (err error)
- func (p *TRISAPeer) Info() (*Info, error)
- func (p *TRISAPeer) KeyExchange(ctx context.Context, in *api.SigningKey, opts ...grpc.CallOption) (*api.SigningKey, error)
- func (p *TRISAPeer) Name() string
- func (p *TRISAPeer) Status(ctx context.Context, in *api.HealthCheck, opts ...grpc.CallOption) (*api.ServiceState, error)
- func (p *TRISAPeer) String() string
- func (p *TRISAPeer) Transfer(ctx context.Context, in *api.SecureEnvelope, opts ...grpc.CallOption) (*api.SecureEnvelope, error)
- func (p *TRISAPeer) TransferStream(ctx context.Context, opts ...grpc.CallOption) (api.TRISANetwork_TransferStreamClient, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoCommonName = errors.New("a peer must have a unique common name") ErrNoEndpoint = errors.New("peer does not have an endpoint to connect on") ErrAlreadyConnected = errors.New("already connected to remote peer, cannot overide dialer") ErrNotConnected = errors.New("not connected to remote peer") )
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { ID string `json:"vasp_id"` RegisteredDirectory string `json:"registered_directory"` CommonName string `json:"common_name"` Endpoint string `json:"endpoint"` Name string `json:"name"` Country string `json:"country"` VerifiedOn time.Time `json:"verified_on"` }
Info provides detailed VASP counterparty information that can be looked up via the TRISA Global Directory Service (GDS). This data structure can also be used for identifying counterparties in TRISA transactions or other interactions with the GDS.
func (*Info) Counterparty ¶
func (i *Info) Counterparty() *api.Counterparty
Returns a counterparty data structure for API purposes.
func (*Info) Model ¶
func (i *Info) Model() *models.Counterparty
Returns a counterparty model data structure for TRISA interactions
type MockPeer ¶
type MockPeer struct { TRISAPeer // contains filtered or unexported fields }
MockPeer implements all of the functionality of a TRISAPeer and implements the Peer interface because a TRISAPeer is embedded. However, instead of connecting to a live remote TRISA node or requiring a TRISA config, it connects to a mock RemotePeer via bufconn to allow for robust testing outside of the package.
NOTE: the internal package tests test the TRISAPeer object directly, the MockPeer should only be used for tests outside of the package.
func (*MockPeer) GetMock ¶
func (m *MockPeer) GetMock() *mock.RemotePeer
type Peer ¶
type Peer interface { api.TRISANetworkClient api.TRISAHealthClient fmt.Stringer Name() string Info() (*Info, error) Connect(opts ...grpc.DialOption) error Close() error }
Peer objects should wrap (or mock) the TRISANetworkClient and TRISAHealthClient interfaces from the TRISA protocol buffers. Additionally, the Peer should provide an Info() method to return its identifying details as fetched from the directory service and a Name() method that returns the common name of the peer. A Peer is the primary mechanism for network interaction between TRISA nodes. A TRISA node should be able to identify a peer from an incoming request via the mTLS certificates used for authentication, or to select a remote Peer via a directory service lookup to make outgoing transfers. To facilitate remote connections, a Peer should be able to Connect using gRPC dial options. Mock peers can implement a bufconn connection, whereas actual peer-to-peer connections require mTLS credentials for connecting.
type TRISAPeer ¶
TRISAPeer implements the Peer interface and is used to directly connect to a remote TRISA node by wrapping a gRPC dial connection to the endpoint.
func (*TRISAPeer) Close ¶
Close the connection to the remote peer. Once called the peer must be reconnected before any gRPC methods can be called on the peer.
func (*TRISAPeer) ConfirmAddress ¶
func (p *TRISAPeer) ConfirmAddress(ctx context.Context, in *api.Address, opts ...grpc.CallOption) (*api.AddressConfirmation, error)
func (*TRISAPeer) Connect ¶
func (p *TRISAPeer) Connect(opts ...grpc.DialOption) (err error)
Connect to the remote peer by dialing the grpc endpoint with the specified options and credentials. Connect validates that the peer is correctly configured and must be called before any gRPC methods can be called on the peer.
func (*TRISAPeer) KeyExchange ¶
func (p *TRISAPeer) KeyExchange(ctx context.Context, in *api.SigningKey, opts ...grpc.CallOption) (*api.SigningKey, error)
func (*TRISAPeer) Status ¶
func (p *TRISAPeer) Status(ctx context.Context, in *api.HealthCheck, opts ...grpc.CallOption) (*api.ServiceState, error)
Status performs a health check against the remote TRISA node.
func (*TRISAPeer) String ¶
String returns the common name of the peer and can be used for hashing purposes.
func (*TRISAPeer) Transfer ¶
func (p *TRISAPeer) Transfer(ctx context.Context, in *api.SecureEnvelope, opts ...grpc.CallOption) (*api.SecureEnvelope, error)
func (*TRISAPeer) TransferStream ¶
func (p *TRISAPeer) TransferStream(ctx context.Context, opts ...grpc.CallOption) (api.TRISANetwork_TransferStreamClient, error)