Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Drop Dead Code #138

Merged
merged 3 commits into from Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions accounts/abi/abi.go
Expand Up @@ -225,8 +225,6 @@ func toGoType(i int, t Argument, output []byte) (interface{}, error) {
// assignment.
var (
r_interSlice = reflect.TypeOf([]interface{}{})
r_hash = reflect.TypeOf(common.Hash{})
r_bytes = reflect.TypeOf([]byte{})
r_byte = reflect.TypeOf(byte(0))
)

Expand Down
5 changes: 0 additions & 5 deletions accounts/abi/error.go
Expand Up @@ -68,11 +68,6 @@ func typeCheck(t Type, value reflect.Value) error {
return nil
}

// varErr returns a formatted error.
func varErr(expected, got reflect.Kind) error {
return typeErr(expected, got)
}

// typeErr returns a formatted type casting error.
func typeErr(expected, got interface{}) error {
return fmt.Errorf("abi: cannot use %v as type %v as argument", got, expected)
Expand Down
16 changes: 0 additions & 16 deletions accounts/abi/numbers.go
Expand Up @@ -26,34 +26,18 @@ import (
var (
big_t = reflect.TypeOf(big.Int{})
ubig_t = reflect.TypeOf(big.Int{})
byte_t = reflect.TypeOf(byte(0))
byte_ts = reflect.TypeOf([]byte(nil))
uint_t = reflect.TypeOf(uint(0))
uint8_t = reflect.TypeOf(uint8(0))
uint16_t = reflect.TypeOf(uint16(0))
uint32_t = reflect.TypeOf(uint32(0))
uint64_t = reflect.TypeOf(uint64(0))
int_t = reflect.TypeOf(int(0))
int8_t = reflect.TypeOf(int8(0))
int16_t = reflect.TypeOf(int16(0))
int32_t = reflect.TypeOf(int32(0))
int64_t = reflect.TypeOf(int64(0))
hash_t = reflect.TypeOf(common.Hash{})
address_t = reflect.TypeOf(common.Address{})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely these data types are important?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lowercase means private and the package compiles without those lines.

uint_ts = reflect.TypeOf([]uint(nil))
uint8_ts = reflect.TypeOf([]uint8(nil))
uint16_ts = reflect.TypeOf([]uint16(nil))
uint32_ts = reflect.TypeOf([]uint32(nil))
uint64_ts = reflect.TypeOf([]uint64(nil))
ubig_ts = reflect.TypeOf([]*big.Int(nil))

int_ts = reflect.TypeOf([]int(nil))
int8_ts = reflect.TypeOf([]int8(nil))
int16_ts = reflect.TypeOf([]int16(nil))
int32_ts = reflect.TypeOf([]int32(nil))
int64_ts = reflect.TypeOf([]int64(nil))
big_ts = reflect.TypeOf([]*big.Int(nil))
)

// U256 converts a big Int into a 256bit EVM number.
Expand Down
4 changes: 2 additions & 2 deletions accounts/accounts_test.go
Expand Up @@ -48,7 +48,7 @@ func TestManager(t *testing.T) {
t.Fatalf("account file has wrong mode: got %o, want %o", stat.Mode(), 0600)
}
if !am.HasAddress(a.Address) {
t.Errorf("HasAccount(%x) should've returned true", a.Address)
t.Errorf("HasAddres(%x) should've returned true", a.Address)
}
if err := am.Update(a, "foo", "bar"); err != nil {
t.Errorf("Update error: %v", err)
Expand All @@ -60,7 +60,7 @@ func TestManager(t *testing.T) {
t.Errorf("account file %s should be gone after DeleteAccount", a.File)
}
if am.HasAddress(a.Address) {
t.Errorf("HasAccount(%x) should've returned true after DeleteAccount", a.Address)
t.Errorf("HasAddress(%x) should've returned true after DeleteAccount", a.Address)
}
}

Expand Down
31 changes: 0 additions & 31 deletions accounts/key.go
Expand Up @@ -17,7 +17,6 @@
package accounts

import (
"bytes"
"crypto/ecdsa"
"encoding/hex"
"encoding/json"
Expand All @@ -26,7 +25,6 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"

"github.com/ethereumproject/go-ethereum/common"
Expand Down Expand Up @@ -91,14 +89,6 @@ type cipherparamsJSON struct {
IV string `json:"iv"`
}

type scryptParamsJSON struct {
N int `json:"n"`
R int `json:"r"`
P int `json:"p"`
DkLen int `json:"dklen"`
Salt string `json:"salt"`
}

func (k *Key) MarshalJSON() (j []byte, err error) {
jStruct := plainKeyJSON{
hex.EncodeToString(k.Address[:]),
Expand Down Expand Up @@ -146,27 +136,6 @@ func newKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key {
return key
}

// NewKeyForDirectICAP generates a key whose address fits into < 155 bits so it can fit
// into the Direct ICAP spec. for simplicity and easier compatibility with other libs, we
// retry until the first byte is 0.
func NewKeyForDirectICAP(rand io.Reader) *Key {
randBytes := make([]byte, 64)
_, err := rand.Read(randBytes)
if err != nil {
panic("key generation: could not read from random source: " + err.Error())
}
reader := bytes.NewReader(randBytes)
privateKeyECDSA, err := ecdsa.GenerateKey(secp256k1.S256(), reader)
if err != nil {
panic("key generation: ecdsa.GenerateKey failed: " + err.Error())
}
key := newKeyFromECDSA(privateKeyECDSA)
if !strings.HasPrefix(key.Address.Hex(), "0x00") {
return NewKeyForDirectICAP(rand)
}
return key
}

func newKey(rand io.Reader) (*Key, error) {
privateKeyECDSA, err := ecdsa.GenerateKey(secp256k1.S256(), rand)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions accounts/key_store_passphrase.go
Expand Up @@ -44,8 +44,6 @@ import (
)

const (
keyHeaderKDF = "scrypt"

// n,r,p = 2^18, 8, 1 uses 256MB memory and approx 1s CPU time on a modern CPU.
StandardScryptN = 1 << 18
StandardScryptP = 1
Expand Down
27 changes: 26 additions & 1 deletion accounts/key_store_test.go
Expand Up @@ -17,9 +17,12 @@
package accounts

import (
"bytes"
"crypto/ecdsa"
"crypto/rand"
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"os"
"reflect"
Expand All @@ -28,6 +31,7 @@ import (

"github.com/ethereumproject/go-ethereum/common"
"github.com/ethereumproject/go-ethereum/crypto"
"github.com/ethereumproject/go-ethereum/crypto/secp256k1"
)

func tmpKeyStore(t *testing.T, encrypted bool) (dir string, ks keyStore) {
Expand Down Expand Up @@ -234,8 +238,29 @@ func loadKeyStoreTestV1(file string, t *testing.T) map[string]KeyStoreTestV1 {

func TestKeyForDirectICAP(t *testing.T) {
t.Parallel()
key := NewKeyForDirectICAP(rand.Reader)
key := newKeyForDirectICAP(rand.Reader)
if !strings.HasPrefix(key.Address.Hex(), "0x00") {
t.Errorf("Expected first address byte to be zero, have: %s", key.Address.Hex())
}
}

// newKeyForDirectICAP generates a key whose address fits into < 155 bits so it can fit
// into the Direct ICAP spec. for simplicity and easier compatibility with other libs, we
// retry until the first byte is 0.
func newKeyForDirectICAP(rand io.Reader) *Key {
randBytes := make([]byte, 64)
_, err := rand.Read(randBytes)
if err != nil {
panic("key generation: could not read from random source: " + err.Error())
}
reader := bytes.NewReader(randBytes)
privateKeyECDSA, err := ecdsa.GenerateKey(secp256k1.S256(), reader)
if err != nil {
panic("key generation: ecdsa.GenerateKey failed: " + err.Error())
}
key := newKeyFromECDSA(privateKeyECDSA)
if !strings.HasPrefix(key.Address.Hex(), "0x00") {
return newKeyForDirectICAP(rand)
}
return key
}
7 changes: 0 additions & 7 deletions cmd/geth/chaincmd.go
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/ethereumproject/go-ethereum/core"
"github.com/ethereumproject/go-ethereum/core/state"
"github.com/ethereumproject/go-ethereum/core/types"
"github.com/ethereumproject/go-ethereum/ethdb"
"github.com/ethereumproject/go-ethereum/logger/glog"
"gopkg.in/urfave/cli.v1"
)
Expand Down Expand Up @@ -199,9 +198,3 @@ func hashish(x string) bool {
_, err := strconv.Atoi(x)
return err != nil
}

func closeAll(dbs ...ethdb.Database) {
for _, db := range dbs {
db.Close()
}
}
24 changes: 12 additions & 12 deletions cmd/utils/bootnodes.go
Expand Up @@ -23,18 +23,18 @@ import "github.com/ethereumproject/go-ethereum/p2p/discover"
var HomesteadBootNodes = []*discover.Node{
// ETC Volunteer Go Bootnodes
// EPROJECT Upgrade by supplying a default list, parsing oracle & random selection
discover.MustParseNode("enode://08c7ee6a4f861ff0664a49532bcc86de1363acd608999d1b76609bb9bc278649906f069057630fd9493924a368b5d1dc9b8f8bf13ac26df72512f6d1fabd8c95@45.32.7.81:30303"), //dan-
discover.MustParseNode("enode://e809c4a2fec7daed400e5e28564e23693b23b2cc5a019b612505631bbe7b9ccf709c1796d2a3d29ef2b045f210caf51e3c4f5b6d3587d43ad5d6397526fa6179@174.112.32.157:30303"), //bar-
discover.MustParseNode("enode://687be94c3a7beaa3d2fde82fa5046cdeb3e8198354e05b29d6e0d4e276713e3707ac10f784a7904938b06b46c764875c241b0337dd853385a4d8bfcbf8190647@95.183.51.229:30303"), //tre-
discover.MustParseNode("enode://6e538e7c1280f0a31ff08b382db5302480f775480b8e68f8febca0ceff81e4b19153c6f8bf60313b93bef2cc34d34e1df41317de0ce613a201d1660a788a03e2@52.206.67.235:30303"), //ela-
discover.MustParseNode("enode://ca5ae4eca09ba6787e29cf6d86f7634d07aae6b9e6317a59aff675851c0bf445068173208cf8ef7f5cd783d8e29b85b2fa3fa358124cf0546823149724f9bde1@138.68.1.16:30303"), //ige-
discover.MustParseNode("enode://217ebe27e89bf4fec8ce06509323ff095b1014378deb75ab2e5f6759a4e8750a3bd8254b8c6833136e4d5e58230d65ee8ab34a5db5abf0640408c4288af3c8a7@188.138.1.237:30303"), //lec-
discover.MustParseNode("enode://fa20444ef991596ce99b81652ac4e61de1eddc4ff21d3cd42762abd7ed47e7cf044d3c9ccddaf6035d39725e4eb372806787829ccb9a08ec7cb71883cb8c3abd@50.149.116.182:30303"), //Vla-
discover.MustParseNode("enode://4bd6a4df3612c718333eb5ea7f817923a8cdf1bed89cee70d1710b45a0b6b77b2819846440555e451a9b602ad2efa2d2facd4620650249d8468008946887820a@71.178.232.20:30304"), //NoM-
discover.MustParseNode("enode://921cf8e4c345fe8db913c53964f9cadc667644e7f20195a0b7d877bd689a5934e146ff2c2259f1bae6817b6585153a007ceb67d260b720fa3e6fc4350df25c7f@51.255.49.170:30303"), //jai-
discover.MustParseNode("enode://ffea3b01c000cdd89e1e9229fea3e80e95b646f9b2aa55071fc865e2f19543c9b06045cc2e69453e6b78100a119e66be1b5ad50b36f2ffd27293caa28efdd1b2@128.199.93.177:3030"), //pys-
discover.MustParseNode("enode://ee3da491ce6a155eb132708eb0e8d04b0637926ec0ae1b79e63fc97cb9fc3818f49250a0ae0d7f79ed62b66ec677f408c4e01741504dc7a051e274f1e803d454@91.121.65.179:40404"), //mso-
discover.MustParseNode("enode://48e063a6cf5f335b1ef2ed98126bf522cf254396f850c7d442fe2edbbc23398787e14cd4de7968a00175a82762de9cbe9e1407d8ccbcaeca5004d65f8398d759@159.203.255.59:30303"), //mik-
discover.MustParseNode("enode://08c7ee6a4f861ff0664a49532bcc86de1363acd608999d1b76609bb9bc278649906f069057630fd9493924a368b5d1dc9b8f8bf13ac26df72512f6d1fabd8c95@45.32.7.81:30303"), //dan-
discover.MustParseNode("enode://e809c4a2fec7daed400e5e28564e23693b23b2cc5a019b612505631bbe7b9ccf709c1796d2a3d29ef2b045f210caf51e3c4f5b6d3587d43ad5d6397526fa6179@174.112.32.157:30303"), //bar-
discover.MustParseNode("enode://687be94c3a7beaa3d2fde82fa5046cdeb3e8198354e05b29d6e0d4e276713e3707ac10f784a7904938b06b46c764875c241b0337dd853385a4d8bfcbf8190647@95.183.51.229:30303"), //tre-
discover.MustParseNode("enode://6e538e7c1280f0a31ff08b382db5302480f775480b8e68f8febca0ceff81e4b19153c6f8bf60313b93bef2cc34d34e1df41317de0ce613a201d1660a788a03e2@52.206.67.235:30303"), //ela-
discover.MustParseNode("enode://ca5ae4eca09ba6787e29cf6d86f7634d07aae6b9e6317a59aff675851c0bf445068173208cf8ef7f5cd783d8e29b85b2fa3fa358124cf0546823149724f9bde1@138.68.1.16:30303"), //ige-
discover.MustParseNode("enode://217ebe27e89bf4fec8ce06509323ff095b1014378deb75ab2e5f6759a4e8750a3bd8254b8c6833136e4d5e58230d65ee8ab34a5db5abf0640408c4288af3c8a7@188.138.1.237:30303"), //lec-
discover.MustParseNode("enode://fa20444ef991596ce99b81652ac4e61de1eddc4ff21d3cd42762abd7ed47e7cf044d3c9ccddaf6035d39725e4eb372806787829ccb9a08ec7cb71883cb8c3abd@50.149.116.182:30303"), //Vla-
discover.MustParseNode("enode://4bd6a4df3612c718333eb5ea7f817923a8cdf1bed89cee70d1710b45a0b6b77b2819846440555e451a9b602ad2efa2d2facd4620650249d8468008946887820a@71.178.232.20:30304"), //NoM-
discover.MustParseNode("enode://921cf8e4c345fe8db913c53964f9cadc667644e7f20195a0b7d877bd689a5934e146ff2c2259f1bae6817b6585153a007ceb67d260b720fa3e6fc4350df25c7f@51.255.49.170:30303"), //jai-
discover.MustParseNode("enode://ffea3b01c000cdd89e1e9229fea3e80e95b646f9b2aa55071fc865e2f19543c9b06045cc2e69453e6b78100a119e66be1b5ad50b36f2ffd27293caa28efdd1b2@128.199.93.177:3030"), //pys-
discover.MustParseNode("enode://ee3da491ce6a155eb132708eb0e8d04b0637926ec0ae1b79e63fc97cb9fc3818f49250a0ae0d7f79ed62b66ec677f408c4e01741504dc7a051e274f1e803d454@91.121.65.179:40404"), //mso-
discover.MustParseNode("enode://48e063a6cf5f335b1ef2ed98126bf522cf254396f850c7d442fe2edbbc23398787e14cd4de7968a00175a82762de9cbe9e1407d8ccbcaeca5004d65f8398d759@159.203.255.59:30303"), //mik-
discover.MustParseNode("enode://42d8f29d1db5f4b2947cd5c3d76c6d0d3697e6b9b3430c3d41e46b4bb77655433aeedc25d4b4ea9d8214b6a43008ba67199374a9b53633301bca0cd20c6928ab@104.155.176.151:30303"), //boot.gastracker.io

// Pending & Not Resolving
Expand Down
24 changes: 0 additions & 24 deletions cmd/utils/cmd.go
Expand Up @@ -22,10 +22,8 @@ import (
"io"
"os"
"os/signal"
"regexp"
"runtime"

"github.com/ethereumproject/go-ethereum/common"
"github.com/ethereumproject/go-ethereum/core"
"github.com/ethereumproject/go-ethereum/core/types"
"github.com/ethereumproject/go-ethereum/internal/debug"
Expand All @@ -39,15 +37,6 @@ const (
importBatchSize = 2500
)

func openLogFile(Datadir string, filename string) *os.File {
path := common.AbsolutePath(Datadir, filename)
file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
panic(fmt.Sprintf("error opening log file '%s': %v", filename, err))
}
return file
}

// Fatalf formats a message to standard error and exits the program.
// The message is also printed to standard output if standard error
// is redirected to a different file.
Expand Down Expand Up @@ -91,19 +80,6 @@ func StartNode(stack *node.Node) {
}()
}

func FormatTransactionData(data string) []byte {
d := common.StringToByteFunc(data, func(s string) (ret []byte) {
slice := regexp.MustCompile("\\n|\\s").Split(s, 1000000000)
for _, dataItem := range slice {
d := common.FormatData(dataItem)
ret = append(ret, d...)
}
return
})

return d
}

func ImportChain(chain *core.BlockChain, fn string) error {
// Watch for Ctrl-C while the import is running.
// If a signal is received, the import will stop at the next batch.
Expand Down
4 changes: 0 additions & 4 deletions cmd/utils/customflags.go
Expand Up @@ -122,10 +122,6 @@ func withEnvHint(envVar, str string) string {
return str + envText
}

func (self DirectoryFlag) getName() string {
return self.Name
}

func (self *DirectoryFlag) Set(value string) {
self.Value.Value = value
}
Expand Down
7 changes: 0 additions & 7 deletions common/big.go
Expand Up @@ -126,13 +126,6 @@ func BigToBytes(num *big.Int, base int) []byte {
return append(ret[:len(ret)-len(num.Bytes())], num.Bytes()...)
}

// Big copy
//
// Creates a copy of the given big integer
func BigCopy(src *big.Int) *big.Int {
return new(big.Int).Set(src)
}

// Big max
//
// Returns the maximum size big integer
Expand Down
19 changes: 0 additions & 19 deletions common/big_test.go
Expand Up @@ -17,7 +17,6 @@
package common

import (
"bytes"
"testing"
)

Expand Down Expand Up @@ -69,21 +68,3 @@ func TestBigMin(t *testing.T) {
t.Errorf("Expected %d got %d", b, min2)
}
}

func TestBigCopy(t *testing.T) {
a := Big("10")
b := BigCopy(a)
c := Big("1000000000000")
y := BigToBytes(b, 16)
ybytes := []byte{0, 10}
z := BigToBytes(c, 16)
zbytes := []byte{232, 212, 165, 16, 0}

if bytes.Compare(y, ybytes) != 0 {
t.Error("Got", ybytes)
}

if bytes.Compare(z, zbytes) != 0 {
t.Error("Got", zbytes)
}
}