mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
*: remove dead code
Found by deadcode via golangci-lint.
This commit is contained in:
parent
75a55d910e
commit
cfc067dd24
16 changed files with 2 additions and 183 deletions
|
@ -302,10 +302,6 @@ func isInteropPath(s string) bool {
|
|||
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.
|
||||
func canConvert(s string) bool {
|
||||
if len(s) != 0 && s[0] == '*' {
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/nspcc-dev/dbft/payload"
|
||||
"github.com/nspcc-dev/neo-go/internal/testchain"
|
||||
"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/stretchr/testify/require"
|
||||
)
|
||||
|
@ -157,16 +156,3 @@ func TestRecoveryMessage_Decode(t *testing.T) {
|
|||
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
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
"time"
|
||||
|
||||
"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/config"
|
||||
"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/storage"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
|
@ -180,51 +178,6 @@ func TestBug1728(t *testing.T) {
|
|||
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
|
||||
// for RPC unit tests. It also is a nice integration test.
|
||||
// To generate new "../rpc/testdata/testblocks.acc", follow the steps:
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"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/interop"
|
||||
"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
|
||||
}
|
||||
|
||||
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) {
|
||||
script := []byte("testscript")
|
||||
m := manifest.NewManifest("Test")
|
||||
|
|
|
@ -25,14 +25,7 @@ type Ledger struct {
|
|||
interop.ContractMD
|
||||
}
|
||||
|
||||
const (
|
||||
ledgerContractID = -4
|
||||
|
||||
prefixBlockHash = 9
|
||||
prefixCurrentBlock = 12
|
||||
prefixBlock = 5
|
||||
prefixTransaction = 11
|
||||
)
|
||||
const ledgerContractID = -4
|
||||
|
||||
// newLedger creates new Ledger native contract.
|
||||
func newLedger() *Ledger {
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package native
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"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/encoding/bigint"
|
||||
"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())
|
||||
}
|
||||
|
||||
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 {
|
||||
return dao.PutStorageItem(id, key, bigint.ToBytes(big.NewInt(value)))
|
||||
}
|
||||
|
|
|
@ -14,17 +14,6 @@ import (
|
|||
"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.
|
||||
func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error) {
|
||||
validators, err := validatorsFromConfig(cfg)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package fixedn
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
@ -13,8 +12,6 @@ const (
|
|||
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.
|
||||
type Fixed8 int64
|
||||
|
||||
|
|
|
@ -5,18 +5,6 @@ import (
|
|||
"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
|
||||
// structure. It's an io.Writer that doesn't do any real writes, but instead
|
||||
// just counts the number of bytes to be written.
|
||||
|
|
|
@ -2,7 +2,6 @@ package payload
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"math"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
|
@ -10,10 +9,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
)
|
||||
|
||||
const (
|
||||
maxExtensibleCategorySize = 32
|
||||
maxExtensibleDataSize = math.MaxUint16
|
||||
)
|
||||
const maxExtensibleCategorySize = 32
|
||||
|
||||
// Extensible represents payload containing arbitrary data.
|
||||
type Extensible struct {
|
||||
|
|
|
@ -41,12 +41,10 @@ const (
|
|||
var (
|
||||
errAlreadyConnected = errors.New("already connected")
|
||||
errIdenticalID = errors.New("identical node id")
|
||||
errInvalidHandshake = errors.New("invalid handshake")
|
||||
errInvalidNetwork = errors.New("invalid network")
|
||||
errMaxPeers = errors.New("max peers reached")
|
||||
errServerShutdown = errors.New("server shutdown")
|
||||
errInvalidInvType = errors.New("invalid inventory type")
|
||||
errInvalidHashStart = errors.New("invalid requested HashStart")
|
||||
)
|
||||
|
||||
type (
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
const (
|
||||
defaultDialTimeout = 4 * time.Second
|
||||
defaultRequestTimeout = 4 * time.Second
|
||||
defaultClientVersion = "2.0"
|
||||
// number of blocks after which cache is expired
|
||||
cacheTimeout = 100
|
||||
)
|
||||
|
|
|
@ -46,11 +46,6 @@ type executor struct {
|
|||
httpSrv *httptest.Server
|
||||
}
|
||||
|
||||
const (
|
||||
defaultJSONRPC = "2.0"
|
||||
defaultID = 1
|
||||
)
|
||||
|
||||
type rpcTestCase struct {
|
||||
name string
|
||||
params string
|
||||
|
@ -66,7 +61,6 @@ const genesisBlockHash = "73fe50b5564d57118296cbab0a78fe7cb11c97b7699d07a9a21fab
|
|||
const verifyContractHash = "c50082e0d8364d61ce6933bd24027a3363474dce"
|
||||
const verifyContractAVM = "VwMAQS1RCDAhcAwU7p6iLCfjS9AUj8QQjgj3To9QSLLbMHFoE87bKGnbKJdA"
|
||||
const verifyWithArgsContractHash = "8744ffdd07af8e9f18ab90685c8c2ebfd37c6415"
|
||||
const verifyWithArgsContractAVM = "VwIDeAwLZ29vZF9zdHJpbmeXJA15FSgJehHbIJciBRHbIHBoQA=="
|
||||
const invokescriptContractAVM = "VwcADBQBDAMOBQYMDQIODw0DDgcJAAAAANswcGhB+CfsjCGqJgQRQAwUDQ8DAgkAAgEDBwMEBQIBAA4GDAnbMHFpQfgn7IwhqiYEEkATQA=="
|
||||
|
||||
var rpcTestCases = map[string][]rpcTestCase{
|
||||
|
|
|
@ -3,7 +3,6 @@ package neofs
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
@ -24,10 +23,6 @@ const (
|
|||
// URIScheme is the name of neofs URI scheme.
|
||||
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 = '|'
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ type Field []uint64
|
|||
|
||||
// Bits and bytes count in a basic element of Field.
|
||||
const elemBits = 64
|
||||
const elemBytes = 8
|
||||
|
||||
// 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
|
||||
|
|
|
@ -61,18 +61,6 @@ type Contract struct {
|
|||
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
|
||||
// containing type and optional name.
|
||||
type ContractParam struct {
|
||||
|
|
Loading…
Reference in a new issue