From e4c3339c911140bf2ab74b35c91a9ceff5a214e0 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 1 Dec 2020 11:40:58 +0300 Subject: [PATCH] util: move `Fixed8` to encoding/fixedn package --- cli/flags/fixed8.go | 10 +++---- cli/flags/fixed8_test.go | 10 +++---- cli/nep17_test.go | 10 +++---- cli/smartcontract/smart_contract.go | 3 +- cli/wallet/nep17.go | 5 ++-- pkg/core/helper_test.go | 5 ++-- pkg/core/state/notification_event.go | 5 ++-- pkg/core/transaction/transaction.go | 29 ++++++++++---------- pkg/core/transaction/transaction_test.go | 5 ++-- pkg/{util => encoding/fixedn}/fixed8.go | 2 +- pkg/{util => encoding/fixedn}/fixed8_test.go | 2 +- pkg/rpc/client/rpc.go | 7 +++-- pkg/rpc/client/rpc_test.go | 3 +- pkg/rpc/response/result/invoke.go | 6 ++-- pkg/rpc/response/result/invoke_test.go | 4 +-- pkg/rpc/rpc_config.go | 10 ++++--- 16 files changed, 63 insertions(+), 53 deletions(-) rename pkg/{util => encoding/fixedn}/fixed8.go (99%) rename pkg/{util => encoding/fixedn}/fixed8_test.go (99%) diff --git a/cli/flags/fixed8.go b/cli/flags/fixed8.go index 919652fb8..2f4a16d76 100644 --- a/cli/flags/fixed8.go +++ b/cli/flags/fixed8.go @@ -4,13 +4,13 @@ import ( "flag" "strings" - "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/urfave/cli" ) // Fixed8 is a wrapper for Uint160 with flag.Value methods. type Fixed8 struct { - Value util.Fixed8 + Value fixedn.Fixed8 } // Fixed8Flag is a flag with type string. @@ -32,7 +32,7 @@ func (a Fixed8) String() string { // Set implements flag.Value interface. func (a *Fixed8) Set(s string) error { - f, err := util.Fixed8FromString(s) + f, err := fixedn.Fixed8FromString(s) if err != nil { return cli.NewExitError(err, 1) } @@ -41,7 +41,7 @@ func (a *Fixed8) Set(s string) error { } // Fixed8 casts address to util.Fixed8. -func (a *Fixed8) Fixed8() util.Fixed8 { +func (a *Fixed8) Fixed8() fixedn.Fixed8 { return a.Value } @@ -70,6 +70,6 @@ func (f Fixed8Flag) Apply(set *flag.FlagSet) { } // Fixed8FromContext returns parsed util.Fixed8 value provided flag name. -func Fixed8FromContext(ctx *cli.Context, name string) util.Fixed8 { +func Fixed8FromContext(ctx *cli.Context, name string) fixedn.Fixed8 { return ctx.Generic(name).(*Fixed8).Value } diff --git a/cli/flags/fixed8_test.go b/cli/flags/fixed8_test.go index 62004b1c4..3eb344504 100644 --- a/cli/flags/fixed8_test.go +++ b/cli/flags/fixed8_test.go @@ -5,12 +5,12 @@ import ( "io/ioutil" "testing" - "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/stretchr/testify/require" ) func TestFixed8_String(t *testing.T) { - value := util.Fixed8(123) + value := fixedn.Fixed8(123) f := Fixed8{ Value: value, } @@ -19,7 +19,7 @@ func TestFixed8_String(t *testing.T) { } func TestFixed8_Set(t *testing.T) { - value := util.Fixed8(123) + value := fixedn.Fixed8(123) f := Fixed8{} require.Error(t, f.Set("not-a-fixed8")) @@ -30,10 +30,10 @@ func TestFixed8_Set(t *testing.T) { func TestFixed8_Fixed8(t *testing.T) { f := Fixed8{ - Value: util.Fixed8(123), + Value: fixedn.Fixed8(123), } - require.Equal(t, util.Fixed8(123), f.Fixed8()) + require.Equal(t, fixedn.Fixed8(123), f.Fixed8()) } func TestFixed8Flag_String(t *testing.T) { diff --git a/cli/nep17_test.go b/cli/nep17_test.go index 78ecb478c..a5ca20494 100644 --- a/cli/nep17_test.go +++ b/cli/nep17_test.go @@ -10,7 +10,7 @@ import ( "testing" "github.com/nspcc-dev/neo-go/pkg/encoding/address" - "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/stretchr/testify/require" ) @@ -47,7 +47,7 @@ func TestNEP17Balance(t *testing.T) { e.checkNextLine(t, "^\\s*Account\\s+"+validatorAddr) e.checkNextLine(t, "^\\s*GAS:\\s+GAS \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") b := e.Chain.GetUtilityTokenBalance(validatorHash) - e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+util.Fixed8(b.Int64()).String()) + e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(b.Int64()).String()) }) t.Run("all accounts", func(t *testing.T) { e.Run(t, cmdbase...) @@ -56,7 +56,7 @@ func TestNEP17Balance(t *testing.T) { e.checkNextLine(t, "^Account "+address.Uint160ToString(addr1)) e.checkNextLine(t, "^\\s*GAS:\\s+GAS \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") balance := e.Chain.GetUtilityTokenBalance(addr1) - e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+util.Fixed8(balance.Int64()).String()) + e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String()) e.checkNextLine(t, "^\\s*Updated:") e.checkNextLine(t, "^\\s*$") @@ -74,7 +74,7 @@ func TestNEP17Balance(t *testing.T) { if strings.Contains(line, "GAS") { e.checkLine(t, line, "^\\s*GAS:\\s+GAS \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") balance = e.Chain.GetUtilityTokenBalance(addr3) - e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+util.Fixed8(balance.Int64()).String()) + e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String()) e.checkNextLine(t, "^\\s*Updated:") } else { balance, index := e.Chain.GetGoverningTokenBalance(validatorHash) @@ -156,7 +156,7 @@ func TestNEP17MultiTransfer(t *testing.T) { b, _ := e.Chain.GetGoverningTokenBalance(privs[0].GetScriptHash()) require.Equal(t, big.NewInt(42), b) b = e.Chain.GetUtilityTokenBalance(privs[1].GetScriptHash()) - require.Equal(t, big.NewInt(int64(util.Fixed8FromInt64(7))), b) + require.Equal(t, big.NewInt(int64(fixedn.Fixed8FromInt64(7))), b) b, _ = e.Chain.GetGoverningTokenBalance(privs[2].GetScriptHash()) require.Equal(t, big.NewInt(13), b) } diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index 8f37467c2..4f90d9c7c 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -19,6 +19,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/encoding/address" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/smartcontract" @@ -446,7 +447,7 @@ func invokeFunction(ctx *cli.Context) error { func invokeInternal(ctx *cli.Context, signAndPush bool) error { var ( err error - gas util.Fixed8 + gas fixedn.Fixed8 operation string params = make([]smartcontract.Parameter, 0) paramsStart = 1 diff --git a/cli/wallet/nep17.go b/cli/wallet/nep17.go index 40f32d560..8257d4019 100644 --- a/cli/wallet/nep17.go +++ b/cli/wallet/nep17.go @@ -9,6 +9,7 @@ import ( "github.com/nspcc-dev/neo-go/cli/options" "github.com/nspcc-dev/neo-go/cli/paramcontext" "github.com/nspcc-dev/neo-go/pkg/encoding/address" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/rpc/client" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/wallet" @@ -390,7 +391,7 @@ func multiTransferNEP17(ctx *cli.Context) error { if err != nil { return cli.NewExitError(fmt.Errorf("invalid address: '%s'", ss[1]), 1) } - amount, err := util.FixedNFromString(ss[2], int(token.Decimals)) + amount, err := fixedn.FixedNFromString(ss[2], int(token.Decimals)) if err != nil { return cli.NewExitError(fmt.Errorf("invalid amount: %w", err), 1) } @@ -437,7 +438,7 @@ func transferNEP17(ctx *cli.Context) error { } } - amount, err := util.FixedNFromString(ctx.String("amount"), int(token.Decimals)) + amount, err := fixedn.FixedNFromString(ctx.String("amount"), int(token.Decimals)) if err != nil { return cli.NewExitError(fmt.Errorf("invalid amount: %w", err), 1) } diff --git a/pkg/core/helper_test.go b/pkg/core/helper_test.go index e63207516..e1b6a6de7 100644 --- a/pkg/core/helper_test.go +++ b/pkg/core/helper_test.go @@ -22,6 +22,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/storage" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" @@ -198,7 +199,7 @@ func TestCreateBasicChain(t *testing.T) { acc0 := wallet.NewAccountFromPrivateKey(priv0) // Prepare some transaction for future submission. - txSendRaw := newNEP17Transfer(bc.contracts.NEO.Hash, priv0ScriptHash, priv1.GetScriptHash(), int64(util.Fixed8FromInt64(1000))) + txSendRaw := newNEP17Transfer(bc.contracts.NEO.Hash, priv0ScriptHash, priv1.GetScriptHash(), int64(fixedn.Fixed8FromInt64(1000))) txSendRaw.ValidUntilBlock = transaction.MaxValidUntilBlockIncrement txSendRaw.Nonce = 0x1234 txSendRaw.Signers = []transaction.Signer{{ @@ -245,7 +246,7 @@ func initBasicChain(t *testing.T, bc *Blockchain) { txMoveNeo, err := testchain.NewTransferFromOwner(bc, neoHash, priv0ScriptHash, neoAmount, getNextNonce(), validUntilBlock) require.NoError(t, err) // Move some GAS to one simple account. - txMoveGas, err := testchain.NewTransferFromOwner(bc, gasHash, priv0ScriptHash, int64(util.Fixed8FromInt64(1000)), + txMoveGas, err := testchain.NewTransferFromOwner(bc, gasHash, priv0ScriptHash, int64(fixedn.Fixed8FromInt64(1000)), getNextNonce(), validUntilBlock) require.NoError(t, err) diff --git a/pkg/core/state/notification_event.go b/pkg/core/state/notification_event.go index e4e1a846f..4caf4bdc2 100644 --- a/pkg/core/state/notification_event.go +++ b/pkg/core/state/notification_event.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" @@ -173,7 +174,7 @@ type Execution struct { type executionAux struct { Trigger string `json:"trigger"` VMState string `json:"vmstate"` - GasConsumed util.Fixed8 `json:"gasconsumed,string"` + GasConsumed fixedn.Fixed8 `json:"gasconsumed,string"` Stack json.RawMessage `json:"stack"` Events []NotificationEvent `json:"notifications"` FaultException string `json:"exception,omitempty"` @@ -202,7 +203,7 @@ func (e Execution) MarshalJSON() ([]byte, error) { return json.Marshal(&executionAux{ Trigger: e.Trigger.String(), VMState: e.VMState.String(), - GasConsumed: util.Fixed8(e.GasConsumed), + GasConsumed: fixedn.Fixed8(e.GasConsumed), Stack: st, Events: e.Events, FaultException: e.FaultException, diff --git a/pkg/core/transaction/transaction.go b/pkg/core/transaction/transaction.go index d0f79d44e..95ce8e664 100644 --- a/pkg/core/transaction/transaction.go +++ b/pkg/core/transaction/transaction.go @@ -10,6 +10,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/encoding/address" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/util" ) @@ -301,18 +302,18 @@ func (t *Transaction) Sender() util.Uint160 { // transactionJSON is a wrapper for Transaction and // used for correct marhalling of transaction.Data type transactionJSON struct { - TxID util.Uint256 `json:"hash"` - Size int `json:"size"` - Version uint8 `json:"version"` - Nonce uint32 `json:"nonce"` - Sender string `json:"sender"` - SystemFee util.Fixed8 `json:"sysfee,string"` - NetworkFee util.Fixed8 `json:"netfee,string"` - ValidUntilBlock uint32 `json:"validuntilblock"` - Attributes []Attribute `json:"attributes"` - Signers []Signer `json:"signers"` - Script []byte `json:"script"` - Scripts []Witness `json:"witnesses"` + TxID util.Uint256 `json:"hash"` + Size int `json:"size"` + Version uint8 `json:"version"` + Nonce uint32 `json:"nonce"` + Sender string `json:"sender"` + SystemFee fixedn.Fixed8 `json:"sysfee,string"` + NetworkFee fixedn.Fixed8 `json:"netfee,string"` + ValidUntilBlock uint32 `json:"validuntilblock"` + Attributes []Attribute `json:"attributes"` + Signers []Signer `json:"signers"` + Script []byte `json:"script"` + Scripts []Witness `json:"witnesses"` } // MarshalJSON implements json.Marshaler interface. @@ -328,8 +329,8 @@ func (t *Transaction) MarshalJSON() ([]byte, error) { Signers: t.Signers, Script: t.Script, Scripts: t.Scripts, - SystemFee: util.Fixed8(t.SystemFee), - NetworkFee: util.Fixed8(t.NetworkFee), + SystemFee: fixedn.Fixed8(t.SystemFee), + NetworkFee: fixedn.Fixed8(t.NetworkFee), } return json.Marshal(tx) } diff --git a/pkg/core/transaction/transaction_test.go b/pkg/core/transaction/transaction_test.go index 4df141aa8..587bc48a4 100644 --- a/pkg/core/transaction/transaction_test.go +++ b/pkg/core/transaction/transaction_test.go @@ -7,6 +7,7 @@ import ( "math" "testing" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -119,8 +120,8 @@ func TestMarshalUnmarshalJSONInvocationTX(t *testing.T) { Script: []byte{1, 2, 3, 4}, Attributes: []Attribute{{Type: HighPriority}}, Scripts: []Witness{}, - SystemFee: int64(util.Fixed8FromFloat(123.45)), - NetworkFee: int64(util.Fixed8FromFloat(0.123)), + SystemFee: int64(fixedn.Fixed8FromFloat(123.45)), + NetworkFee: int64(fixedn.Fixed8FromFloat(0.123)), Trimmed: false, } diff --git a/pkg/util/fixed8.go b/pkg/encoding/fixedn/fixed8.go similarity index 99% rename from pkg/util/fixed8.go rename to pkg/encoding/fixedn/fixed8.go index c11badae7..80103b9d5 100644 --- a/pkg/util/fixed8.go +++ b/pkg/encoding/fixedn/fixed8.go @@ -1,4 +1,4 @@ -package util +package fixedn import ( "encoding/json" diff --git a/pkg/util/fixed8_test.go b/pkg/encoding/fixedn/fixed8_test.go similarity index 99% rename from pkg/util/fixed8_test.go rename to pkg/encoding/fixedn/fixed8_test.go index 8421b11fc..5560e6a4d 100644 --- a/pkg/util/fixed8_test.go +++ b/pkg/encoding/fixedn/fixed8_test.go @@ -1,4 +1,4 @@ -package util +package fixedn import ( "encoding/json" diff --git a/pkg/rpc/client/rpc.go b/pkg/rpc/client/rpc.go index 22ffeec8a..65da7f66f 100644 --- a/pkg/rpc/client/rpc.go +++ b/pkg/rpc/client/rpc.go @@ -13,6 +13,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" @@ -170,10 +171,10 @@ func (c *Client) GetBlockHeaderVerbose(hash util.Uint256) (*result.Header, error } // GetBlockSysFee returns the system fees of the block, based on the specified index. -func (c *Client) GetBlockSysFee(index uint32) (util.Fixed8, error) { +func (c *Client) GetBlockSysFee(index uint32) (fixedn.Fixed8, error) { var ( params = request.NewRawParams(index) - resp util.Fixed8 + resp fixedn.Fixed8 ) if err := c.performRequest("getblocksysfee", params, &resp); err != nil { return resp, err @@ -473,7 +474,7 @@ func (c *Client) SubmitBlock(b block.Block) (util.Uint256, error) { // SignAndPushInvocationTx signs and pushes given script as an invocation // transaction using given wif to sign it and spending the amount of gas // specified. It returns a hash of the invocation transaction and an error. -func (c *Client) SignAndPushInvocationTx(script []byte, acc *wallet.Account, sysfee int64, netfee util.Fixed8, cosigners []transaction.Signer) (util.Uint256, error) { +func (c *Client) SignAndPushInvocationTx(script []byte, acc *wallet.Account, sysfee int64, netfee fixedn.Fixed8, cosigners []transaction.Signer) (util.Uint256, error) { var txHash util.Uint256 var err error diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index b3c48eba3..8cffef5ff 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -22,6 +22,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/address" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/smartcontract" @@ -285,7 +286,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ }, serverResponse: `{"jsonrpc":"2.0","id":1,"result":"195500"}`, result: func(c *Client) interface{} { - return util.Fixed8FromInt64(195500) + return fixedn.Fixed8FromInt64(195500) }, }, }, diff --git a/pkg/rpc/response/result/invoke.go b/pkg/rpc/response/result/invoke.go index b070f4b27..922dcdcad 100644 --- a/pkg/rpc/response/result/invoke.go +++ b/pkg/rpc/response/result/invoke.go @@ -6,7 +6,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/core/transaction" - "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" ) @@ -26,7 +26,7 @@ type Invoke struct { type invokeAux struct { State string `json:"state"` - GasConsumed util.Fixed8 `json:"gasconsumed,string"` + GasConsumed fixedn.Fixed8 `json:"gasconsumed,string"` Script []byte `json:"script"` Stack json.RawMessage `json:"stack"` FaultException string `json:"exception,omitempty"` @@ -55,7 +55,7 @@ func (r Invoke) MarshalJSON() ([]byte, error) { } return json.Marshal(&invokeAux{ - GasConsumed: util.Fixed8(r.GasConsumed), + GasConsumed: fixedn.Fixed8(r.GasConsumed), Script: r.Script, State: r.State, Stack: st, diff --git a/pkg/rpc/response/result/invoke_test.go b/pkg/rpc/response/result/invoke_test.go index c6b3accc0..611831acb 100644 --- a/pkg/rpc/response/result/invoke_test.go +++ b/pkg/rpc/response/result/invoke_test.go @@ -6,7 +6,7 @@ import ( "math/big" "testing" - "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/stretchr/testify/require" ) @@ -14,7 +14,7 @@ import ( func TestInvoke_MarshalJSON(t *testing.T) { result := &Invoke{ State: "HALT", - GasConsumed: int64(util.Fixed8FromFloat(123.45)), + GasConsumed: int64(fixedn.Fixed8FromFloat(123.45)), Script: []byte{10}, Stack: []stackitem.Item{stackitem.NewBigInteger(big.NewInt(1))}, FaultException: "", diff --git a/pkg/rpc/rpc_config.go b/pkg/rpc/rpc_config.go index 30ecbf236..8647d6e83 100644 --- a/pkg/rpc/rpc_config.go +++ b/pkg/rpc/rpc_config.go @@ -1,6 +1,8 @@ package rpc -import "github.com/nspcc-dev/neo-go/pkg/util" +import ( + "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" +) type ( // Config is an RPC service configuration information @@ -10,9 +12,9 @@ type ( EnableCORSWorkaround bool `yaml:"EnableCORSWorkaround"` // MaxGasInvoke is a maximum amount of gas which // can be spent during RPC call. - MaxGasInvoke util.Fixed8 `yaml:"MaxGasInvoke"` - Port uint16 `yaml:"Port"` - TLSConfig TLSConfig `yaml:"TLSConfig"` + MaxGasInvoke fixedn.Fixed8 `yaml:"MaxGasInvoke"` + Port uint16 `yaml:"Port"` + TLSConfig TLSConfig `yaml:"TLSConfig"` } // TLSConfig describes SSL/TLS configuration.