*: remove dead code

Found by deadcode via golangci-lint.
This commit is contained in:
Roman Khimov 2021-05-12 18:13:14 +03:00
parent 75a55d910e
commit cfc067dd24
16 changed files with 2 additions and 183 deletions

View file

@ -302,10 +302,6 @@ func isInteropPath(s string) bool {
return strings.HasPrefix(s, interopPrefix) return strings.HasPrefix(s, interopPrefix)
} }
func isNativeHelpersPath(s string) bool {
return strings.HasPrefix(s, interopPrefix+"/native")
}
// canConvert returns true if type doesn't need to be converted on type assertion. // canConvert returns true if type doesn't need to be converted on type assertion.
func canConvert(s string) bool { func canConvert(s string) bool {
if len(s) != 0 && s[0] == '*' { if len(s) != 0 && s[0] == '*' {

View file

@ -7,7 +7,6 @@ import (
"github.com/nspcc-dev/dbft/payload" "github.com/nspcc-dev/dbft/payload"
"github.com/nspcc-dev/neo-go/internal/testchain" "github.com/nspcc-dev/neo-go/internal/testchain"
"github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/config/netmode"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -157,16 +156,3 @@ func TestRecoveryMessage_Decode(t *testing.T) {
require.Equal(t, gio.EOF, buf.Err) require.Equal(t, gio.EOF, buf.Err)
} }
*/ */
func getKeys(t *testing.T, n int) []*privateKey {
privs := make([]*privateKey, 0, n)
for i := 0; i < n; i++ {
priv, err := keys.NewPrivateKey()
require.NoError(t, err)
require.NotNil(t, priv)
privs = append(privs, &privateKey{PrivateKey: priv})
}
return privs
}

View file

@ -15,7 +15,6 @@ import (
"time" "time"
"github.com/nspcc-dev/neo-go/internal/testchain" "github.com/nspcc-dev/neo-go/internal/testchain"
"github.com/nspcc-dev/neo-go/internal/testserdes"
"github.com/nspcc-dev/neo-go/pkg/compiler" "github.com/nspcc-dev/neo-go/pkg/compiler"
"github.com/nspcc-dev/neo-go/pkg/config" "github.com/nspcc-dev/neo-go/pkg/config"
"github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/block"
@ -28,7 +27,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/storage" "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/core/transaction"
"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/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
@ -180,51 +178,6 @@ func TestBug1728(t *testing.T) {
require.Equal(t, aer.VMState, vm.HaltState) require.Equal(t, aer.VMState, vm.HaltState)
} }
func getDecodedBlock(t *testing.T, i int) *block.Block {
data, err := getBlockData(i)
require.NoError(t, err)
b, err := hex.DecodeString(data["raw"].(string))
require.NoError(t, err)
block := block.New(false)
require.NoError(t, testserdes.DecodeBinary(b, block))
return block
}
func getBlockData(i int) (map[string]interface{}, error) {
b, err := ioutil.ReadFile(fmt.Sprintf("test_data/block_%d.json", i))
if err != nil {
return nil, err
}
var data map[string]interface{}
if err := json.Unmarshal(b, &data); err != nil {
return nil, err
}
return data, err
}
func newDumbBlock() *block.Block {
return &block.Block{
Header: block.Header{
Version: 0,
PrevHash: hash.Sha256([]byte("a")),
MerkleRoot: hash.Sha256([]byte("b")),
Timestamp: 100500,
Index: 1,
NextConsensus: hash.Hash160([]byte("a")),
Script: transaction.Witness{
VerificationScript: []byte{0x51}, // PUSH1
InvocationScript: []byte{0x61}, // NOP
},
},
Transactions: []*transaction.Transaction{
transaction.New([]byte{byte(opcode.PUSH1)}, 0),
},
}
}
// This function generates "../rpc/testdata/testblocks.acc" file which contains data // This function generates "../rpc/testdata/testblocks.acc" file which contains data
// for RPC unit tests. It also is a nice integration test. // for RPC unit tests. It also is a nice integration test.
// To generate new "../rpc/testdata/testblocks.acc", follow the steps: // To generate new "../rpc/testdata/testblocks.acc", follow the steps:

View file

@ -7,7 +7,6 @@ import (
"testing" "testing"
"github.com/nspcc-dev/neo-go/internal/random" "github.com/nspcc-dev/neo-go/internal/random"
"github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/dao" "github.com/nspcc-dev/neo-go/pkg/core/dao"
"github.com/nspcc-dev/neo-go/pkg/core/interop" "github.com/nspcc-dev/neo-go/pkg/core/interop"
"github.com/nspcc-dev/neo-go/pkg/core/interop/contract" "github.com/nspcc-dev/neo-go/pkg/core/interop/contract"
@ -451,27 +450,6 @@ func createVM(t *testing.T) (*vm.VM, *interop.Context, *Blockchain) {
return v, context, chain return v, context, chain
} }
func createVMAndPushBlock(t *testing.T) (*vm.VM, *block.Block, *interop.Context, *Blockchain) {
v, block, context, chain := createVMAndBlock(t)
v.Estack().PushVal(stackitem.NewInterop(block))
return v, block, context, chain
}
func createVMAndBlock(t *testing.T) (*vm.VM, *block.Block, *interop.Context, *Blockchain) {
block := newDumbBlock()
chain := newTestChain(t)
d := dao.NewSimple(storage.NewMemoryStore(), chain.GetConfig().StateRootInHeader)
context := chain.newInteropContext(trigger.Application, d, block, nil)
v := context.SpawnVM()
return v, block, context, chain
}
func createVMAndPushTX(t *testing.T) (*vm.VM, *transaction.Transaction, *interop.Context, *Blockchain) {
v, tx, context, chain := createVMAndTX(t)
v.Estack().PushVal(stackitem.NewInterop(tx))
return v, tx, context, chain
}
func createVMAndContractState(t *testing.T) (*vm.VM, *state.Contract, *interop.Context, *Blockchain) { func createVMAndContractState(t *testing.T) (*vm.VM, *state.Contract, *interop.Context, *Blockchain) {
script := []byte("testscript") script := []byte("testscript")
m := manifest.NewManifest("Test") m := manifest.NewManifest("Test")

View file

@ -25,14 +25,7 @@ type Ledger struct {
interop.ContractMD interop.ContractMD
} }
const ( const ledgerContractID = -4
ledgerContractID = -4
prefixBlockHash = 9
prefixCurrentBlock = 12
prefixBlock = 5
prefixTransaction = 11
)
// newLedger creates new Ledger native contract. // newLedger creates new Ledger native contract.
func newLedger() *Ledger { func newLedger() *Ledger {

View file

@ -1,13 +1,11 @@
package native package native
import ( import (
"encoding/binary"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"math/big" "math/big"
"github.com/nspcc-dev/neo-go/pkg/core/dao" "github.com/nspcc-dev/neo-go/pkg/core/dao"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/storage" "github.com/nspcc-dev/neo-go/pkg/core/storage"
"github.com/nspcc-dev/neo-go/pkg/encoding/bigint" "github.com/nspcc-dev/neo-go/pkg/encoding/bigint"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
@ -36,34 +34,6 @@ func putSerializableToDAO(id int32, d dao.DAO, key []byte, item io.Serializable)
return d.PutStorageItem(id, key, w.Bytes()) return d.PutStorageItem(id, key, w.Bytes())
} }
func getInt64WithKey(id int32, d dao.DAO, key []byte, defaultValue int64) int64 {
si := d.GetStorageItem(id, key)
if si == nil {
return defaultValue
}
return int64(binary.LittleEndian.Uint64(si))
}
func setInt64WithKey(id int32, dao dao.DAO, key []byte, value int64) error {
si := make(state.StorageItem, 8)
binary.LittleEndian.PutUint64(si, uint64(value))
return dao.PutStorageItem(id, key, si)
}
func getUint32WithKey(id int32, dao dao.DAO, key []byte, defaultValue uint32) uint32 {
si := dao.GetStorageItem(id, key)
if si == nil {
return defaultValue
}
return binary.LittleEndian.Uint32(si)
}
func setUint32WithKey(id int32, dao dao.DAO, key []byte, value uint32) error {
si := make(state.StorageItem, 4)
binary.LittleEndian.PutUint32(si, value)
return dao.PutStorageItem(id, key, si)
}
func setIntWithKey(id int32, dao dao.DAO, key []byte, value int64) error { func setIntWithKey(id int32, dao dao.DAO, key []byte, value int64) error {
return dao.PutStorageItem(id, key, bigint.ToBytes(big.NewInt(value))) return dao.PutStorageItem(id, key, bigint.ToBytes(big.NewInt(value)))
} }

View file

@ -14,17 +14,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/opcode"
) )
var (
// governingTokenTX represents transaction that is used to create
// governing (NEO) token. It's a part of the genesis block.
governingTokenTX transaction.Transaction
// utilityTokenTX represents transaction that is used to create
// utility (GAS) token. It's a part of the genesis block. It's mostly
// useful for its hash that represents GAS asset ID.
utilityTokenTX transaction.Transaction
)
// createGenesisBlock creates a genesis block based on the given configuration. // createGenesisBlock creates a genesis block based on the given configuration.
func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error) { func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error) {
validators, err := validatorsFromConfig(cfg) validators, err := validatorsFromConfig(cfg)

View file

@ -1,7 +1,6 @@
package fixedn package fixedn
import ( import (
"errors"
"strconv" "strconv"
"strings" "strings"
@ -13,8 +12,6 @@ const (
decimals = 100000000 decimals = 100000000
) )
var errInvalidString = errors.New("fixed8 must satisfy following regex \\d+(\\.\\d{1,8})?")
// Fixed8 represents a fixed-point number with precision 10^-8. // Fixed8 represents a fixed-point number with precision 10^-8.
type Fixed8 int64 type Fixed8 int64

View file

@ -5,18 +5,6 @@ import (
"reflect" "reflect"
) )
var (
bit8 byte
ui8 uint8
ui16 uint16
ui32 uint32
ui64 uint64
i8 int8
i16 int16
i32 int32
i64 int64
)
// This structure is used to calculate the wire size of the serializable // This structure is used to calculate the wire size of the serializable
// structure. It's an io.Writer that doesn't do any real writes, but instead // structure. It's an io.Writer that doesn't do any real writes, but instead
// just counts the number of bytes to be written. // just counts the number of bytes to be written.

View file

@ -2,7 +2,6 @@ package payload
import ( import (
"errors" "errors"
"math"
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "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/crypto/hash"
@ -10,10 +9,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
) )
const ( const maxExtensibleCategorySize = 32
maxExtensibleCategorySize = 32
maxExtensibleDataSize = math.MaxUint16
)
// Extensible represents payload containing arbitrary data. // Extensible represents payload containing arbitrary data.
type Extensible struct { type Extensible struct {

View file

@ -41,12 +41,10 @@ const (
var ( var (
errAlreadyConnected = errors.New("already connected") errAlreadyConnected = errors.New("already connected")
errIdenticalID = errors.New("identical node id") errIdenticalID = errors.New("identical node id")
errInvalidHandshake = errors.New("invalid handshake")
errInvalidNetwork = errors.New("invalid network") errInvalidNetwork = errors.New("invalid network")
errMaxPeers = errors.New("max peers reached") errMaxPeers = errors.New("max peers reached")
errServerShutdown = errors.New("server shutdown") errServerShutdown = errors.New("server shutdown")
errInvalidInvType = errors.New("invalid inventory type") errInvalidInvType = errors.New("invalid inventory type")
errInvalidHashStart = errors.New("invalid requested HashStart")
) )
type ( type (

View file

@ -21,7 +21,6 @@ import (
const ( const (
defaultDialTimeout = 4 * time.Second defaultDialTimeout = 4 * time.Second
defaultRequestTimeout = 4 * time.Second defaultRequestTimeout = 4 * time.Second
defaultClientVersion = "2.0"
// number of blocks after which cache is expired // number of blocks after which cache is expired
cacheTimeout = 100 cacheTimeout = 100
) )

View file

@ -46,11 +46,6 @@ type executor struct {
httpSrv *httptest.Server httpSrv *httptest.Server
} }
const (
defaultJSONRPC = "2.0"
defaultID = 1
)
type rpcTestCase struct { type rpcTestCase struct {
name string name string
params string params string
@ -66,7 +61,6 @@ const genesisBlockHash = "73fe50b5564d57118296cbab0a78fe7cb11c97b7699d07a9a21fab
const verifyContractHash = "c50082e0d8364d61ce6933bd24027a3363474dce" const verifyContractHash = "c50082e0d8364d61ce6933bd24027a3363474dce"
const verifyContractAVM = "VwMAQS1RCDAhcAwU7p6iLCfjS9AUj8QQjgj3To9QSLLbMHFoE87bKGnbKJdA" const verifyContractAVM = "VwMAQS1RCDAhcAwU7p6iLCfjS9AUj8QQjgj3To9QSLLbMHFoE87bKGnbKJdA"
const verifyWithArgsContractHash = "8744ffdd07af8e9f18ab90685c8c2ebfd37c6415" const verifyWithArgsContractHash = "8744ffdd07af8e9f18ab90685c8c2ebfd37c6415"
const verifyWithArgsContractAVM = "VwIDeAwLZ29vZF9zdHJpbmeXJA15FSgJehHbIJciBRHbIHBoQA=="
const invokescriptContractAVM = "VwcADBQBDAMOBQYMDQIODw0DDgcJAAAAANswcGhB+CfsjCGqJgQRQAwUDQ8DAgkAAgEDBwMEBQIBAA4GDAnbMHFpQfgn7IwhqiYEEkATQA==" const invokescriptContractAVM = "VwcADBQBDAMOBQYMDQIODw0DDgcJAAAAANswcGhB+CfsjCGqJgQRQAwUDQ8DAgkAAgEDBwMEBQIBAA4GDAnbMHFpQfgn7IwhqiYEEkATQA=="
var rpcTestCases = map[string][]rpcTestCase{ var rpcTestCases = map[string][]rpcTestCase{

View file

@ -3,7 +3,6 @@ package neofs
import ( import (
"bytes" "bytes"
"context" "context"
"crypto/sha256"
"errors" "errors"
"fmt" "fmt"
"net/url" "net/url"
@ -24,10 +23,6 @@ const (
// URIScheme is the name of neofs URI scheme. // URIScheme is the name of neofs URI scheme.
URIScheme = "neofs" URIScheme = "neofs"
// containerIDSize is the size of container id in bytes.
containerIDSize = sha256.Size
// objectIDSize is the size of container id in bytes.
objectIDSize = sha256.Size
// rangeSep is a separator between offset and length. // rangeSep is a separator between offset and length.
rangeSep = '|' rangeSep = '|'

View file

@ -10,7 +10,6 @@ type Field []uint64
// Bits and bytes count in a basic element of Field. // Bits and bytes count in a basic element of Field.
const elemBits = 64 const elemBits = 64
const elemBytes = 8
// New creates a new bit field of specified length. Actual field length // New creates a new bit field of specified length. Actual field length
// can be rounded to the next multiple of 64, so it's a responsibility // can be rounded to the next multiple of 64, so it's a responsibility

View file

@ -61,18 +61,6 @@ type Contract struct {
Deployed bool `json:"deployed"` Deployed bool `json:"deployed"`
} }
// contract is an intermediate struct used for json unmarshalling.
type contract struct {
// Script is a hex-encoded script of the contract.
Script string `json:"script"`
// A list of parameters used deploying this contract.
Parameters []ContractParam `json:"parameters"`
// Indicates whether the contract has been deployed to the blockchain.
Deployed bool `json:"deployed"`
}
// ContractParam is a descriptor of a contract parameter // ContractParam is a descriptor of a contract parameter
// containing type and optional name. // containing type and optional name.
type ContractParam struct { type ContractParam struct {