From 9d2712573fa7573e9c54141d5a255e6bcd82348b Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 12 May 2021 23:17:03 +0300 Subject: [PATCH] *: enable godot linter and fix all its warnings It's important for NeoGo to have clean documentation. No functional changes. --- .golangci.yml | 1 + cli/flags/address.go | 8 ++++---- cli/input/input.go | 2 +- cli/nep11_test.go | 2 +- cli/paramcontext/context.go | 2 +- cli/smartcontract/smart_contract.go | 2 +- pkg/compiler/codegen.go | 4 ++-- pkg/compiler/debug.go | 4 ++-- pkg/compiler/inline.go | 10 +++++----- pkg/consensus/commit.go | 2 +- pkg/consensus/payload.go | 2 +- pkg/core/block/block.go | 2 +- pkg/core/block/header.go | 4 ++-- pkg/core/dao/dao.go | 2 +- pkg/core/fee/calculate.go | 2 +- pkg/core/helper_test.go | 2 +- pkg/core/mempool/mem_pool.go | 6 +++--- pkg/core/mpt/batch_test.go | 2 +- pkg/core/native/ledger.go | 4 ++-- pkg/core/native/name_service_test.go | 2 +- pkg/core/native/oracle.go | 4 ++-- pkg/core/native/policy.go | 2 +- pkg/core/state/contract.go | 2 +- pkg/core/state/notification_event.go | 2 +- pkg/core/storage/badgerdb_store.go | 6 +++--- pkg/core/storage/store.go | 4 ++-- pkg/core/transaction/attrtype.go | 4 ++-- pkg/core/transaction/helper_test.go | 2 +- pkg/core/transaction/signer.go | 2 +- pkg/core/transaction/transaction.go | 8 ++++---- pkg/crypto/keys/publickey.go | 2 +- pkg/encoding/bigint/bigint.go | 2 +- pkg/encoding/bigint/bigint_test.go | 2 +- pkg/encoding/fixedn/fixed8.go | 2 +- pkg/interop/native/std/std.go | 10 +++++----- pkg/interop/types.go | 2 +- pkg/io/binaryReader.go | 2 +- pkg/network/capability/capability.go | 12 ++++++------ pkg/network/capability/type.go | 8 ++++---- pkg/network/discovery.go | 4 ++-- pkg/network/message.go | 16 ++++++++-------- pkg/network/payload/getblockbyindex.go | 4 ++-- pkg/network/payload/getblocks.go | 4 ++-- pkg/rpc/client/client.go | 6 +++--- pkg/rpc/client/rpc.go | 2 +- pkg/rpc/request/types.go | 2 +- pkg/rpc/response/errors.go | 18 +++++++++--------- pkg/rpc/response/result/unclaimed_gas.go | 4 ++-- pkg/rpc/rpc_config.go | 2 +- pkg/rpc/server/server.go | 2 +- pkg/smartcontract/convertor.go | 2 +- pkg/smartcontract/param_type.go | 2 +- pkg/smartcontract/trigger/trigger_type.go | 2 +- pkg/util/uint256.go | 2 +- pkg/vm/opcode/opcode.go | 20 ++++++++++---------- pkg/vm/stackitem/item.go | 4 ++-- pkg/vm/vm.go | 8 ++++---- pkg/vm/vm_test.go | 2 +- pkg/wallet/token.go | 2 +- pkg/wallet/wallet.go | 2 +- 60 files changed, 127 insertions(+), 126 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f4faf7672..39a4d8e51 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -35,6 +35,7 @@ linters: - deadcode - errcheck - gosimple + - godot - ineffassign - staticcheck - structcheck diff --git a/cli/flags/address.go b/cli/flags/address.go index ce2276e63..56ccf851e 100644 --- a/cli/flags/address.go +++ b/cli/flags/address.go @@ -16,7 +16,7 @@ type Address struct { Value util.Uint160 } -// AddressFlag is a flag with type string +// AddressFlag is a flag with type string. type AddressFlag struct { Name string Usage string @@ -60,7 +60,7 @@ func (f AddressFlag) IsSet() bool { } // String returns a readable representation of this value -// (for usage defaults) +// (for usage defaults). func (f AddressFlag) String() string { var names []string eachName(f.Name, func(name string) { @@ -77,13 +77,13 @@ func getNameHelp(name string) string { return fmt.Sprintf("--%s value", name) } -// GetName returns the name of the flag +// GetName returns the name of the flag. func (f AddressFlag) GetName() string { return f.Name } // Apply populates the flag given the flag set and environment -// Ignores errors +// Ignores errors. func (f AddressFlag) Apply(set *flag.FlagSet) { eachName(f.Name, func(name string) { set.Var(&f.Value, name, f.Usage) diff --git a/cli/input/input.go b/cli/input/input.go index ee62a531a..22eb4a6c8 100644 --- a/cli/input/input.go +++ b/cli/input/input.go @@ -17,7 +17,7 @@ type ReadWriter struct { io.Writer } -// ReadLine reads line from the input without trailing '\n' +// ReadLine reads line from the input without trailing '\n'. func ReadLine(prompt string) (string, error) { trm := Terminal if trm == nil { diff --git a/cli/nep11_test.go b/cli/nep11_test.go index 3565b14b7..99fbeabbe 100644 --- a/cli/nep11_test.go +++ b/cli/nep11_test.go @@ -21,7 +21,7 @@ import ( ) const ( - // nftOwnerAddr is the owner of NFT-ND HASHY token (../examples/nft-nd/nft.go) + // nftOwnerAddr is the owner of NFT-ND HASHY token (../examples/nft-nd/nft.go). nftOwnerAddr = "NbrUYaZgyhSkNoRo9ugRyEMdUZxrhkNaWB" nftOwnerWallet = "../examples/my_wallet.json" nftOwnerPass = "qwerty" diff --git a/cli/paramcontext/context.go b/cli/paramcontext/context.go index 9df147fd0..c991e2e85 100644 --- a/cli/paramcontext/context.go +++ b/cli/paramcontext/context.go @@ -12,7 +12,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/wallet" ) -// validUntilBlockIncrement is the number of extra blocks to add to an exported transaction +// validUntilBlockIncrement is the number of extra blocks to add to an exported transaction. const validUntilBlockIncrement = 50 // InitAndSave creates incompletely signed transaction which can used diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index c3662696d..070a9ef7c 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -68,7 +68,7 @@ var ( const ( // smartContractTmpl is written to a file when used with `init` command. - // %s is parsed to be the smartContractName + // %s is parsed to be the smartContractName. smartContractTmpl = `package %s import "github.com/nspcc-dev/neo-go/pkg/interop/runtime" diff --git a/pkg/compiler/codegen.go b/pkg/compiler/codegen.go index 14a456165..2723f861b 100644 --- a/pkg/compiler/codegen.go +++ b/pkg/compiler/codegen.go @@ -126,7 +126,7 @@ const ( varArgument ) -// newLabel creates a new label to jump to +// newLabel creates a new label to jump to. func (c *codegen) newLabel() (l uint16) { li := len(c.l) if li > math.MaxUint16 { @@ -1498,7 +1498,7 @@ func (c *codegen) getLabelOffset(typ labelOffsetType, name string) uint16 { } // For `&&` and `||` it return an opcode which jumps only if result is known: -// false && .. == false, true || .. = true +// false && .. == false, true || .. = true. func getJumpForToken(tok token.Token, typ types.Type) (opcode.Opcode, bool) { switch tok { case token.GTR: diff --git a/pkg/compiler/debug.go b/pkg/compiler/debug.go index 042d47fd5..9ec74af29 100644 --- a/pkg/compiler/debug.go +++ b/pkg/compiler/debug.go @@ -340,7 +340,7 @@ func (d *DebugParam) UnmarshalJSON(data []byte) error { return nil } -// ToManifestParameter converts DebugParam to manifest.Parameter +// ToManifestParameter converts DebugParam to manifest.Parameter. func (d *DebugParam) ToManifestParameter() manifest.Parameter { return manifest.Parameter{ Name: d.Name, @@ -348,7 +348,7 @@ func (d *DebugParam) ToManifestParameter() manifest.Parameter { } } -// ToManifestMethod converts MethodDebugInfo to manifest.Method +// ToManifestMethod converts MethodDebugInfo to manifest.Method. func (m *MethodDebugInfo) ToManifestMethod() manifest.Method { var ( result manifest.Method diff --git a/pkg/compiler/inline.go b/pkg/compiler/inline.go index 4da30043d..f3471863b 100644 --- a/pkg/compiler/inline.go +++ b/pkg/compiler/inline.go @@ -10,11 +10,11 @@ import ( // inlineCall inlines call of n for function represented by f. // Call `f(a,b)` for definition `func f(x,y int)` is translated to block: -// { -// x := a -// y := b -// -// } +// { +// x := a +// y := b +// +// } func (c *codegen) inlineCall(f *funcScope, n *ast.CallExpr) { labelSz := len(c.labelList) offSz := len(c.inlineLabelOffsets) diff --git a/pkg/consensus/commit.go b/pkg/consensus/commit.go index 492a1a156..920d67745 100644 --- a/pkg/consensus/commit.go +++ b/pkg/consensus/commit.go @@ -11,7 +11,7 @@ type commit struct { } // signatureSize is an rfc6989 signature size in bytes -// without leading byte (0x04, uncompressed) +// without leading byte (0x04, uncompressed). const signatureSize = 64 var _ payload.Commit = (*commit)(nil) diff --git a/pkg/consensus/payload.go b/pkg/consensus/payload.go index 2d17938ea..e4ae53066 100644 --- a/pkg/consensus/payload.go +++ b/pkg/consensus/payload.go @@ -233,7 +233,7 @@ func (p *Payload) encodeData() { } } -// decode data of payload into it's message +// decode data of payload into its message. func (p *Payload) decodeData() error { br := io.NewBinReaderFromBuf(p.Extensible.Data) p.message.DecodeBinary(br) diff --git a/pkg/core/block/block.go b/pkg/core/block/block.go index 8feff8942..37d705ef5 100644 --- a/pkg/core/block/block.go +++ b/pkg/core/block/block.go @@ -215,7 +215,7 @@ func (b *Block) UnmarshalJSON(data []byte) error { return nil } -// GetExpectedBlockSize returns expected block size which should be equal to io.GetVarSize(b) +// GetExpectedBlockSize returns expected block size which should be equal to io.GetVarSize(b). func (b *Block) GetExpectedBlockSize() int { var transactionsSize int for _, tx := range b.Transactions { diff --git a/pkg/core/block/header.go b/pkg/core/block/header.go index e7515dcab..c4025428d 100644 --- a/pkg/core/block/header.go +++ b/pkg/core/block/header.go @@ -11,7 +11,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/util" ) -// Header holds the base info of a block +// Header holds the base info of a block. type Header struct { // Version of the block. Version uint32 @@ -84,7 +84,7 @@ func (b *Header) DecodeBinary(br *io.BinReader) { b.Script.DecodeBinary(br) } -// EncodeBinary implements Serializable interface +// EncodeBinary implements Serializable interface. func (b *Header) EncodeBinary(bw *io.BinWriter) { b.encodeHashableFields(bw) bw.WriteVarUint(1) diff --git a/pkg/core/dao/dao.go b/pkg/core/dao/dao.go index 9e1f371f7..12e4ecfe7 100644 --- a/pkg/core/dao/dao.go +++ b/pkg/core/dao/dao.go @@ -17,7 +17,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/util" ) -// HasTransaction errors +// HasTransaction errors. var ( // ErrAlreadyExists is returned when transaction exists in dao. ErrAlreadyExists = errors.New("transaction already exists") diff --git a/pkg/core/fee/calculate.go b/pkg/core/fee/calculate.go index c15874932..4942f3f89 100644 --- a/pkg/core/fee/calculate.go +++ b/pkg/core/fee/calculate.go @@ -10,7 +10,7 @@ import ( // ECDSAVerifyPrice is a gas price of a single verification. const ECDSAVerifyPrice = 1 << 15 -// Calculate returns network fee for transaction +// Calculate returns network fee for transaction. func Calculate(base int64, script []byte) (int64, int) { var ( netFee int64 diff --git a/pkg/core/helper_test.go b/pkg/core/helper_test.go index 32a470175..24c8cafd1 100644 --- a/pkg/core/helper_test.go +++ b/pkg/core/helper_test.go @@ -44,7 +44,7 @@ import ( "go.uber.org/zap/zaptest" ) -// multisig address which possess all NEO +// multisig address which possess all NEO. var neoOwner = testchain.MultisigScriptHash() // newTestChain should be called before newBlock invocation to properly setup diff --git a/pkg/core/mempool/mem_pool.go b/pkg/core/mempool/mem_pool.go index 1215b9f52..53b6f60bb 100644 --- a/pkg/core/mempool/mem_pool.go +++ b/pkg/core/mempool/mem_pool.go @@ -47,7 +47,7 @@ type item struct { type items []item // utilityBalanceAndFees stores sender's balance and overall fees of -// sender's transactions which are currently in mempool +// sender's transactions which are currently in mempool. type utilityBalanceAndFees struct { balance *big.Int feeSum *big.Int @@ -158,7 +158,7 @@ func (mp *Pool) HasConflicts(t *transaction.Transaction, fee Feer) bool { } // tryAddSendersFee tries to add system fee and network fee to the total sender`s fee in mempool -// and returns false if both balance check is required and sender has not enough GAS to pay +// and returns false if both balance check is required and sender has not enough GAS to pay. func (mp *Pool) tryAddSendersFee(tx *transaction.Transaction, feer Feer, needCheck bool) bool { payer := tx.Signers[mp.payerIndex].Account senderFee, ok := mp.fees[payer] @@ -304,7 +304,7 @@ func (mp *Pool) Remove(hash util.Uint256, feer Feer) { mp.lock.Unlock() } -// removeInternal is an internal unlocked representation of Remove +// removeInternal is an internal unlocked representation of Remove. func (mp *Pool) removeInternal(hash util.Uint256, feer Feer) { if tx, ok := mp.verifiedMap[hash]; ok { var num int diff --git a/pkg/core/mpt/batch_test.go b/pkg/core/mpt/batch_test.go index dffb4b9ae..9438b8e2b 100644 --- a/pkg/core/mpt/batch_test.go +++ b/pkg/core/mpt/batch_test.go @@ -281,7 +281,7 @@ var _ = printNode // This function is unused, but is helpful for debugging // as it provides more readable Trie representation compared to -// `spew.Dump()` +// `spew.Dump()`. func printNode(prefix string, n Node) { switch tn := n.(type) { case *HashNode: diff --git a/pkg/core/native/ledger.go b/pkg/core/native/ledger.go index 4dfd6b313..ad9b68185 100644 --- a/pkg/core/native/ledger.go +++ b/pkg/core/native/ledger.go @@ -192,7 +192,7 @@ func getTransactionAndHeight(cd *dao.Cached, item stackitem.Item) (*transaction. return cd.GetTransaction(hash) } -// BlockToStackItem converts block.Block to stackitem.Item +// BlockToStackItem converts block.Block to stackitem.Item. func BlockToStackItem(b *block.Block) stackitem.Item { return stackitem.NewArray([]stackitem.Item{ stackitem.NewByteArray(b.Hash().BytesBE()), @@ -206,7 +206,7 @@ func BlockToStackItem(b *block.Block) stackitem.Item { }) } -// TransactionToStackItem converts transaction.Transaction to stackitem.Item +// TransactionToStackItem converts transaction.Transaction to stackitem.Item. func TransactionToStackItem(t *transaction.Transaction) stackitem.Item { return stackitem.NewArray([]stackitem.Item{ stackitem.NewByteArray(t.Hash().BytesBE()), diff --git a/pkg/core/native/name_service_test.go b/pkg/core/native/name_service_test.go index bc741051f..325ffd831 100644 --- a/pkg/core/native/name_service_test.go +++ b/pkg/core/native/name_service_test.go @@ -10,7 +10,7 @@ import ( ) // The specification is following C# code: -// string domain = string.Join('.', name.Split('.')[^2..]); +// string domain = string.Join('.', name.Split('.')[^2..]); func TestParseDomain(t *testing.T) { testCases := []struct { name string diff --git a/pkg/core/native/oracle.go b/pkg/core/native/oracle.go index abd99fbf5..b6deb469c 100644 --- a/pkg/core/native/oracle.go +++ b/pkg/core/native/oracle.go @@ -56,7 +56,7 @@ const ( maxFilterLength = 128 maxCallbackLength = 32 maxUserDataLength = 512 - // maxRequestsCount is the maximum number of requests per URL + // maxRequestsCount is the maximum number of requests per URL. maxRequestsCount = 256 // DefaultOracleRequestPrice is default amount GAS needed for oracle request. @@ -520,7 +520,7 @@ func (o *Oracle) getSerializableFromDAO(d dao.DAO, key []byte, item io.Serializa return getSerializableFromDAO(o.ID, d, key, item) } -// updateCache updates cached Oracle values if they've been changed +// updateCache updates cached Oracle values if they've been changed. func (o *Oracle) updateCache(d dao.DAO) error { orc, _ := o.Module.Load().(services.Oracle) if orc == nil { diff --git a/pkg/core/native/policy.go b/pkg/core/native/policy.go index 8c063bca7..78f346605 100644 --- a/pkg/core/native/policy.go +++ b/pkg/core/native/policy.go @@ -243,7 +243,7 @@ func (p *Policy) isBlocked(ic *interop.Context, args []stackitem.Item) stackitem return stackitem.NewBool(p.IsBlockedInternal(ic.DAO, hash)) } -// IsBlockedInternal checks whether provided account is blocked +// IsBlockedInternal checks whether provided account is blocked. func (p *Policy) IsBlockedInternal(dao dao.DAO, hash util.Uint160) bool { p.lock.RLock() defer p.lock.RUnlock() diff --git a/pkg/core/state/contract.go b/pkg/core/state/contract.go index 6c2fd0310..3c6da196b 100644 --- a/pkg/core/state/contract.go +++ b/pkg/core/state/contract.go @@ -54,7 +54,7 @@ func (c *Contract) EncodeBinary(w *io.BinWriter) { stackitem.EncodeBinaryStackItem(si, w) } -// ToStackItem converts state.Contract to stackitem.Item +// ToStackItem converts state.Contract to stackitem.Item. func (c *Contract) ToStackItem() (stackitem.Item, error) { rawNef, err := c.NEF.Bytes() if err != nil { diff --git a/pkg/core/state/notification_event.go b/pkg/core/state/notification_event.go index d7b2706e8..a7c032b76 100644 --- a/pkg/core/state/notification_event.go +++ b/pkg/core/state/notification_event.go @@ -129,7 +129,7 @@ func (ne *NotificationEvent) UnmarshalJSON(data []byte) error { return nil } -// appExecResultAux is an auxiliary struct for JSON marshalling +// appExecResultAux is an auxiliary struct for JSON marshalling. type appExecResultAux struct { Container util.Uint256 `json:"container"` } diff --git a/pkg/core/storage/badgerdb_store.go b/pkg/core/storage/badgerdb_store.go index 277487058..619ca592a 100644 --- a/pkg/core/storage/badgerdb_store.go +++ b/pkg/core/storage/badgerdb_store.go @@ -17,12 +17,12 @@ type BadgerDBStore struct { db *badger.DB } -// BadgerDBBatch is a wrapper around badger.WriteBatch, compatible with Batch interface +// BadgerDBBatch is a wrapper around badger.WriteBatch, compatible with Batch interface. type BadgerDBBatch struct { batch *badger.WriteBatch } -// Delete implements the Batch interface +// Delete implements the Batch interface. func (b *BadgerDBBatch) Delete(key []byte) { err := b.batch.Delete(key) if err != nil { @@ -30,7 +30,7 @@ func (b *BadgerDBBatch) Delete(key []byte) { } } -// Put implements the Batch interface +// Put implements the Batch interface. func (b *BadgerDBBatch) Put(key, value []byte) { keycopy := make([]byte, len(key)) copy(keycopy, key) diff --git a/pkg/core/storage/store.go b/pkg/core/storage/store.go index 14bd13888..fe2d15703 100644 --- a/pkg/core/storage/store.go +++ b/pkg/core/storage/store.go @@ -69,7 +69,7 @@ func (k KeyPrefix) Bytes() []byte { } // AppendPrefix appends byteslice b to the given KeyPrefix. -// AppendKeyPrefix(SYSVersion, []byte{0x00, 0x01}) +// AppendKeyPrefix(SYSVersion, []byte{0x00, 0x01}). func AppendPrefix(k KeyPrefix, b []byte) []byte { dest := make([]byte, len(b)+1) dest[0] = byte(k) @@ -78,7 +78,7 @@ func AppendPrefix(k KeyPrefix, b []byte) []byte { } // AppendPrefixInt append int n to the given KeyPrefix. -//AppendPrefixInt(SYSCurrentHeader, 10001) +// AppendPrefixInt(SYSCurrentHeader, 10001) func AppendPrefixInt(k KeyPrefix, n int) []byte { b := make([]byte, 4) binary.LittleEndian.PutUint32(b, uint32(n)) diff --git a/pkg/core/transaction/attrtype.go b/pkg/core/transaction/attrtype.go index c6879fefa..7f339245f 100644 --- a/pkg/core/transaction/attrtype.go +++ b/pkg/core/transaction/attrtype.go @@ -6,9 +6,9 @@ package transaction type AttrType uint8 const ( - // ReservedLowerBound is the lower bound of reserved attribute types + // ReservedLowerBound is the lower bound of reserved attribute types. ReservedLowerBound = 0xe0 - // ReservedUpperBound is the upper bound of reserved attribute types + // ReservedUpperBound is the upper bound of reserved attribute types. ReservedUpperBound = 0xff ) diff --git a/pkg/core/transaction/helper_test.go b/pkg/core/transaction/helper_test.go index 13987a18c..53f53e079 100644 --- a/pkg/core/transaction/helper_test.go +++ b/pkg/core/transaction/helper_test.go @@ -8,7 +8,7 @@ import ( ) var ( - // tx from C# privnet 0x25426643feed564cd3e57f346d6c68692f5622b3063da11c5572d99ee1a5b49a + // tx from C# privnet 0x25426643feed564cd3e57f346d6c68692f5622b3063da11c5572d99ee1a5b49a. rawInvocationTX = "ANgkvBnA2KcAAAAAACCqRAAAAAAA6AMAAAHe7nnBifMAmLC6ai65CzqSWKbH/wEAXwsDAEDZ3YhNCgAMFIDOx7b1tW9QV49zfxYtOrFNRmUNDBTe7nnBifMAmLC6ai65CzqSWKbH/xTAHwwIdHJhbnNmZXIMFM924ovQBixKR47jVWEBExnzz6TSQWJ9W1I5AcYMQNafQPvPYQuqk3yCFwz8+18XCjnr8F8Rqx8e5IoQIkxjG9TjuvZm1KKGDn2UbFJnMey/FPLqezK8nbbJw2Eg10kMQKXrVyD3fs38e6Mqwsy7bAkxLsLnhvMnerbYLOqWW/DdinzT1RKAoOz5b7dAPusj5IWzQ6EifSCigJRTp//XdaMMQOv1d15PkIZM7wIvQmKDNxNy5yzQYFyoezx9Og7rM+64J9LtaHp3LFIKKNPgDhL7sFR1bd2w7vzbyR7V+Pyg3GaTEwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEF7zmyl" ) diff --git a/pkg/core/transaction/signer.go b/pkg/core/transaction/signer.go index 7cb93940e..ef409e25b 100644 --- a/pkg/core/transaction/signer.go +++ b/pkg/core/transaction/signer.go @@ -8,7 +8,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/util" ) -// The maximum number of AllowedContracts or AllowedGroups +// The maximum number of AllowedContracts or AllowedGroups. const maxSubitems = 16 // Signer implements a Transaction signer. diff --git a/pkg/core/transaction/transaction.go b/pkg/core/transaction/transaction.go index d49b8061d..893c72024 100644 --- a/pkg/core/transaction/transaction.go +++ b/pkg/core/transaction/transaction.go @@ -230,7 +230,7 @@ func (t *Transaction) DecodeHashableFields(buf []byte) error { return nil } -// Bytes converts the transaction to []byte +// Bytes converts the transaction to []byte. func (t *Transaction) Bytes() []byte { buf := io.NewBufBinWriter() t.EncodeBinary(buf.BinWriter) @@ -240,7 +240,7 @@ func (t *Transaction) Bytes() []byte { return buf.Bytes() } -// NewTransactionFromBytes decodes byte array into *Transaction +// NewTransactionFromBytes decodes byte array into *Transaction. func NewTransactionFromBytes(b []byte) (*Transaction, error) { tx := &Transaction{} r := io.NewBinReaderFromBuf(b) @@ -257,7 +257,7 @@ func NewTransactionFromBytes(b []byte) (*Transaction, error) { } // FeePerByte returns NetworkFee of the transaction divided by -// its size +// its size. func (t *Transaction) FeePerByte() int64 { return t.NetworkFee / int64(t.Size()) } @@ -280,7 +280,7 @@ func (t *Transaction) Sender() util.Uint160 { } // transactionJSON is a wrapper for Transaction and -// used for correct marhalling of transaction.Data +// used for correct marhalling of transaction.Data. type transactionJSON struct { TxID util.Uint256 `json:"hash"` Size int `json:"size"` diff --git a/pkg/crypto/keys/publickey.go b/pkg/crypto/keys/publickey.go index a3660d616..b7954bdd1 100644 --- a/pkg/crypto/keys/publickey.go +++ b/pkg/crypto/keys/publickey.go @@ -203,7 +203,7 @@ func NewPublicKeyFromASN1(data []byte) (*PublicKey, error) { // 1. Secp256k1 (Koblitz curve): y² = x³ + b, // 2. Secp256r1 (Random curve): y² = x³ - 3x + b. // To decode compressed curve point we perform the following operation: y = sqrt(x³ + ax + b mod p) -// where `p` denotes the order of the underlying curve field +// where `p` denotes the order of the underlying curve field. func decodeCompressedY(x *big.Int, ylsb uint, curve elliptic.Curve) (*big.Int, error) { var a *big.Int switch curve.(type) { diff --git a/pkg/encoding/bigint/bigint.go b/pkg/encoding/bigint/bigint.go index ed562821d..15d6df77b 100644 --- a/pkg/encoding/bigint/bigint.go +++ b/pkg/encoding/bigint/bigint.go @@ -9,7 +9,7 @@ import ( const ( // MaxBytesLen is the maximum length of serialized integer suitable for Neo VM. MaxBytesLen = 33 // 32 bytes for 256-bit integer plus 1 if padding needed - // wordSizeBytes is a size of a big.Word (uint) in bytes.` + // wordSizeBytes is a size of a big.Word (uint) in bytes. wordSizeBytes = bits.UintSize / 8 ) diff --git a/pkg/encoding/bigint/bigint_test.go b/pkg/encoding/bigint/bigint_test.go index 7b0455c34..bb8c2207c 100644 --- a/pkg/encoding/bigint/bigint_test.go +++ b/pkg/encoding/bigint/bigint_test.go @@ -149,7 +149,7 @@ var stringCases = []struct { // this cases are from stdlib // https://github.com/dotnet/runtime/blob/master/src/libraries/System.Runtime.Numerics/tests/BigInteger/ToByteArray.cs#L96 -// note that they are in big-endian +// note that they are in big-endian. var stdlibCases = []struct { numStr string buf []byte diff --git a/pkg/encoding/fixedn/fixed8.go b/pkg/encoding/fixedn/fixed8.go index 01abc8720..af3b82f9c 100644 --- a/pkg/encoding/fixedn/fixed8.go +++ b/pkg/encoding/fixedn/fixed8.go @@ -65,7 +65,7 @@ func Fixed8FromFloat(val float64) Fixed8 { } // Fixed8FromString parses s which must be a fixed point number -// with precision up to 10^-8 +// with precision up to 10^-8. func Fixed8FromString(s string) (Fixed8, error) { num, err := FromString(s, precision) if err != nil { diff --git a/pkg/interop/native/std/std.go b/pkg/interop/native/std/std.go index af263c8ba..135de27eb 100644 --- a/pkg/interop/native/std/std.go +++ b/pkg/interop/native/std/std.go @@ -46,11 +46,11 @@ func JSONSerialize(item interface{}) []byte { // JSONDeserialize deserializes value from json. It uses `jsonDeserialize` method of StdLib // native contract. // It performs deserialization as follows: -// strings -> []byte (string) from base64 -// integers -> (u)int* types -// null -> interface{}(nil) -// arrays -> []interface{} -// maps -> map[string]interface{} +// strings -> []byte (string) from base64 +// integers -> (u)int* types +// null -> interface{}(nil) +// arrays -> []interface{} +// maps -> map[string]interface{} func JSONDeserialize(data []byte) interface{} { return contract.Call(interop.Hash160(Hash), "jsonDeserialize", contract.NoneFlag, data) diff --git a/pkg/interop/types.go b/pkg/interop/types.go index f6ae0b11e..5ed473ccc 100644 --- a/pkg/interop/types.go +++ b/pkg/interop/types.go @@ -13,5 +13,5 @@ type Hash256 []byte type PublicKey []byte // Interface represents interop interface type which is needed for -// transparent handling of VM-internal types (e.g. storage.Context) +// transparent handling of VM-internal types (e.g. storage.Context). type Interface interface{} diff --git a/pkg/io/binaryReader.go b/pkg/io/binaryReader.go index 6915f5109..fdcb08249 100644 --- a/pkg/io/binaryReader.go +++ b/pkg/io/binaryReader.go @@ -167,7 +167,7 @@ func (r *BinReader) ReadVarUint() uint64 { } // ReadVarBytes reads the next set of bytes from the underlying reader. -// ReadVarUInt() is used to determine how large that slice is +// ReadVarUInt() is used to determine how large that slice is. func (r *BinReader) ReadVarBytes(maxSize ...int) []byte { n := r.ReadVarUint() ms := MaxArraySize diff --git a/pkg/network/capability/capability.go b/pkg/network/capability/capability.go index 7b489ef3a..32073129f 100644 --- a/pkg/network/capability/capability.go +++ b/pkg/network/capability/capability.go @@ -6,10 +6,10 @@ import ( "github.com/nspcc-dev/neo-go/pkg/io" ) -// MaxCapabilities is the maximum number of capabilities per payload +// MaxCapabilities is the maximum number of capabilities per payload. const MaxCapabilities = 32 -// Capabilities is a list of Capability +// Capabilities is a list of Capability. type Capabilities []Capability // DecodeBinary implements Serializable interface. @@ -49,7 +49,7 @@ func (cs Capabilities) checkUniqueCapabilities() error { return nil } -// Capability describes network service available for node +// Capability describes network service available for node. type Capability struct { Type Type Data io.Serializable @@ -80,7 +80,7 @@ func (c *Capability) EncodeBinary(bw *io.BinWriter) { c.Data.EncodeBinary(bw) } -// Node represents full node capability with start height +// Node represents full node capability with start height. type Node struct { StartHeight uint32 } @@ -95,9 +95,9 @@ func (n *Node) EncodeBinary(bw *io.BinWriter) { bw.WriteU32LE(n.StartHeight) } -// Server represents TCP or WS server capability with port +// Server represents TCP or WS server capability with port. type Server struct { - // Port is the port this server is listening on + // Port is the port this server is listening on. Port uint16 } diff --git a/pkg/network/capability/type.go b/pkg/network/capability/type.go index b25b15397..0955c1b38 100644 --- a/pkg/network/capability/type.go +++ b/pkg/network/capability/type.go @@ -1,13 +1,13 @@ package capability -// Type represents node capability type +// Type represents node capability type. type Type byte const ( - // TCPServer represents TCP node capability type + // TCPServer represents TCP node capability type. TCPServer Type = 0x01 - // WSServer represents WebSocket node capability type + // WSServer represents WebSocket node capability type. WSServer Type = 0x02 - // FullNode represents full node capability type + // FullNode represents full node capability type. FullNode Type = 0x10 ) diff --git a/pkg/network/discovery.go b/pkg/network/discovery.go index 25da5a5ba..1a56b703f 100644 --- a/pkg/network/discovery.go +++ b/pkg/network/discovery.go @@ -28,7 +28,7 @@ type Discoverer interface { GoodPeers() []AddressWithCapabilities } -// AddressWithCapabilities represents node address with its capabilities +// AddressWithCapabilities represents node address with its capabilities. type AddressWithCapabilities struct { Address string Capabilities capability.Capabilities @@ -94,7 +94,7 @@ func (d *DefaultDiscovery) PoolCount() int { } // pushToPoolOrDrop tries to push address given into the pool, but if the pool -// is already full, it just drops it +// is already full, it just drops it. func (d *DefaultDiscovery) pushToPoolOrDrop(addr string) { select { case d.pool <- addr: diff --git a/pkg/network/message.go b/pkg/network/message.go index 1a8025cb0..f2892aae9 100644 --- a/pkg/network/message.go +++ b/pkg/network/message.go @@ -34,10 +34,10 @@ type Message struct { StateRootInHeader bool } -// MessageFlag represents compression level of message payload +// MessageFlag represents compression level of message payload. type MessageFlag byte -// Possible message flags +// Possible message flags. const ( Compressed MessageFlag = 1 << iota None MessageFlag = 0 @@ -48,17 +48,17 @@ type CommandType byte // Valid protocol commands used to send between nodes. const ( - // handshaking + // Handshaking. CMDVersion CommandType = 0x00 CMDVerack CommandType = 0x01 - // connectivity + // Connectivity. CMDGetAddr CommandType = 0x10 CMDAddr CommandType = 0x11 CMDPing CommandType = 0x18 CMDPong CommandType = 0x19 - // synchronization + // Synchronization. CMDGetHeaders CommandType = 0x20 CMDHeaders CommandType = 0x21 CMDGetBlocks CommandType = 0x24 @@ -73,13 +73,13 @@ const ( CMDP2PNotaryRequest = CommandType(payload.P2PNotaryRequestType) CMDReject CommandType = 0x2f - // SPV protocol + // SPV protocol. CMDFilterLoad CommandType = 0x30 CMDFilterAdd CommandType = 0x31 CMDFilterClear CommandType = 0x32 CMDMerkleBlock CommandType = 0x38 - // others + // Others. CMDAlert CommandType = 0x40 ) @@ -197,7 +197,7 @@ func (m *Message) Bytes() ([]byte, error) { } // tryCompressPayload sets message's compressed payload to serialized -// payload and compresses it in case if its size exceeds CompressionMinSize +// payload and compresses it in case if its size exceeds CompressionMinSize. func (m *Message) tryCompressPayload() error { if m.Payload == nil { return nil diff --git a/pkg/network/payload/getblockbyindex.go b/pkg/network/payload/getblockbyindex.go index a4e59db1d..372af4d08 100644 --- a/pkg/network/payload/getblockbyindex.go +++ b/pkg/network/payload/getblockbyindex.go @@ -6,13 +6,13 @@ import ( "github.com/nspcc-dev/neo-go/pkg/io" ) -// GetBlockByIndex payload +// GetBlockByIndex payload. type GetBlockByIndex struct { IndexStart uint32 Count int16 } -// NewGetBlockByIndex returns GetBlockByIndex payload with specified start index and count +// NewGetBlockByIndex returns GetBlockByIndex payload with specified start index and count. func NewGetBlockByIndex(indexStart uint32, count int16) *GetBlockByIndex { return &GetBlockByIndex{ IndexStart: indexStart, diff --git a/pkg/network/payload/getblocks.go b/pkg/network/payload/getblocks.go index e3434ebce..b881559a3 100644 --- a/pkg/network/payload/getblocks.go +++ b/pkg/network/payload/getblocks.go @@ -12,9 +12,9 @@ const ( MaxHashesCount = 500 ) -// GetBlocks contains fields and methods to be shared with the +// GetBlocks contains getblocks message payload fields. type GetBlocks struct { - // hash of latest block that node requests + // Hash of the latest block that node requests. HashStart util.Uint256 Count int16 } diff --git a/pkg/rpc/client/client.go b/pkg/rpc/client/client.go index 4623a9070..9011e680c 100644 --- a/pkg/rpc/client/client.go +++ b/pkg/rpc/client/client.go @@ -21,7 +21,7 @@ import ( const ( defaultDialTimeout = 4 * time.Second defaultRequestTimeout = 4 * time.Second - // number of blocks after which cache is expired + // Number of blocks after which cache is expired. cacheTimeout = 100 ) @@ -52,14 +52,14 @@ type Options struct { RequestTimeout time.Duration } -// cache stores cache values for the RPC client methods +// cache stores cache values for the RPC client methods. type cache struct { calculateValidUntilBlock calculateValidUntilBlockCache nativeHashes map[string]util.Uint160 } // calculateValidUntilBlockCache stores cached number of validators and -// cache expiration value in blocks +// cache expiration value in blocks. type calculateValidUntilBlockCache struct { validatorsCount uint32 expiresAt uint32 diff --git a/pkg/rpc/client/rpc.go b/pkg/rpc/client/rpc.go index db88ff0df..e51078fbf 100644 --- a/pkg/rpc/client/rpc.go +++ b/pkg/rpc/client/rpc.go @@ -463,7 +463,7 @@ func (c *Client) InvokeContractVerify(contract util.Uint160, params []smartcontr return c.invokeSomething("invokecontractverify", p, signers, witnesses...) } -// invokeSomething is an inner wrapper for Invoke* functions +// invokeSomething is an inner wrapper for Invoke* functions. func (c *Client) invokeSomething(method string, p request.RawParams, signers []transaction.Signer, witnesses ...transaction.Witness) (*result.Invoke, error) { var resp = new(result.Invoke) if signers != nil { diff --git a/pkg/rpc/request/types.go b/pkg/rpc/request/types.go index 8da4f31b5..450815489 100644 --- a/pkg/rpc/request/types.go +++ b/pkg/rpc/request/types.go @@ -61,7 +61,7 @@ type In struct { // batch: https://www.jsonrpc.org/specification#batch. type Batch []In -// MarshalJSON implements json.Marshaler interface +// MarshalJSON implements json.Marshaler interface. func (r Request) MarshalJSON() ([]byte, error) { if r.In != nil { return json.Marshal(r.In) diff --git a/pkg/rpc/response/errors.go b/pkg/rpc/response/errors.go index 70201403b..e19df1166 100644 --- a/pkg/rpc/response/errors.go +++ b/pkg/rpc/response/errors.go @@ -20,17 +20,17 @@ type ( var ( // ErrInvalidParams represents a generic 'invalid parameters' error. ErrInvalidParams = NewInvalidParamsError("", nil) - // ErrAlreadyExists represents SubmitError with code -501 + // ErrAlreadyExists represents SubmitError with code -501. ErrAlreadyExists = NewSubmitError(-501, "Block or transaction already exists and cannot be sent repeatedly.") - // ErrOutOfMemory represents SubmitError with code -502 + // ErrOutOfMemory represents SubmitError with code -502. ErrOutOfMemory = NewSubmitError(-502, "The memory pool is full and no more transactions can be sent.") - // ErrUnableToVerify represents SubmitError with code -503 + // ErrUnableToVerify represents SubmitError with code -503. ErrUnableToVerify = NewSubmitError(-503, "The block cannot be validated.") - // ErrValidationFailed represents SubmitError with code -504 + // ErrValidationFailed represents SubmitError with code -504. ErrValidationFailed = NewSubmitError(-504, "Block or transaction validation failed.") - // ErrPolicyFail represents SubmitError with code -505 + // ErrPolicyFail represents SubmitError with code -505. ErrPolicyFail = NewSubmitError(-505, "One of the Policy filters failed.") - // ErrUnknown represents SubmitError with code -500 + // ErrUnknown represents SubmitError with code -500. ErrUnknown = NewSubmitError(-500, "Unknown error.") ) @@ -47,7 +47,7 @@ func NewError(code int64, httpCode int, message string, data string, cause error } // NewParseError creates a new error with code -// -32700.:%s +// -32700. func NewParseError(data string, cause error) *Error { return NewError(-32700, http.StatusBadRequest, "Parse Error", data, cause) } @@ -77,13 +77,13 @@ func NewInternalServerError(data string, cause error) *Error { } // NewRPCError creates a new error with -// code -100 +// code -100. func NewRPCError(message string, data string, cause error) *Error { return NewError(-100, http.StatusUnprocessableEntity, message, data, cause) } // NewSubmitError creates a new error with -// specified error code and error message +// specified error code and error message. func NewSubmitError(code int64, message string) *Error { return NewError(code, http.StatusUnprocessableEntity, message, "", nil) } diff --git a/pkg/rpc/response/result/unclaimed_gas.go b/pkg/rpc/response/result/unclaimed_gas.go index af051acdd..ae62b4124 100644 --- a/pkg/rpc/response/result/unclaimed_gas.go +++ b/pkg/rpc/response/result/unclaimed_gas.go @@ -9,13 +9,13 @@ import ( "github.com/nspcc-dev/neo-go/pkg/util" ) -// UnclaimedGas response wrapper +// UnclaimedGas response wrapper. type UnclaimedGas struct { Address util.Uint160 Unclaimed big.Int } -// unclaimedGas is an auxiliary struct for JSON marhsalling +// unclaimedGas is an auxiliary struct for JSON marhsalling. type unclaimedGas struct { Address string `json:"address"` Unclaimed string `json:"unclaimed"` diff --git a/pkg/rpc/rpc_config.go b/pkg/rpc/rpc_config.go index 27bd8bb4b..17aedec0c 100644 --- a/pkg/rpc/rpc_config.go +++ b/pkg/rpc/rpc_config.go @@ -5,7 +5,7 @@ import ( ) type ( - // Config is an RPC service configuration information + // Config is an RPC service configuration information. Config struct { Address string `yaml:"Address"` Enabled bool `yaml:"Enabled"` diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index 5c06eb6b3..3a62b3e6d 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -1179,7 +1179,7 @@ func (s *Server) getNextBlockValidators(_ request.Params) (interface{}, *respons return res, nil } -// getCommittee returns the current list of NEO committee members +// getCommittee returns the current list of NEO committee members. func (s *Server) getCommittee(_ request.Params) (interface{}, *response.Error) { keys, err := s.chain.GetCommittee() if err != nil { diff --git a/pkg/smartcontract/convertor.go b/pkg/smartcontract/convertor.go index 680238f29..c592807b8 100644 --- a/pkg/smartcontract/convertor.go +++ b/pkg/smartcontract/convertor.go @@ -7,7 +7,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" ) -// ParameterFromStackItem converts stackitem.Item to Parameter +// ParameterFromStackItem converts stackitem.Item to Parameter. func ParameterFromStackItem(i stackitem.Item, seen map[stackitem.Item]bool) Parameter { switch t := i.(type) { case stackitem.Null, *stackitem.Pointer: diff --git a/pkg/smartcontract/param_type.go b/pkg/smartcontract/param_type.go index 2875e60bd..2ea611a95 100644 --- a/pkg/smartcontract/param_type.go +++ b/pkg/smartcontract/param_type.go @@ -38,7 +38,7 @@ const ( // fileBytesParamType is a string representation of `filebytes` parameter type used in cli. const fileBytesParamType string = "filebytes" -// validParamTypes contains a map of known ParamTypes +// validParamTypes contains a map of known ParamTypes. var validParamTypes = map[ParamType]bool{ UnknownType: true, AnyType: true, diff --git a/pkg/smartcontract/trigger/trigger_type.go b/pkg/smartcontract/trigger/trigger_type.go index 60f3c1b08..86a00ff39 100644 --- a/pkg/smartcontract/trigger/trigger_type.go +++ b/pkg/smartcontract/trigger/trigger_type.go @@ -40,7 +40,7 @@ const ( All Type = OnPersist | PostPersist | Verification | Application ) -// FromString converts string to trigger Type +// FromString converts string to trigger Type. func FromString(str string) (Type, error) { triggers := []Type{OnPersist, PostPersist, Verification, Application, All} str = strings.ToLower(str) diff --git a/pkg/util/uint256.go b/pkg/util/uint256.go index 9e3c0df2f..ff764d4da 100644 --- a/pkg/util/uint256.go +++ b/pkg/util/uint256.go @@ -63,7 +63,7 @@ func (u Uint256) BytesBE() []byte { return u[:] } -// Reverse reverses the Uint256 object +// Reverse reverses the Uint256 object. func (u Uint256) Reverse() Uint256 { res, _ := Uint256DecodeBytesLE(u.BytesBE()) return res diff --git a/pkg/vm/opcode/opcode.go b/pkg/vm/opcode/opcode.go index e1fd89a56..3d24b7ea7 100644 --- a/pkg/vm/opcode/opcode.go +++ b/pkg/vm/opcode/opcode.go @@ -7,7 +7,7 @@ type Opcode byte // Viable list of supported instruction constants. const ( - // Constants + // Constants. PUSHINT8 Opcode = 0x00 PUSHINT16 Opcode = 0x01 PUSHINT32 Opcode = 0x02 @@ -43,7 +43,7 @@ const ( PUSH15 Opcode = 0x1F PUSH16 Opcode = 0x20 - // Flow control + // Flow control. NOP Opcode = 0x21 JMP Opcode = 0x22 JMPL Opcode = 0x23 // JMP_L @@ -68,7 +68,7 @@ const ( CALLA Opcode = 0x36 CALLT Opcode = 0x37 - // Exceptions + // Exceptions. ABORT Opcode = 0x38 ASSERT Opcode = 0x39 THROW Opcode = 0x3A @@ -81,7 +81,7 @@ const ( RET Opcode = 0x40 SYSCALL Opcode = 0x41 - // Stack + // Stack. DEPTH Opcode = 0x43 DROP Opcode = 0x45 NIP Opcode = 0x46 @@ -98,7 +98,7 @@ const ( REVERSE4 Opcode = 0x54 REVERSEN Opcode = 0x55 - // Slots + // Slots. INITSSLOT Opcode = 0x56 INITSLOT Opcode = 0x57 LDSFLD0 Opcode = 0x58 @@ -150,7 +150,7 @@ const ( STARG6 Opcode = 0x86 STARG Opcode = 0x87 - // Splice + // Splice. NEWBUFFER Opcode = 0x88 MEMCPY Opcode = 0x89 CAT Opcode = 0x8B @@ -158,7 +158,7 @@ const ( LEFT Opcode = 0x8D RIGHT Opcode = 0x8E - // Bitwise logic + // Bitwise logic. INVERT Opcode = 0x90 AND Opcode = 0x91 OR Opcode = 0x92 @@ -166,7 +166,7 @@ const ( EQUAL Opcode = 0x97 NOTEQUAL Opcode = 0x98 - // Arithmetic + // Arithmetic. SIGN Opcode = 0x99 ABS Opcode = 0x9A NEGATE Opcode = 0x9B @@ -195,7 +195,7 @@ const ( MAX Opcode = 0xBA WITHIN Opcode = 0xBB - // Advanced data structures (arrays, structures, maps) + // Advanced data structures (arrays, structures, maps). PACK Opcode = 0xC0 UNPACK Opcode = 0xC1 NEWARRAY0 Opcode = 0xC2 @@ -216,7 +216,7 @@ const ( CLEARITEMS Opcode = 0xD3 POPITEM Opcode = 0xD4 - // Types + // Types. ISNULL Opcode = 0xD8 ISTYPE Opcode = 0xD9 CONVERT Opcode = 0xDB diff --git a/pkg/vm/stackitem/item.go b/pkg/vm/stackitem/item.go index a0f8ba061..a8af99573 100644 --- a/pkg/vm/stackitem/item.go +++ b/pkg/vm/stackitem/item.go @@ -980,12 +980,12 @@ func (p *Pointer) Convert(typ Type) (Item, error) { } } -// ScriptHash returns pointer item hash +// ScriptHash returns pointer item hash. func (p *Pointer) ScriptHash() util.Uint160 { return p.hash } -// Position returns pointer item position +// Position returns pointer item position. func (p *Pointer) Position() int { return p.pos } diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 46f106482..f284d8c04 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -1487,7 +1487,7 @@ func getTryParams(op opcode.Opcode, p []byte) ([]byte, []byte) { return p[:i], p[i:] } -// getJumpCondition performs opcode specific comparison of a and b +// getJumpCondition performs opcode specific comparison of a and b. func getJumpCondition(op opcode.Opcode, a, b *big.Int) bool { cmp := a.Cmp(b) switch op { @@ -1790,17 +1790,17 @@ func bytesToPublicKey(b []byte, curve elliptic.Curve) *keys.PublicKey { return pkey } -// GetCallingScriptHash implements ScriptHashGetter interface +// GetCallingScriptHash implements ScriptHashGetter interface. func (v *VM) GetCallingScriptHash() util.Uint160 { return v.Context().callingScriptHash } -// GetEntryScriptHash implements ScriptHashGetter interface +// GetEntryScriptHash implements ScriptHashGetter interface. func (v *VM) GetEntryScriptHash() util.Uint160 { return v.getContextScriptHash(v.Istack().Len() - 1) } -// GetCurrentScriptHash implements ScriptHashGetter interface +// GetCurrentScriptHash implements ScriptHashGetter interface. func (v *VM) GetCurrentScriptHash() util.Uint160 { return v.getContextScriptHash(0) } diff --git a/pkg/vm/vm_test.go b/pkg/vm/vm_test.go index 2b3e97477..c70f9a282 100644 --- a/pkg/vm/vm_test.go +++ b/pkg/vm/vm_test.go @@ -641,7 +641,7 @@ func TestNOT(t *testing.T) { t.Run("Buffer1", getTestFuncForVM(prog, false, stackitem.NewBuffer([]byte{1}))) } -// getBigInt returns 2^a+b +// getBigInt returns 2^a+b. func getBigInt(a, b int64) *big.Int { p := new(big.Int).Exp(big.NewInt(2), big.NewInt(a), nil) p.Add(p, big.NewInt(b)) diff --git a/pkg/wallet/token.go b/pkg/wallet/token.go index 0c1e90e9f..ecea33f93 100644 --- a/pkg/wallet/token.go +++ b/pkg/wallet/token.go @@ -25,7 +25,7 @@ func NewToken(tokenHash util.Uint160, name, symbol string, decimals int64, stand } } -// Address returns token address from hash +// Address returns token address from hash. func (t *Token) Address() string { return address.Uint160ToString(t.Hash) } diff --git a/pkg/wallet/wallet.go b/pkg/wallet/wallet.go index 4b8bf364e..e365849fb 100644 --- a/pkg/wallet/wallet.go +++ b/pkg/wallet/wallet.go @@ -54,7 +54,7 @@ func NewWallet(location string) (*Wallet, error) { return newWallet(file), nil } -// NewWalletFromFile creates a Wallet from the given wallet file path +// NewWalletFromFile creates a Wallet from the given wallet file path. func NewWalletFromFile(path string) (*Wallet, error) { file, err := os.OpenFile(path, os.O_RDWR, os.ModeAppend) if err != nil {