From bbd586f3e200ccfc78fcda2ed0b4dd91e91db26c Mon Sep 17 00:00:00 2001 From: Yilun Date: Wed, 8 May 2024 02:48:32 -0700 Subject: [PATCH] gofmt Signed-off-by: Yilun --- README.md | 2 +- api/websocket/server/server.go | 2 +- common/serialization/serialize.go | 2 +- dashboard/routes/common/sync.go | 2 +- dashboard/routes/node/beneficiary.go | 2 +- dashboard/routes/wallet/create.go | 2 +- pb/transaction.go | 4 ++-- program/program.go | 18 +++++++++--------- signature/signature.go | 2 +- signature/signer.go | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 5f3c609b8..f13d833b8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@
-[![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/nknorg/nkn)](https://goreportcard.com/report/github.com/nknorg/nkn) [![Build Status](https://github.com/nknorg/nkn/actions/workflows/build-ubuntu.yml/badge.svg)](https://github.com/nknorg/nkn/actions/workflows/build-ubuntu.yml) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing) +[![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/nknorg/nkn/v2)](https://goreportcard.com/report/github.com/nknorg/nkn/v2) [![Build Status](https://github.com/nknorg/nkn/actions/workflows/build-ubuntu.yml/badge.svg)](https://github.com/nknorg/nkn/actions/workflows/build-ubuntu.yml) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing) ### Dev Status: V2 line, Production (Stable and Feature-Complete) diff --git a/api/websocket/server/server.go b/api/websocket/server/server.go index 9181ca62c..0254a8e57 100644 --- a/api/websocket/server/server.go +++ b/api/websocket/server/server.go @@ -184,7 +184,7 @@ func (ms *MsgServer) registryMethod() { err = crypto.Verify(pubKey, hash[:], byteSignature) if err != nil { // fail verify challenge signature go func() { - log.Warning("Client signature is not right, close its conneciton now") + log.Warning("Client signature is not right, close its connection now") time.Sleep(3 * time.Second) // sleep several second, let response reach client ms.SessionList.CloseSession(sess) // close this session }() diff --git a/common/serialization/serialize.go b/common/serialization/serialize.go index 318242733..0c0d7daed 100644 --- a/common/serialization/serialize.go +++ b/common/serialization/serialize.go @@ -10,7 +10,7 @@ import ( var ErrRange = errors.New("value out of range") var ErrEof = errors.New("got EOF, can not get the next byte") -//SerializableData describe the data need be serialized. +// SerializableData describe the data need be serialized. type SerializableData interface { //Write data to writer diff --git a/dashboard/routes/common/sync.go b/dashboard/routes/common/sync.go index b8105d85c..31c6f9d29 100644 --- a/dashboard/routes/common/sync.go +++ b/dashboard/routes/common/sync.go @@ -2,8 +2,8 @@ package common import ( "github.com/gin-gonic/gin" - serviceConfig "github.com/nknorg/nkn/v2/dashboard/config" "github.com/nknorg/nkn/v2/config" + serviceConfig "github.com/nknorg/nkn/v2/dashboard/config" "net/http" "time" ) diff --git a/dashboard/routes/node/beneficiary.go b/dashboard/routes/node/beneficiary.go index 0218576ba..8445f442b 100644 --- a/dashboard/routes/node/beneficiary.go +++ b/dashboard/routes/node/beneficiary.go @@ -3,9 +3,9 @@ package node import ( "encoding/json" "github.com/gin-gonic/gin" + "github.com/nknorg/nkn/v2/config" "github.com/nknorg/nkn/v2/dashboard/auth" "github.com/nknorg/nkn/v2/dashboard/helpers" - "github.com/nknorg/nkn/v2/config" "github.com/nknorg/nkn/v2/util/log" "net/http" ) diff --git a/dashboard/routes/wallet/create.go b/dashboard/routes/wallet/create.go index fb463193d..43448cc0e 100644 --- a/dashboard/routes/wallet/create.go +++ b/dashboard/routes/wallet/create.go @@ -6,9 +6,9 @@ import ( "net/http" "github.com/gin-gonic/gin" + "github.com/nknorg/nkn/v2/config" serviceConfig "github.com/nknorg/nkn/v2/dashboard/config" "github.com/nknorg/nkn/v2/dashboard/helpers" - "github.com/nknorg/nkn/v2/config" "github.com/nknorg/nkn/v2/util/log" "github.com/nknorg/nkn/v2/util/password" "github.com/nknorg/nkn/v2/vault" diff --git a/pb/transaction.go b/pb/transaction.go index 89535575d..570777141 100644 --- a/pb/transaction.go +++ b/pb/transaction.go @@ -10,7 +10,7 @@ import ( "github.com/nknorg/nkn/v2/common/serialization" ) -//Serialize the Program +// Serialize the Program func (p *Program) Serialize(w io.Writer) error { err := serialization.WriteVarBytes(w, p.Parameter) if err != nil { @@ -24,7 +24,7 @@ func (p *Program) Serialize(w io.Writer) error { return nil } -//Deserialize the Program +// Deserialize the Program func (p *Program) Deserialize(w io.Reader) error { val, err := serialization.ReadVarBytes(w) if err != nil { diff --git a/program/program.go b/program/program.go index 1bf9b8026..3c8b474aa 100644 --- a/program/program.go +++ b/program/program.go @@ -99,7 +99,7 @@ func ByteToProgramContextParameterType(b []byte) []ProgramContextParameterType { return c } -//create a single signature program context for owner +// create a single signature program context for owner func CreateSignatureProgramContext(ownerPubKey []byte) (*ProgramContext, error) { code, err := CreateSignatureProgramCode(ownerPubKey) if err != nil { @@ -121,7 +121,7 @@ func CreateSignatureProgramContext(ownerPubKey []byte) (*ProgramContext, error) }, nil } -//CODE: len(publickey) + publickey + CHECKSIG +// CODE: len(publickey) + publickey + CHECKSIG func CreateSignatureProgramCode(pubKey []byte) ([]byte, error) { code := bytes.NewBuffer(nil) code.WriteByte(byte(len(pubKey))) @@ -144,9 +144,9 @@ func CreateProgramHash(pubKey []byte) (common.Uint160, error) { return programHash, err } -//CODE: len(publickey) + publickey + CHECKSIG -//-------------------------------------------- -//Size: 1 32 1 +// CODE: len(publickey) + publickey + CHECKSIG +// -------------------------------------------- +// Size: 1 32 1 func GetPublicKeyFromCode(code []byte) ([]byte, error) { if len(code) != 34 { return nil, fmt.Errorf("code length error, need 34, but got %v", len(code)) @@ -159,9 +159,9 @@ func GetPublicKeyFromCode(code []byte) ([]byte, error) { return code[1:33], nil } -//Parameter: len(signature) + signature -//-------------------------------------------- -//Size: 1 64 +// Parameter: len(signature) + signature +// -------------------------------------------- +// Size: 1 64 func GetSignatureFromParameter(parameter []byte) ([]byte, error) { if len(parameter) != 65 { return nil, fmt.Errorf("parameter length error, need 65,but got %v", len(parameter)) @@ -174,7 +174,7 @@ func GetSignatureFromParameter(parameter []byte) ([]byte, error) { return parameter[1:], nil } -//Parameter: len(signature) + signature +// Parameter: len(signature) + signature func (c *ProgramContext) NewProgram(signature []byte) *pb.Program { size := len(signature) parameter := append([]byte{byte(size)}, signature...) diff --git a/signature/signature.go b/signature/signature.go index 63758da95..91ae020c2 100644 --- a/signature/signature.go +++ b/signature/signature.go @@ -11,7 +11,7 @@ import ( "github.com/nknorg/nkn/v2/pb" ) -//SignableData describe the data need be signed. +// SignableData describe the data need be signed. type SignableData interface { GetProgramHashes() ([]common.Uint160, error) SetPrograms([]*pb.Program) diff --git a/signature/signer.go b/signature/signer.go index e3aa5e6b4..8dee94eeb 100644 --- a/signature/signer.go +++ b/signature/signer.go @@ -1,6 +1,6 @@ package signature -//Signer is the abstract interface of user's information(Keys) for signing data. +// Signer is the abstract interface of user's information(Keys) for signing data. type Signer interface { PrivKey() []byte PubKey() []byte