// New creates new protocol client.
New creates new protocol client.
// New creates new protocol client .
func New(protocolVersions []protocol.Version, opts ...Option) (*Client, error) {
	if len(protocolVersions) == 0 {
		return nil, fmt.Errorf("must provide at least one protocol version")
	}
	var protocols []protocol.Version
	protocols = append(protocols, protocolVersions...)
	sort.SliceStable(protocols, func(i, j int) bool {
		return protocols[j].Protocol().GenesisTime > protocols[i].Protocol().GenesisTime
	})
	client := &Client{
		protocols: protocols,
		current:   protocols[len(protocols)-1],
	}
	for _, opt := range opts {
		opt(client)
	}
	return client, nil
}
func New ( protocolVersions [ ] protocol . Version , opts ... Option ) ( * Client , error ) { if len ( protocolVersions ) == 0 { return nil , fmt . Errorf ( " " ) } var protocols [ ] protocol . Version protocols = append ( protocols , protocolVersions ... ) sort . SliceStable ( protocols , func ( i , j int ) bool { return protocols [ j ] . Protocol ( ) . GenesisTime > protocols [ i ] . Protocol ( ) . GenesisTime } ) client := & Client { protocols : protocols , current : protocols [ len ( protocols ) - 1 ] , } for _ , opt := range opts { opt ( client ) } return client , nil }
New creates new protocol client.
New creates new protocol client .
// Creating the list of the protocol versions // Sorting the protocolParameter list based on protocol genesis time // apply options