mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
Merge 02c2242791 into e39ca5e597
This commit is contained in:
commit
f9eec423a0
37 changed files with 56 additions and 16 deletions
|
|
@ -50,6 +50,7 @@ func U256(n *big.Int) []byte {
|
|||
}
|
||||
|
||||
// checks whether the given reflect value is signed. This also works for slices with a number type
|
||||
// nolint: deadcode
|
||||
func isSigned(v reflect.Value) bool {
|
||||
switch v.Type() {
|
||||
case int_ts, int8_ts, int16_ts, int32_ts, int64_ts, int_t, int8_t, int16_t, int32_t, int64_t:
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ type ledgerParam1 byte
|
|||
// specific opcodes. The same parameter values may be reused between opcodes.
|
||||
type ledgerParam2 byte
|
||||
|
||||
// nolint: deadcode
|
||||
const (
|
||||
ledgerOpRetrieveAddress ledgerOpcode = 0x02 // Returns the public key and Ethereum address for a given BIP 32 path
|
||||
ledgerOpSignTransaction ledgerOpcode = 0x04 // Signs an Ethereum transaction after having the user validate the parameters
|
||||
|
|
|
|||
|
|
@ -323,7 +323,14 @@ func doLint(cmdline []string) {
|
|||
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), "--install")
|
||||
|
||||
// Run fast linters batched together
|
||||
configs := []string{"--vendor", "--disable-all", "--enable=vet", "--enable=gofmt", "--enable=misspell"}
|
||||
configs := []string{"--vendor", "-t",
|
||||
"--disable-all",
|
||||
"--exclude=cmd/faucet/website.go",
|
||||
"--enable=vet",
|
||||
"--enable=gofmt",
|
||||
"--enable=misspell",
|
||||
"--enable=deadcode",
|
||||
}
|
||||
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...)
|
||||
|
||||
// Run slow linters one by one
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ const (
|
|||
)
|
||||
|
||||
// Clique proof-of-authority protocol constants.
|
||||
// nolint: deadcode
|
||||
var (
|
||||
epochLength = uint64(30000) // Default number of blocks after which to checkpoint and reset the pending votes
|
||||
blockPeriod = uint64(15) // Default minimum difference between two consecutive block's timestamps
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ func swap(buffer []byte) {
|
|||
// prepare converts an ethash cache or dataset from a byte stream into the internal
|
||||
// int representation. All ethash methods work with ints to avoid constant byte to
|
||||
// int conversions as well as to handle both little and big endian systems.
|
||||
// nolint: deadcode
|
||||
func prepare(dest []uint32, src []byte) {
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = binary.LittleEndian.Uint32(src[i*4:])
|
||||
|
|
|
|||
|
|
@ -267,6 +267,7 @@ func (err compileError) Error() string {
|
|||
return fmt.Sprintf("%d syntax error: unexpected %v, expected %v", err.lineno, err.got, err.want)
|
||||
}
|
||||
|
||||
// nolint: deadcode
|
||||
var (
|
||||
errExpBol = errors.New("expected beginning of line")
|
||||
errExpElementOrLabel = errors.New("expected beginning of line")
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import (
|
|||
)
|
||||
|
||||
// So we can deterministically seed different blockchains
|
||||
// nolint: deadcode
|
||||
var (
|
||||
canonicalSeed = 1
|
||||
forkSeed = 2
|
||||
|
|
@ -229,6 +230,7 @@ func makeHeader(config *params.ChainConfig, parent *types.Block, state *state.St
|
|||
// newCanonical creates a chain database, and injects a deterministic canonical
|
||||
// chain. Depending on the full flag, if creates either a full block chain or a
|
||||
// header only chain.
|
||||
// nolint: deadcode
|
||||
func newCanonical(n int, full bool) (ethdb.Database, *BlockChain, error) {
|
||||
// Initialize a fresh chain with only a genesis block
|
||||
gspec := new(Genesis)
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ type GenesisAccount struct {
|
|||
}
|
||||
|
||||
// field type overrides for gencodec
|
||||
// nolint: deadcode
|
||||
type genesisSpecMarshaling struct {
|
||||
Nonce math.HexOrDecimal64
|
||||
Timestamp math.HexOrDecimal64
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
const (
|
||||
// chainHeadChanSize is the size of channel listening to ChainHeadEvent.
|
||||
chainHeadChanSize = 10
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ type Header struct {
|
|||
}
|
||||
|
||||
// field type overrides for gencodec
|
||||
// nolint: deadcode
|
||||
type headerMarshaling struct {
|
||||
Difficulty *hexutil.Big
|
||||
Number *hexutil.Big
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ type Log struct {
|
|||
Removed bool `json:"removed"`
|
||||
}
|
||||
|
||||
// nolint: deadcode
|
||||
type logMarshaling struct {
|
||||
Data hexutil.Bytes
|
||||
BlockNumber hexutil.Uint64
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ type Receipt struct {
|
|||
GasUsed *big.Int `json:"gasUsed" gencodec:"required"`
|
||||
}
|
||||
|
||||
// nolint: deadcode
|
||||
type receiptMarshaling struct {
|
||||
PostState hexutil.Bytes
|
||||
Status hexutil.Uint
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import (
|
|||
|
||||
//go:generate gencodec -type txdata -field-override txdataMarshaling -out gen_tx_json.go
|
||||
|
||||
// nolint: deadcode
|
||||
var (
|
||||
ErrInvalidSig = errors.New("invalid transaction v, r, s values")
|
||||
errNoSigner = errors.New("missing signing methods")
|
||||
|
|
@ -71,6 +72,7 @@ type txdata struct {
|
|||
Hash *common.Hash `json:"hash" rlp:"-"`
|
||||
}
|
||||
|
||||
// nolint: deadcode
|
||||
type txdataMarshaling struct {
|
||||
AccountNonce hexutil.Uint64
|
||||
Price *hexutil.Big
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ type StructLog struct {
|
|||
}
|
||||
|
||||
// overrides for gencodec
|
||||
// nolint: deadcode
|
||||
type structLogMarshaling struct {
|
||||
Stack []*math.HexOrDecimal256
|
||||
Gas math.HexOrDecimal64
|
||||
|
|
|
|||
|
|
@ -65,12 +65,6 @@ func memoryCall(stack *Stack) *big.Int {
|
|||
return math.BigMax(x, y)
|
||||
}
|
||||
|
||||
func memoryCallCode(stack *Stack) *big.Int {
|
||||
x := calcMemSize(stack.Back(5), stack.Back(6))
|
||||
y := calcMemSize(stack.Back(3), stack.Back(4))
|
||||
|
||||
return math.BigMax(x, y)
|
||||
}
|
||||
func memoryDelegateCall(stack *Stack) *big.Int {
|
||||
x := calcMemSize(stack.Back(4), stack.Back(5))
|
||||
y := calcMemSize(stack.Back(2), stack.Back(3))
|
||||
|
|
|
|||
|
|
@ -13,4 +13,5 @@ var (
|
|||
copyOutUnaligned = copyOutGeneric
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
const xorImplementationUnaligned = "generic"
|
||||
|
|
|
|||
|
|
@ -55,4 +55,5 @@ var (
|
|||
copyOut = copyOutUnaligned
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
const xorImplementationUnaligned = "unaligned"
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ type Config struct {
|
|||
PowShared bool `toml:"-"`
|
||||
}
|
||||
|
||||
// nolint: deadcode
|
||||
type configMarshaling struct {
|
||||
ExtraData hexutil.Bytes
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ var (
|
|||
fsCriticalTrials = uint32(32) // Number of times to retry in the cricical section before bailing
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
var (
|
||||
errBusy = errors.New("busy")
|
||||
errUnknownPeer = errors.New("peer is unknown or unhealthy")
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ func (eth *LightEthereum) startBloomHandlers() {
|
|||
}
|
||||
}
|
||||
|
||||
// nolint: deadcode
|
||||
const (
|
||||
// bloomConfirms is the number of confirmation blocks before a bloom section is
|
||||
// considered probably final and its rotated bits are calculated.
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/rlp"
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
const (
|
||||
// After a connection has been ended or timed out, there is a waiting period
|
||||
// before it can be selected for connection again.
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/light"
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
const (
|
||||
//forceSyncCycle = 10 * time.Second // Time interval to force syncs, even if few peers are available
|
||||
minDesiredPeerCount = 5 // Amount of peers desired to start syncing
|
||||
|
|
|
|||
|
|
@ -412,6 +412,7 @@ func logdist(a, b common.Hash) int {
|
|||
}
|
||||
|
||||
// hashAtDistance returns a random hash such that logdist(a, b) == n
|
||||
// nolint: deadcode
|
||||
func hashAtDistance(a common.Hash, n int) (b common.Hash) {
|
||||
if n == 0 {
|
||||
return a
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ var (
|
|||
)
|
||||
|
||||
// Timeouts
|
||||
// nolint: deadcode
|
||||
const (
|
||||
respTimeout = 500 * time.Millisecond
|
||||
sendTimeout = 500 * time.Millisecond
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/rlp"
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
var (
|
||||
errInvalidEvent = errors.New("invalid in current state")
|
||||
errNoQuery = errors.New("no pending query")
|
||||
|
|
@ -48,6 +49,7 @@ const (
|
|||
lowPort = 1024
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
const testTopic = "foo"
|
||||
|
||||
const (
|
||||
|
|
@ -825,12 +827,11 @@ type nodeEvent uint
|
|||
|
||||
//go:generate stringer -type=nodeEvent
|
||||
|
||||
//
|
||||
const (
|
||||
invalidEvent nodeEvent = iota // zero is reserved
|
||||
|
||||
// Packet type events.
|
||||
// These correspond to packet types in the UDP protocol.
|
||||
pingPacket
|
||||
pingPacket nodeEvent = iota + 1
|
||||
pongPacket
|
||||
findnodePacket
|
||||
neighborsPacket
|
||||
|
|
|
|||
|
|
@ -413,6 +413,7 @@ func logdist(a, b common.Hash) int {
|
|||
}
|
||||
|
||||
// hashAtDistance returns a random hash such that logdist(a, b) == n
|
||||
// nolint: deadcode
|
||||
func hashAtDistance(a common.Hash, n int) (b common.Hash) {
|
||||
if n == 0 {
|
||||
return a
|
||||
|
|
|
|||
|
|
@ -1,25 +1,26 @@
|
|||
// Code generated by "stringer -type nodeEvent"; DO NOT EDIT
|
||||
// Code generated by "stringer -type=nodeEvent"; DO NOT EDIT.
|
||||
|
||||
package discv5
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
_nodeEvent_name_0 = "invalidEventpingPacketpongPacketfindnodePacketneighborsPacketfindnodeHashPackettopicRegisterPackettopicQueryPackettopicNodesPacket"
|
||||
_nodeEvent_name_0 = "pingPacketpongPacketfindnodePacketneighborsPacketfindnodeHashPackettopicRegisterPackettopicQueryPackettopicNodesPacket"
|
||||
_nodeEvent_name_1 = "pongTimeoutpingTimeoutneighboursTimeout"
|
||||
)
|
||||
|
||||
var (
|
||||
_nodeEvent_index_0 = [...]uint8{0, 12, 22, 32, 46, 61, 79, 98, 114, 130}
|
||||
_nodeEvent_index_0 = [...]uint8{0, 10, 20, 34, 49, 67, 86, 102, 118}
|
||||
_nodeEvent_index_1 = [...]uint8{0, 11, 22, 39}
|
||||
)
|
||||
|
||||
func (i nodeEvent) String() string {
|
||||
switch {
|
||||
case 0 <= i && i <= 8:
|
||||
case 1 <= i && i <= 8:
|
||||
i -= 1
|
||||
return _nodeEvent_name_0[_nodeEvent_index_0[i]:_nodeEvent_index_0[i+1]]
|
||||
case 265 <= i && i <= 267:
|
||||
i -= 265
|
||||
case 264 <= i && i <= 266:
|
||||
i -= 264
|
||||
return _nodeEvent_name_1[_nodeEvent_index_1[i]:_nodeEvent_index_1[i+1]]
|
||||
default:
|
||||
return fmt.Sprintf("nodeEvent(%d)", i)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ func (s durationSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
|||
|
||||
// checkClockDrift queries an NTP server for clock drifts and warns the user if
|
||||
// one large enough is detected.
|
||||
// nolint: deadcode
|
||||
func checkClockDrift() {
|
||||
drift, err := sntpDrift(ntpChecks)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
const (
|
||||
alpha = 3 // Kademlia concurrency factor
|
||||
bucketSize = 16 // Kademlia bucket size
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
const Version = 4
|
||||
|
||||
// Errors
|
||||
// nolint: deadcode
|
||||
var (
|
||||
errPacketTooSmall = errors.New("too small")
|
||||
errBadHash = errors.New("bad hash")
|
||||
|
|
@ -47,6 +48,7 @@ var (
|
|||
)
|
||||
|
||||
// Timeouts
|
||||
// nolint: deadcode
|
||||
const (
|
||||
respTimeout = 500 * time.Millisecond
|
||||
sendTimeout = 500 * time.Millisecond
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ func SendItems(w MsgWriter, msgcode uint64, elems ...interface{}) error {
|
|||
|
||||
// netWrapper wraps a MsgReadWriter with locks around
|
||||
// ReadMsg/WriteMsg and applies read/write deadlines.
|
||||
// nolint: deadcode
|
||||
type netWrapper struct {
|
||||
rmu, wmu sync.Mutex
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ const (
|
|||
pingInterval = 15 * time.Second
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
const (
|
||||
// devp2p message codes
|
||||
handshakeMsg = 0x00
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/p2p/netutil"
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
const (
|
||||
defaultDialTimeout = 15 * time.Second
|
||||
refreshPeersInterval = 30 * time.Second
|
||||
|
|
|
|||
|
|
@ -307,6 +307,7 @@ type nodesByDistance struct {
|
|||
target Address
|
||||
}
|
||||
|
||||
// nolint: deadcode
|
||||
func sortedByDistanceTo(target Address, slice []Node) bool {
|
||||
var last Address
|
||||
for i, node := range slice {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import (
|
|||
"github.com/syndtr/goleveldb/leveldb/iterator"
|
||||
)
|
||||
|
||||
// nolint: deadcode
|
||||
const (
|
||||
defaultDbCapacity = 5000000
|
||||
defaultRadius = 0 // not yet used
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ func NewNetStore(hash SwarmHasher, lstore *LocalStore, cloud CloudStore, params
|
|||
}
|
||||
}
|
||||
|
||||
// nolint: deadcode
|
||||
const (
|
||||
// maximum number of peers that a retrieved message is delivered to
|
||||
requesterCount = 3
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ func newTopicMatcher(topics ...[]Topic) *topicMatcher {
|
|||
}
|
||||
|
||||
// newTopicMatcherFromBinary create a topic matcher from a list of binary conditions.
|
||||
// nolint: deadcode
|
||||
func newTopicMatcherFromBinary(data ...[][]byte) *topicMatcher {
|
||||
topics := make([][]Topic, len(data))
|
||||
for i, condition := range data {
|
||||
|
|
@ -114,6 +115,7 @@ func newTopicMatcherFromBinary(data ...[][]byte) *topicMatcher {
|
|||
|
||||
// newTopicMatcherFromStrings creates a topic matcher from a list of textual
|
||||
// conditions.
|
||||
// nolint: deadcode
|
||||
func newTopicMatcherFromStrings(data ...[]string) *topicMatcher {
|
||||
topics := make([][]Topic, len(data))
|
||||
for i, condition := range data {
|
||||
|
|
|
|||
Loading…
Reference in a new issue