mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-28 19:31:34 +00:00
*: enable godot linter and fix all its warnings
It's important for NeoGo to have clean documentation. No functional changes.
This commit is contained in:
parent
3fdba9265f
commit
9d2712573f
60 changed files with 127 additions and 126 deletions
|
@ -35,6 +35,7 @@ linters:
|
|||
- deadcode
|
||||
- errcheck
|
||||
- gosimple
|
||||
- godot
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- structcheck
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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()),
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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{}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue