From 5fb4aef1cc6866655641ba28c96ddfef7fff2e87 Mon Sep 17 00:00:00 2001 From: Victor Farazdagi Date: Thu, 8 Sep 2016 12:45:12 +0300 Subject: [PATCH 1/3] Initial refactoring + vendor update (after rebase) --- {src => common}/types.go | 2 +- common/utils.go | 26 + {src/extkeys => extkeys}/hdkey.go | 0 {src/extkeys => extkeys}/hdkey_test.go | 12 +- {src/extkeys => extkeys}/mnemonic.go | 7 +- {src/extkeys => extkeys}/mnemonic_test.go | 13 +- .../extkeys => extkeys}/mnemonic_vectors.json | 0 {src/extkeys => extkeys}/utils.go | 0 src/main.go | 167 +--- src/node.go | 162 ++++ .../accounts/abi/bind/backends/remote.go | 260 ------ .../ethereum/go-ethereum/cmd/utils/client.go | 55 -- .../go-ethereum/common/compiler/solidity.go | 225 ----- .../go-ethereum/eth/downloader/api.go | 108 --- .../ethereum/go-ethereum/eth/filters/api.go | 655 --------------- .../go-ethereum/eth/filters/filter_system.go | 185 ----- .../ethereum/go-ethereum/rpc/http.go | 142 ---- .../ethereum/go-ethereum/rpc/inproc.go | 61 -- .../ethereum/go-ethereum/rpc/ipc.go | 84 -- .../ethereum/go-ethereum/rpc/notification.go | 297 ------- .../ethereum/go-ethereum/rpc/websocket.go | 182 ---- .../Gustav-Simonsson/go-opencl/cl/cl.go | 0 .../Gustav-Simonsson/go-opencl/cl/context.go | 0 .../Gustav-Simonsson/go-opencl/cl/device.go | 0 .../Gustav-Simonsson/go-opencl/cl/device12.go | 0 .../Gustav-Simonsson/go-opencl/cl/image.go | 0 .../Gustav-Simonsson/go-opencl/cl/kernel.go | 0 .../Gustav-Simonsson/go-opencl/cl/kernel10.go | 0 .../Gustav-Simonsson/go-opencl/cl/kernel12.go | 0 .../Gustav-Simonsson/go-opencl/cl/platform.go | 0 .../Gustav-Simonsson/go-opencl/cl/program.go | 0 .../Gustav-Simonsson/go-opencl/cl/queue.go | 0 .../Gustav-Simonsson/go-opencl/cl/types.go | 0 .../Gustav-Simonsson/go-opencl/cl/types12.go | 0 .../go-opencl/cl/types_darwin.go | 0 .../aristanetworks/goarista/COPYING | 0 .../goarista/atime/issue15006.s | 0 .../aristanetworks/goarista/atime/nanotime.go | 0 .../github.com/btcsuite/btcd/LICENSE | 0 .../github.com/btcsuite/btcd/btcec/README.md | 0 .../github.com/btcsuite/btcd/btcec/btcec.go | 0 .../btcsuite/btcd/btcec/ciphering.go | 0 .../github.com/btcsuite/btcd/btcec/doc.go | 0 .../github.com/btcsuite/btcd/btcec/field.go | 0 .../btcsuite/btcd/btcec/genprecomps.go | 0 .../btcsuite/btcd/btcec/gensecp256k1.go | 0 .../btcsuite/btcd/btcec/precompute.go | 0 .../github.com/btcsuite/btcd/btcec/privkey.go | 0 .../github.com/btcsuite/btcd/btcec/pubkey.go | 0 .../btcsuite/btcd/btcec/secp256k1.go | 0 .../btcsuite/btcd/btcec/signature.go | 0 .../btcsuite/btcd/chaincfg/README.md | 0 .../btcd/chaincfg/chainhash/README.md | 0 .../btcsuite/btcd/chaincfg/chainhash/doc.go | 0 .../btcsuite/btcd/chaincfg/chainhash/hash.go | 0 .../btcd/chaincfg/chainhash/hashfuncs.go | 0 .../github.com/btcsuite/btcd/chaincfg/doc.go | 0 .../btcsuite/btcd/chaincfg/genesis.go | 0 .../btcsuite/btcd/chaincfg/params.go | 0 .../github.com/btcsuite/btcd/wire/README.md | 0 .../btcsuite/btcd/wire/blockheader.go | 0 .../github.com/btcsuite/btcd/wire/common.go | 0 .../github.com/btcsuite/btcd/wire/doc.go | 0 .../github.com/btcsuite/btcd/wire/error.go | 0 .../github.com/btcsuite/btcd/wire/invvect.go | 0 .../github.com/btcsuite/btcd/wire/message.go | 0 .../github.com/btcsuite/btcd/wire/msgaddr.go | 0 .../github.com/btcsuite/btcd/wire/msgalert.go | 0 .../github.com/btcsuite/btcd/wire/msgblock.go | 0 .../btcsuite/btcd/wire/msgfilteradd.go | 0 .../btcsuite/btcd/wire/msgfilterclear.go | 0 .../btcsuite/btcd/wire/msgfilterload.go | 0 .../btcsuite/btcd/wire/msggetaddr.go | 0 .../btcsuite/btcd/wire/msggetblocks.go | 0 .../btcsuite/btcd/wire/msggetdata.go | 0 .../btcsuite/btcd/wire/msggetheaders.go | 0 .../btcsuite/btcd/wire/msgheaders.go | 0 .../github.com/btcsuite/btcd/wire/msginv.go | 0 .../btcsuite/btcd/wire/msgmempool.go | 0 .../btcsuite/btcd/wire/msgmerkleblock.go | 0 .../btcsuite/btcd/wire/msgnotfound.go | 0 .../github.com/btcsuite/btcd/wire/msgping.go | 0 .../github.com/btcsuite/btcd/wire/msgpong.go | 0 .../btcsuite/btcd/wire/msgreject.go | 0 .../btcsuite/btcd/wire/msgsendheaders.go | 0 .../github.com/btcsuite/btcd/wire/msgtx.go | 0 .../btcsuite/btcd/wire/msgverack.go | 0 .../btcsuite/btcd/wire/msgversion.go | 0 .../btcsuite/btcd/wire/netaddress.go | 0 .../github.com/btcsuite/btcd/wire/protocol.go | 0 .../github.com/btcsuite/btcutil/LICENSE | 0 .../github.com/btcsuite/btcutil/README.md | 0 .../github.com/btcsuite/btcutil/address.go | 0 .../github.com/btcsuite/btcutil/amount.go | 0 .../github.com/btcsuite/btcutil/appdata.go | 0 .../btcsuite/btcutil/base58/README.md | 0 .../btcsuite/btcutil/base58/alphabet.go | 0 .../btcsuite/btcutil/base58/base58.go | 0 .../btcsuite/btcutil/base58/base58check.go | 0 .../btcsuite/btcutil/base58/cov_report.sh | 0 .../github.com/btcsuite/btcutil/base58/doc.go | 0 .../btcsuite/btcutil/base58/genalphabet.go | 0 .../github.com/btcsuite/btcutil/block.go | 0 .../github.com/btcsuite/btcutil/certgen.go | 0 .../github.com/btcsuite/btcutil/const.go | 0 .../github.com/btcsuite/btcutil/cov_report.sh | 0 .../github.com/btcsuite/btcutil/doc.go | 0 .../github.com/btcsuite/btcutil/goclean.sh | 0 .../github.com/btcsuite/btcutil/hash160.go | 0 .../btcsuite/btcutil/hdkeychain/README.md | 0 .../btcsuite/btcutil/hdkeychain/cov_report.sh | 0 .../btcsuite/btcutil/hdkeychain/doc.go | 0 .../btcutil/hdkeychain/extendedkey.go | 0 .../btcutil/hdkeychain/test_coverage.txt | 0 .../github.com/btcsuite/btcutil/net.go | 0 .../github.com/btcsuite/btcutil/net_noop.go | 0 .../btcsuite/btcutil/test_coverage.txt | 0 .../github.com/btcsuite/btcutil/tx.go | 0 .../github.com/btcsuite/btcutil/wif.go | 0 .../github.com/btcsuite/fastsha256/LICENSE.md | 0 .../github.com/btcsuite/fastsha256/sha256.go | 0 .../btcsuite/fastsha256/sha256block.go | 0 .../btcsuite/fastsha256/sha256block_386.s | 0 .../btcsuite/fastsha256/sha256block_amd64.s | 0 .../btcsuite/fastsha256/sha256block_decl.go | 0 .../github.com/btcsuite/golangcrypto/LICENSE | 0 .../github.com/btcsuite/golangcrypto/PATENTS | 0 .../golangcrypto/ripemd160/ripemd160.go | 0 .../golangcrypto/ripemd160/ripemd160block.go | 0 .../github.com/ethereum/ethash/.gitignore | 0 .../github.com/ethereum/ethash/.travis.yml | 0 .../github.com/ethereum/ethash/CMakeLists.txt | 0 .../github.com/ethereum/ethash/MANIFEST.in | 0 .../github.com/ethereum/ethash/Makefile | 0 .../github.com/ethereum/ethash/README.md | 0 .../github.com/ethereum/ethash/Vagrantfile | 0 .../github.com/ethereum/ethash/appveyor.yml | 0 .../github.com/ethereum/ethash/ethash.go | 0 .../ethereum/ethash/ethash_opencl.go | 0 .../ethash/ethash_opencl_kernel_go_str.go | 0 .../github.com/ethereum/ethash/ethashc.go | 0 .../github.com/ethereum/ethash/setup.py | 0 .../ethash/src/benchmark/CMakeLists.txt | 0 .../ethash/src/benchmark/benchmark.cpp | 0 .../ethash/src/libethash/CMakeLists.txt | 0 .../ethereum/ethash/src/libethash/compiler.h | 0 .../ethash/src/libethash/data_sizes.h | 0 .../ethereum/ethash/src/libethash/endian.h | 0 .../ethereum/ethash/src/libethash/ethash.h | 0 .../ethereum/ethash/src/libethash/fnv.h | 0 .../ethereum/ethash/src/libethash/internal.c | 0 .../ethereum/ethash/src/libethash/internal.h | 0 .../ethereum/ethash/src/libethash/io.c | 0 .../ethereum/ethash/src/libethash/io.h | 0 .../ethereum/ethash/src/libethash/io_posix.c | 0 .../ethereum/ethash/src/libethash/io_win32.c | 0 .../ethereum/ethash/src/libethash/mmap.h | 0 .../ethash/src/libethash/mmap_win32.c | 0 .../ethereum/ethash/src/libethash/sha3.c | 0 .../ethereum/ethash/src/libethash/sha3.h | 0 .../ethash/src/libethash/sha3_cryptopp.cpp | 0 .../ethash/src/libethash/sha3_cryptopp.h | 0 .../ethereum/ethash/src/libethash/util.h | 0 .../ethash/src/libethash/util_win32.c | 0 .../ethereum/ethash/src/python/core.c | 0 .../github.com/ethereum/go-ethereum/COPYING | 0 .../ethereum/go-ethereum/COPYING.LESSER | 0 .../ethereum/go-ethereum/accounts/abi/abi.go | 0 .../go-ethereum/accounts/abi/argument.go | 0 .../go-ethereum/accounts/abi/bind/auth.go | 0 .../go-ethereum/accounts/abi/bind/backend.go | 0 .../accounts/abi/bind/backends/nil.go | 0 .../accounts/abi/bind/backends/remote.go | 136 +++ .../accounts/abi/bind/backends/simulated.go | 0 .../go-ethereum/accounts/abi/bind/base.go | 0 .../go-ethereum/accounts/abi/bind/bind.go | 0 .../go-ethereum/accounts/abi/bind/template.go | 0 .../ethereum/go-ethereum/accounts/abi/doc.go | 0 .../go-ethereum/accounts/abi/error.go | 0 .../go-ethereum/accounts/abi/event.go | 0 .../go-ethereum/accounts/abi/method.go | 0 .../go-ethereum/accounts/abi/numbers.go | 0 .../go-ethereum/accounts/abi/packing.go | 0 .../go-ethereum/accounts/abi/reflect.go | 0 .../ethereum/go-ethereum/accounts/abi/type.go | 0 .../go-ethereum/accounts/account_manager.go | 68 +- .../go-ethereum/accounts/addrcache.go | 0 .../ethereum/go-ethereum/accounts/key.go | 0 .../accounts/key_store_passphrase.go | 0 .../go-ethereum/accounts/key_store_plain.go | 0 .../ethereum/go-ethereum/accounts/presale.go | 0 .../ethereum/go-ethereum/accounts/watch.go | 0 .../go-ethereum/accounts/watch_fallback.go | 0 .../ethereum/go-ethereum/cmd/abigen/main.go | 13 +- .../ethereum/go-ethereum/cmd/bootnode/main.go | 28 +- .../ethereum/go-ethereum/cmd/disasm/main.go | 0 .../ethereum/go-ethereum/cmd/evm/code.txt | 0 .../ethereum/go-ethereum/cmd/evm/input.txt | 0 .../ethereum/go-ethereum/cmd/evm/main.go | 0 .../go-ethereum/cmd/geth/accountcmd.go | 30 +- .../ethereum/go-ethereum/cmd/geth/chaincmd.go | 0 .../go-ethereum/cmd/geth/consolecmd.go | 28 +- .../go-ethereum/cmd/geth/info_test.json | 0 .../ethereum/go-ethereum/cmd/geth/library.c | 0 .../ethereum/go-ethereum/cmd/geth/library.go | 0 .../go-ethereum/cmd/geth/library_android.go | 0 .../ethereum/go-ethereum/cmd/geth/main.go | 117 +-- .../go-ethereum/cmd/geth/monitorcmd.go | 39 +- .../ethereum/go-ethereum/cmd/geth/usage.go | 0 .../go-ethereum/cmd/gethrpctest/main.go | 32 +- .../ethereum/go-ethereum/cmd/rlpdump/main.go | 0 .../go-ethereum/cmd/utils/bootnodes.go | 0 .../ethereum/go-ethereum/cmd/utils/cmd.go | 0 .../go-ethereum/cmd/utils/customflags.go | 0 .../go-ethereum/cmd/utils/fdlimit_freebsd.go | 0 .../go-ethereum/cmd/utils/fdlimit_unix.go | 0 .../go-ethereum/cmd/utils/fdlimit_windows.go | 0 .../ethereum/go-ethereum/cmd/utils/flags.go | 188 ++--- .../ethereum/go-ethereum/common/big.go | 0 .../ethereum/go-ethereum/common/bytes.go | 0 .../go-ethereum/common/compiler/solidity.go | 196 +++++ .../ethereum/go-ethereum/common/debug.go | 0 .../ethereum/go-ethereum/common/defaults.go | 0 .../common/httpclient/httpclient.go | 0 .../ethereum/go-ethereum/common/icap.go | 0 .../ethereum/go-ethereum/common/list.go | 0 .../ethereum/go-ethereum/common/math/dist.go | 0 .../go-ethereum/common/mclock/mclock.go | 0 .../go-ethereum/common/natspec/natspec.go | 0 .../go-ethereum/common/natspec/natspec_js.go | 0 .../ethereum/go-ethereum/common/number/int.go | 0 .../ethereum/go-ethereum/common/path.go | 0 .../go-ethereum/common/registrar/contracts.go | 0 .../common/registrar/ethreg/api.go | 0 .../go-ethereum/common/registrar/registrar.go | 0 .../ethereum/go-ethereum/common/size.go | 0 .../ethereum/go-ethereum/common/test_utils.go | 0 .../ethereum/go-ethereum/common/types.go | 0 .../go-ethereum/common/types_template.go | 0 .../go-ethereum/compression/rle/read_write.go | 0 .../ethereum/go-ethereum/console/bridge.go | 175 ++-- .../ethereum/go-ethereum/console/console.go | 0 .../ethereum/go-ethereum/console/prompter.go | 0 .../ethereum/go-ethereum/core/asm.go | 0 .../go-ethereum/core/block_validator.go | 0 .../ethereum/go-ethereum/core/blockchain.go | 18 +- .../ethereum/go-ethereum/core/blocks.go | 0 .../ethereum/go-ethereum/core/chain_makers.go | 0 .../ethereum/go-ethereum/core/chain_pow.go | 0 .../ethereum/go-ethereum/core/config.go | 0 .../ethereum/go-ethereum/core/dao.go | 0 .../go-ethereum/core/database_util.go | 6 +- .../go-ethereum/core/default_genesis.go | 0 .../ethereum/go-ethereum/core/error.go | 0 .../ethereum/go-ethereum/core/events.go | 0 .../ethereum/go-ethereum/core/execution.go | 0 .../ethereum/go-ethereum/core/fees.go | 0 .../ethereum/go-ethereum/core/gaspool.go | 0 .../ethereum/go-ethereum/core/genesis.go | 0 .../ethereum/go-ethereum/core/headerchain.go | 18 +- .../ethereum/go-ethereum/core/state/dump.go | 0 .../go-ethereum/core/state/iterator.go | 0 .../go-ethereum/core/state/managed_state.go | 0 .../go-ethereum/core/state/state_object.go | 0 .../go-ethereum/core/state/statedb.go | 0 .../ethereum/go-ethereum/core/state/sync.go | 0 .../go-ethereum/core/state_processor.go | 0 .../go-ethereum/core/state_transition.go | 0 .../ethereum/go-ethereum/core/tx_pool.go | 0 .../ethereum/go-ethereum/core/types.go | 16 - .../ethereum/go-ethereum/core/types/block.go | 22 + .../ethereum/go-ethereum/core/types/bloom9.go | 0 .../go-ethereum/core/types/derive_sha.go | 0 .../go-ethereum/core/types/receipt.go | 0 .../go-ethereum/core/types/transaction.go | 0 .../ethereum/go-ethereum/core/vm/analysis.go | 0 .../ethereum/go-ethereum/core/vm/asm.go | 0 .../ethereum/go-ethereum/core/vm/common.go | 0 .../ethereum/go-ethereum/core/vm/contract.go | 0 .../ethereum/go-ethereum/core/vm/contracts.go | 4 +- .../ethereum/go-ethereum/core/vm/disasm.go | 0 .../ethereum/go-ethereum/core/vm/doc.go | 0 .../go-ethereum/core/vm/environment.go | 0 .../ethereum/go-ethereum/core/vm/errors.go | 0 .../ethereum/go-ethereum/core/vm/gas.go | 0 .../go-ethereum/core/vm/instructions.go | 0 .../ethereum/go-ethereum/core/vm/jit.go | 0 .../go-ethereum/core/vm/jit_optimiser.go | 0 .../ethereum/go-ethereum/core/vm/jit_util.go | 0 .../go-ethereum/core/vm/jump_table.go | 0 .../ethereum/go-ethereum/core/vm/log.go | 0 .../ethereum/go-ethereum/core/vm/logger.go | 0 .../ethereum/go-ethereum/core/vm/memory.go | 0 .../ethereum/go-ethereum/core/vm/opcodes.go | 0 .../go-ethereum/core/vm/runtime/doc.go | 0 .../go-ethereum/core/vm/runtime/env.go | 0 .../go-ethereum/core/vm/runtime/runtime.go | 0 .../ethereum/go-ethereum/core/vm/segments.go | 0 .../ethereum/go-ethereum/core/vm/stack.go | 0 .../go-ethereum/core/vm/virtual_machine.go | 0 .../ethereum/go-ethereum/core/vm/vm.go | 0 .../ethereum/go-ethereum/core/vm/vm_jit.go | 0 .../go-ethereum/core/vm/vm_jit_fake.go | 0 .../ethereum/go-ethereum/core/vm_env.go | 0 .../ethereum/go-ethereum/crypto/crypto.go | 0 .../ethereum/go-ethereum/crypto/ecies/LICENSE | 0 .../ethereum/go-ethereum/crypto/ecies/README | 0 .../ethereum/go-ethereum/crypto/ecies/asn1.go | 0 .../go-ethereum/crypto/ecies/ecies.go | 0 .../go-ethereum/crypto/ecies/params.go | 0 .../crypto/randentropy/rand_entropy.go | 0 .../go-ethereum/crypto/secp256k1/curve.go | 0 .../crypto/secp256k1/libsecp256k1/COPYING | 0 .../crypto/secp256k1/libsecp256k1/Makefile.am | 0 .../crypto/secp256k1/libsecp256k1/TODO | 0 .../crypto/secp256k1/libsecp256k1/autogen.sh | 0 .../secp256k1/libsecp256k1/configure.ac | 0 .../libsecp256k1/include/secp256k1.h | 0 .../libsecp256k1/include/secp256k1_ecdh.h | 0 .../libsecp256k1/include/secp256k1_recovery.h | 0 .../libsecp256k1/include/secp256k1_schnorr.h | 0 .../secp256k1/libsecp256k1/libsecp256k1.pc.in | 0 .../secp256k1/libsecp256k1/src/basic-config.h | 0 .../crypto/secp256k1/libsecp256k1/src/bench.h | 0 .../secp256k1/libsecp256k1/src/bench_ecdh.c | 0 .../libsecp256k1/src/bench_internal.c | 0 .../libsecp256k1/src/bench_recover.c | 0 .../libsecp256k1/src/bench_schnorr_verify.c | 0 .../secp256k1/libsecp256k1/src/bench_sign.c | 0 .../secp256k1/libsecp256k1/src/bench_verify.c | 0 .../crypto/secp256k1/libsecp256k1/src/ecdsa.h | 0 .../secp256k1/libsecp256k1/src/ecdsa_impl.h | 0 .../crypto/secp256k1/libsecp256k1/src/eckey.h | 0 .../secp256k1/libsecp256k1/src/eckey_impl.h | 0 .../secp256k1/libsecp256k1/src/ecmult.h | 0 .../secp256k1/libsecp256k1/src/ecmult_const.h | 0 .../libsecp256k1/src/ecmult_const_impl.h | 0 .../secp256k1/libsecp256k1/src/ecmult_gen.h | 0 .../libsecp256k1/src/ecmult_gen_impl.h | 0 .../secp256k1/libsecp256k1/src/ecmult_impl.h | 0 .../crypto/secp256k1/libsecp256k1/src/field.h | 0 .../secp256k1/libsecp256k1/src/field_10x26.h | 0 .../libsecp256k1/src/field_10x26_impl.h | 0 .../secp256k1/libsecp256k1/src/field_5x52.h | 0 .../libsecp256k1/src/field_5x52_asm_impl.h | 0 .../libsecp256k1/src/field_5x52_impl.h | 0 .../libsecp256k1/src/field_5x52_int128_impl.h | 0 .../secp256k1/libsecp256k1/src/field_impl.h | 0 .../secp256k1/libsecp256k1/src/gen_context.c | 0 .../crypto/secp256k1/libsecp256k1/src/group.h | 0 .../secp256k1/libsecp256k1/src/group_impl.h | 0 .../crypto/secp256k1/libsecp256k1/src/hash.h | 0 .../secp256k1/libsecp256k1/src/hash_impl.h | 0 .../src/java/org/bitcoin/NativeSecp256k1.java | 0 .../src/java/org_bitcoin_NativeSecp256k1.c | 0 .../src/java/org_bitcoin_NativeSecp256k1.h | 0 .../src/modules/ecdh/Makefile.am.include | 0 .../libsecp256k1/src/modules/ecdh/main_impl.h | 0 .../src/modules/ecdh/tests_impl.h | 0 .../src/modules/recovery/Makefile.am.include | 0 .../src/modules/recovery/main_impl.h | 0 .../src/modules/recovery/tests_impl.h | 0 .../src/modules/schnorr/Makefile.am.include | 0 .../src/modules/schnorr/main_impl.h | 0 .../src/modules/schnorr/schnorr.h | 0 .../src/modules/schnorr/schnorr_impl.h | 0 .../src/modules/schnorr/tests_impl.h | 0 .../crypto/secp256k1/libsecp256k1/src/num.h | 0 .../secp256k1/libsecp256k1/src/num_gmp.h | 0 .../secp256k1/libsecp256k1/src/num_gmp_impl.h | 0 .../secp256k1/libsecp256k1/src/num_impl.h | 0 .../secp256k1/libsecp256k1/src/scalar.h | 0 .../secp256k1/libsecp256k1/src/scalar_4x64.h | 0 .../libsecp256k1/src/scalar_4x64_impl.h | 0 .../secp256k1/libsecp256k1/src/scalar_8x32.h | 0 .../libsecp256k1/src/scalar_8x32_impl.h | 0 .../secp256k1/libsecp256k1/src/scalar_impl.h | 0 .../secp256k1/libsecp256k1/src/secp256k1.c | 0 .../secp256k1/libsecp256k1/src/testrand.h | 0 .../libsecp256k1/src/testrand_impl.h | 0 .../crypto/secp256k1/libsecp256k1/src/tests.c | 0 .../crypto/secp256k1/libsecp256k1/src/util.h | 0 .../go-ethereum/crypto/secp256k1/notes.go | 0 .../go-ethereum/crypto/secp256k1/panic_cb.go | 0 .../crypto/secp256k1/pubkey_scalar_mul.h | 0 .../go-ethereum/crypto/secp256k1/secp256.go | 0 .../ethereum/go-ethereum/crypto/sha3/LICENSE | 0 .../ethereum/go-ethereum/crypto/sha3/PATENTS | 0 .../ethereum/go-ethereum/crypto/sha3/doc.go | 0 .../go-ethereum/crypto/sha3/hashes.go | 0 .../go-ethereum/crypto/sha3/keccakf.go | 0 .../go-ethereum/crypto/sha3/register.go | 0 .../ethereum/go-ethereum/crypto/sha3/sha3.go | 0 .../ethereum/go-ethereum/crypto/sha3/shake.go | 0 .../ethereum/go-ethereum/crypto/sha3/xor.go | 0 .../go-ethereum/crypto/sha3/xor_generic.go | 0 .../go-ethereum/crypto/sha3/xor_unaligned.go | 0 .../ethereum/go-ethereum/errs/errors.go | 0 .../ethereum/go-ethereum/eth/api.go | 0 .../ethereum/go-ethereum/eth/api_backend.go | 0 .../ethereum/go-ethereum/eth/backend.go | 43 +- .../ethereum/go-ethereum/eth/bad_block.go | 0 .../ethereum/go-ethereum/eth/bind.go | 2 +- .../ethereum/go-ethereum/eth/cpu_mining.go | 0 .../ethereum/go-ethereum/eth/db_upgrade.go | 13 + .../go-ethereum/eth/downloader/api.go | 173 ++++ .../go-ethereum/eth/downloader/downloader.go | 738 +++-------------- .../go-ethereum/eth/downloader/events.go | 0 .../go-ethereum/eth/downloader/metrics.go | 10 - .../go-ethereum/eth/downloader/modes.go | 0 .../go-ethereum/eth/downloader/peer.go | 59 +- .../go-ethereum/eth/downloader/queue.go | 138 +--- .../go-ethereum/eth/downloader/types.go | 20 - .../go-ethereum/eth/fetcher/fetcher.go | 98 +-- .../go-ethereum/eth/fetcher/metrics.go | 3 - .../ethereum/go-ethereum/eth/filters/api.go | 544 ++++++++++++ .../go-ethereum/eth/filters/filter.go | 114 ++- .../go-ethereum/eth/filters/filter_system.go | 318 +++++++ .../go-ethereum/eth/gasprice/gasprice.go | 0 .../go-ethereum/eth/gasprice/lightprice.go | 0 .../ethereum/go-ethereum/eth/gpu_mining.go | 0 .../ethereum/go-ethereum/eth/handler.go | 159 +--- .../ethereum/go-ethereum/eth/metrics.go | 26 +- .../ethereum/go-ethereum/eth/peer.go | 74 +- .../ethereum/go-ethereum/eth/protocol.go | 46 +- .../ethereum/go-ethereum/eth/sync.go | 8 +- .../ethereum/go-ethereum/ethdb/database.go | 2 - .../ethereum/go-ethereum/ethdb/interface.go | 0 .../go-ethereum/ethdb/memory_database.go | 0 .../ethereum/go-ethereum/event/event.go | 0 .../go-ethereum/event/filter/filter.go | 0 .../event/filter/generic_filter.go | 0 .../go-ethereum/generators/defaults.go | 0 .../go-ethereum/internal/debug/api.go | 0 .../go-ethereum/internal/debug/flags.go | 0 .../go-ethereum/internal/debug/loudpanic.go | 0 .../internal/debug/loudpanic_fallback.go | 0 .../go-ethereum/internal/debug/trace.go | 0 .../internal/debug/trace_fallback.go | 0 .../go-ethereum/internal/ethapi/api.go | 206 +---- .../go-ethereum/internal/ethapi/backend.go | 13 +- .../go-ethereum/internal/ethapi/solc.go | 82 ++ .../internal/ethapi/status_backend.go | 2 +- .../go-ethereum/internal/jsre/bignumber_js.go | 0 .../go-ethereum/internal/jsre/completion.go | 0 .../go-ethereum/internal/jsre/ethereum_js.go | 10 +- .../go-ethereum/internal/jsre/jsre.go | 0 .../go-ethereum/internal/jsre/pretty.go | 2 +- .../go-ethereum/internal/web3ext/web3ext.go | 9 +- .../ethereum/go-ethereum/les/api_backend.go | 0 .../ethereum/go-ethereum/les/backend.go | 9 +- .../ethereum/go-ethereum/les/fetcher.go | 0 .../go-ethereum/les/flowcontrol/control.go | 0 .../go-ethereum/les/flowcontrol/manager.go | 0 .../ethereum/go-ethereum/les/handler.go | 11 +- .../ethereum/go-ethereum/les/metrics.go | 0 .../ethereum/go-ethereum/les/odr.go | 0 .../ethereum/go-ethereum/les/odr_peerset.go | 0 .../ethereum/go-ethereum/les/odr_requests.go | 0 .../ethereum/go-ethereum/les/peer.go | 25 +- .../ethereum/go-ethereum/les/protocol.go | 0 .../ethereum/go-ethereum/les/server.go | 0 .../go-ethereum/les/status/txqueue.go | 0 .../ethereum/go-ethereum/les/sync.go | 0 .../ethereum/go-ethereum/les/txrelay.go | 0 .../ethereum/go-ethereum/light/lightchain.go | 15 +- .../ethereum/go-ethereum/light/odr.go | 0 .../ethereum/go-ethereum/light/odr_util.go | 0 .../ethereum/go-ethereum/light/state.go | 0 .../go-ethereum/light/state_object.go | 0 .../ethereum/go-ethereum/light/trie.go | 0 .../ethereum/go-ethereum/light/txpool.go | 0 .../ethereum/go-ethereum/light/vm_env.go | 0 .../ethereum/go-ethereum/logger/glog/LICENSE | 0 .../ethereum/go-ethereum/logger/glog/README | 0 .../ethereum/go-ethereum/logger/glog/glog.go | 0 .../go-ethereum/logger/glog/glog_file.go | 0 .../ethereum/go-ethereum/logger/log.go | 0 .../ethereum/go-ethereum/logger/loggers.go | 0 .../ethereum/go-ethereum/logger/logsystem.go | 0 .../ethereum/go-ethereum/logger/sys.go | 0 .../ethereum/go-ethereum/logger/types.go | 0 .../ethereum/go-ethereum/logger/verbosity.go | 0 .../ethereum/go-ethereum/metrics/disk.go | 0 .../go-ethereum/metrics/disk_linux.go | 0 .../ethereum/go-ethereum/metrics/disk_nop.go | 0 .../ethereum/go-ethereum/metrics/metrics.go | 0 .../ethereum/go-ethereum/miner/agent.go | 0 .../ethereum/go-ethereum/miner/miner.go | 23 +- .../go-ethereum/miner/remote_agent.go | 0 .../ethereum/go-ethereum/miner/worker.go | 8 +- .../ethereum/go-ethereum/node/api.go | 16 + .../ethereum/go-ethereum/node/config.go | 58 +- .../ethereum/go-ethereum/node/errors.go | 0 .../ethereum/go-ethereum/node/node.go | 40 +- .../ethereum/go-ethereum/node/service.go | 8 +- .../ethereum/go-ethereum/p2p/dial.go | 5 + .../go-ethereum/p2p/discover/database.go | 0 .../ethereum/go-ethereum/p2p/discover/node.go | 0 .../ethereum/go-ethereum/p2p/discover/ntp.go | 0 .../go-ethereum/p2p/discover/table.go | 0 .../ethereum/go-ethereum/p2p/discover/udp.go | 0 .../p2p/discover/udp_notwindows.go | 0 .../go-ethereum/p2p/discover/udp_windows.go | 0 .../ethereum/go-ethereum/p2p/message.go | 0 .../ethereum/go-ethereum/p2p/metrics.go | 0 .../ethereum/go-ethereum/p2p/nat/nat.go | 0 .../ethereum/go-ethereum/p2p/nat/natpmp.go | 0 .../ethereum/go-ethereum/p2p/nat/natupnp.go | 0 .../ethereum/go-ethereum/p2p/peer.go | 0 .../ethereum/go-ethereum/p2p/peer_error.go | 0 .../ethereum/go-ethereum/p2p/protocol.go | 0 .../ethereum/go-ethereum/p2p/rlpx.go | 0 .../ethereum/go-ethereum/p2p/server.go | 20 + .../ethereum/go-ethereum/params/dao.go | 0 .../go-ethereum/params/protocol_params.go | 0 .../ethereum/go-ethereum/params/util.go | 0 .../ethereum/go-ethereum/pow/block.go | 0 .../ethereum/go-ethereum/pow/dagger/dagger.go | 0 .../ethereum/go-ethereum/pow/ezp/pow.go | 0 .../ethereum/go-ethereum/pow/pow.go | 0 .../ethereum/go-ethereum/release/contract.go | 0 .../ethereum/go-ethereum/release/contract.sol | 0 .../ethereum/go-ethereum/release/generator.go | 0 .../ethereum/go-ethereum/release/release.go | 0 .../ethereum/go-ethereum/rlp/decode.go | 0 .../ethereum/go-ethereum/rlp/doc.go | 0 .../ethereum/go-ethereum/rlp/encode.go | 0 .../ethereum/go-ethereum/rlp/raw.go | 0 .../ethereum/go-ethereum/rlp/typecache.go | 0 .../ethereum/go-ethereum/rpc/client.go | 776 ++++++++++++++++++ .../go-ethereum/rpc/client_context_go1.4.go | 60 ++ .../go-ethereum/rpc/client_context_go1.5.go | 61 ++ .../go-ethereum/rpc/client_context_go1.6.go | 55 ++ .../go-ethereum/rpc/client_context_go1.7.go | 51 ++ .../ethereum/go-ethereum/rpc/doc.go | 0 .../ethereum/go-ethereum/rpc/errors.go | 63 +- .../ethereum/go-ethereum/rpc/http.go | 175 ++++ .../ethereum/go-ethereum/rpc/inproc.go | 34 + .../ethereum/go-ethereum/rpc/ipc.go | 55 ++ .../ethereum/go-ethereum/rpc/ipc_unix.go | 6 +- .../ethereum/go-ethereum/rpc/ipc_windows.go | 15 +- .../ethereum/go-ethereum/rpc/json.go | 77 +- .../ethereum/go-ethereum/rpc/server.go | 36 +- .../ethereum/go-ethereum/rpc/subscription.go | 135 +++ .../ethereum/go-ethereum/rpc/types.go | 54 +- .../ethereum/go-ethereum/rpc/utils.go | 61 +- .../ethereum/go-ethereum/rpc/websocket.go | 152 ++++ .../ethereum/go-ethereum/trie/arc.go | 0 .../ethereum/go-ethereum/trie/encoding.go | 0 .../ethereum/go-ethereum/trie/errors.go | 0 .../ethereum/go-ethereum/trie/iterator.go | 0 .../ethereum/go-ethereum/trie/node.go | 0 .../ethereum/go-ethereum/trie/proof.go | 0 .../ethereum/go-ethereum/trie/secure_trie.go | 0 .../ethereum/go-ethereum/trie/sync.go | 0 .../ethereum/go-ethereum/trie/trie.go | 0 .../ethereum/go-ethereum/whisper/api.go | 0 .../ethereum/go-ethereum/whisper/doc.go | 0 .../ethereum/go-ethereum/whisper/envelope.go | 0 .../ethereum/go-ethereum/whisper/filter.go | 0 .../ethereum/go-ethereum/whisper/main.go | 0 .../ethereum/go-ethereum/whisper/message.go | 0 .../ethereum/go-ethereum/whisper/peer.go | 0 .../ethereum/go-ethereum/whisper/topic.go | 0 .../ethereum/go-ethereum/whisper/whisper.go | 5 +- .../github.com/golang/snappy/.gitignore | 0 .../github.com/golang/snappy/AUTHORS | 0 .../github.com/golang/snappy/CONTRIBUTORS | 0 .../github.com/golang/snappy/LICENSE | 0 .../github.com/golang/snappy/README | 0 .../github.com/golang/snappy/decode.go | 0 .../github.com/golang/snappy/decode_amd64.go | 0 .../github.com/golang/snappy/decode_amd64.s | 0 .../github.com/golang/snappy/decode_other.go | 0 .../github.com/golang/snappy/encode.go | 0 .../github.com/golang/snappy/encode_amd64.go | 0 .../github.com/golang/snappy/encode_amd64.s | 0 .../github.com/golang/snappy/encode_other.go | 0 .../github.com/golang/snappy/snappy.go | 0 .../hashicorp/golang-lru/.gitignore | 0 .../github.com/hashicorp/golang-lru/2q.go | 0 .../github.com/hashicorp/golang-lru/LICENSE | 0 .../github.com/hashicorp/golang-lru/README.md | 0 .../github.com/hashicorp/golang-lru/arc.go | 0 .../github.com/hashicorp/golang-lru/lru.go | 0 .../hashicorp/golang-lru/simplelru/lru.go | 0 .../github.com/huin/goupnp/.gitignore | 0 .../github.com/huin/goupnp/LICENSE | 0 .../github.com/huin/goupnp/README.md | 0 .../dcps/internetgateway1/internetgateway1.go | 0 .../dcps/internetgateway2/internetgateway2.go | 0 .../github.com/huin/goupnp/device.go | 0 .../github.com/huin/goupnp/goupnp.go | 0 .../github.com/huin/goupnp/httpu/httpu.go | 0 .../github.com/huin/goupnp/httpu/serve.go | 0 .../github.com/huin/goupnp/scpd/scpd.go | 0 .../github.com/huin/goupnp/service_client.go | 0 .../github.com/huin/goupnp/soap/soap.go | 0 .../github.com/huin/goupnp/soap/types.go | 0 .../github.com/huin/goupnp/ssdp/registry.go | 0 .../github.com/huin/goupnp/ssdp/ssdp.go | 0 .../github.com/jackpal/go-nat-pmp/.travis.yml | 0 .../github.com/jackpal/go-nat-pmp/LICENSE | 0 .../github.com/jackpal/go-nat-pmp/README.md | 0 .../github.com/jackpal/go-nat-pmp/natpmp.go | 0 .../github.com/jackpal/go-nat-pmp/network.go | 0 .../github.com/jackpal/go-nat-pmp/recorder.go | 0 .../github.com/microsoft/go-winio/.gitignore | 0 .../github.com/microsoft/go-winio/LICENSE | 0 .../github.com/microsoft/go-winio/README.md | 0 .../github.com/microsoft/go-winio/backup.go | 0 .../github.com/microsoft/go-winio/file.go | 0 .../github.com/microsoft/go-winio/fileinfo.go | 0 .../github.com/microsoft/go-winio/pipe.go | 0 .../microsoft/go-winio/privilege.go | 0 .../github.com/microsoft/go-winio/reparse.go | 0 .../github.com/microsoft/go-winio/sd.go | 0 .../github.com/microsoft/go-winio/syscall.go | 0 .../github.com/microsoft/go-winio/zsyscall.go | 0 .../github.com/pborman/uuid/.travis.yml | 0 .../github.com/pborman/uuid/CONTRIBUTING.md | 0 .../github.com/pborman/uuid/CONTRIBUTORS | 0 .../github.com/pborman/uuid/LICENSE | 0 .../github.com/pborman/uuid/README.md | 0 .../github.com/pborman/uuid/dce.go | 0 .../github.com/pborman/uuid/doc.go | 0 .../github.com/pborman/uuid/hash.go | 0 .../github.com/pborman/uuid/json.go | 0 .../github.com/pborman/uuid/node.go | 0 .../github.com/pborman/uuid/sql.go | 0 .../github.com/pborman/uuid/time.go | 0 .../github.com/pborman/uuid/util.go | 0 .../github.com/pborman/uuid/uuid.go | 0 .../github.com/pborman/uuid/version1.go | 0 .../github.com/pborman/uuid/version4.go | 0 .../github.com/pkg/errors/.gitignore | 0 .../github.com/pkg/errors/.travis.yml | 0 .../github.com/pkg/errors/LICENSE | 0 .../github.com/pkg/errors/README.md | 0 .../github.com/pkg/errors/errors.go | 0 .../github.com/rcrowley/go-metrics/.gitignore | 0 .../rcrowley/go-metrics/.travis.yml | 0 .../github.com/rcrowley/go-metrics/LICENSE | 0 .../github.com/rcrowley/go-metrics/README.md | 0 .../github.com/rcrowley/go-metrics/counter.go | 0 .../github.com/rcrowley/go-metrics/debug.go | 0 .../github.com/rcrowley/go-metrics/ewma.go | 0 .../github.com/rcrowley/go-metrics/gauge.go | 0 .../rcrowley/go-metrics/gauge_float64.go | 0 .../rcrowley/go-metrics/graphite.go | 0 .../rcrowley/go-metrics/healthcheck.go | 0 .../rcrowley/go-metrics/histogram.go | 0 .../github.com/rcrowley/go-metrics/json.go | 0 .../github.com/rcrowley/go-metrics/log.go | 0 .../github.com/rcrowley/go-metrics/memory.md | 0 .../github.com/rcrowley/go-metrics/meter.go | 0 .../github.com/rcrowley/go-metrics/metrics.go | 0 .../rcrowley/go-metrics/opentsdb.go | 0 .../rcrowley/go-metrics/registry.go | 0 .../github.com/rcrowley/go-metrics/runtime.go | 0 .../rcrowley/go-metrics/runtime_cgo.go | 0 .../go-metrics/runtime_gccpufraction.go | 0 .../rcrowley/go-metrics/runtime_no_cgo.go | 0 .../go-metrics/runtime_no_gccpufraction.go | 0 .../github.com/rcrowley/go-metrics/sample.go | 0 .../github.com/rcrowley/go-metrics/syslog.go | 0 .../github.com/rcrowley/go-metrics/timer.go | 0 .../rcrowley/go-metrics/validate.sh | 0 .../github.com/rcrowley/go-metrics/writer.go | 0 .../github.com/rjeczalik/notify/.gitignore | 0 .../github.com/rjeczalik/notify/.travis.yml | 0 .../github.com/rjeczalik/notify/AUTHORS | 0 .../github.com/rjeczalik/notify/LICENSE | 0 .../github.com/rjeczalik/notify/README.md | 0 .../github.com/rjeczalik/notify/appveyor.yml | 0 .../github.com/rjeczalik/notify/debug.go | 0 .../rjeczalik/notify/debug_debug.go | 0 .../github.com/rjeczalik/notify/doc.go | 0 .../github.com/rjeczalik/notify/event.go | 0 .../github.com/rjeczalik/notify/event_fen.go | 0 .../rjeczalik/notify/event_fsevents.go | 0 .../rjeczalik/notify/event_inotify.go | 0 .../rjeczalik/notify/event_kqueue.go | 0 .../rjeczalik/notify/event_readdcw.go | 0 .../github.com/rjeczalik/notify/event_stub.go | 0 .../rjeczalik/notify/event_trigger.go | 0 .../github.com/rjeczalik/notify/node.go | 0 .../github.com/rjeczalik/notify/notify.go | 0 .../github.com/rjeczalik/notify/tree.go | 0 .../rjeczalik/notify/tree_nonrecursive.go | 0 .../rjeczalik/notify/tree_recursive.go | 0 .../github.com/rjeczalik/notify/util.go | 0 .../github.com/rjeczalik/notify/watcher.go | 0 .../rjeczalik/notify/watcher_fen.go | 0 .../rjeczalik/notify/watcher_fen_cgo.go | 0 .../rjeczalik/notify/watcher_fsevents.go | 0 .../rjeczalik/notify/watcher_fsevents_cgo.go | 0 .../rjeczalik/notify/watcher_inotify.go | 0 .../rjeczalik/notify/watcher_kqueue.go | 0 .../rjeczalik/notify/watcher_readdcw.go | 0 .../rjeczalik/notify/watcher_stub.go | 0 .../rjeczalik/notify/watcher_trigger.go | 0 .../github.com/rjeczalik/notify/watchpoint.go | 0 .../rjeczalik/notify/watchpoint_other.go | 0 .../rjeczalik/notify/watchpoint_readdcw.go | 0 .../robertkrimen/otto/DESIGN.markdown | 0 .../github.com/robertkrimen/otto/LICENSE | 0 .../github.com/robertkrimen/otto/Makefile | 0 .../robertkrimen/otto/README.markdown | 0 .../robertkrimen/otto/array_test.go | 0 .../robertkrimen/otto/ast/README.markdown | 0 .../robertkrimen/otto/ast/comments.go | 0 .../robertkrimen/otto/ast/comments_test.go | 0 .../github.com/robertkrimen/otto/ast/node.go | 0 .../github.com/robertkrimen/otto/bug_test.go | 0 .../github.com/robertkrimen/otto/builtin.go | 0 .../robertkrimen/otto/builtin_array.go | 0 .../robertkrimen/otto/builtin_boolean.go | 0 .../robertkrimen/otto/builtin_date.go | 0 .../robertkrimen/otto/builtin_error.go | 0 .../robertkrimen/otto/builtin_function.go | 0 .../robertkrimen/otto/builtin_json.go | 0 .../robertkrimen/otto/builtin_math.go | 0 .../robertkrimen/otto/builtin_number.go | 0 .../robertkrimen/otto/builtin_object.go | 0 .../robertkrimen/otto/builtin_regexp.go | 0 .../robertkrimen/otto/builtin_string.go | 0 .../robertkrimen/otto/builtin_test.go | 0 .../github.com/robertkrimen/otto/call_test.go | 0 .../github.com/robertkrimen/otto/clone.go | 0 .../robertkrimen/otto/clone_test.go | 0 .../github.com/robertkrimen/otto/cmpl.go | 0 .../robertkrimen/otto/cmpl_evaluate.go | 0 .../otto/cmpl_evaluate_expression.go | 0 .../otto/cmpl_evaluate_statement.go | 0 .../robertkrimen/otto/cmpl_parse.go | 0 .../github.com/robertkrimen/otto/cmpl_test.go | 0 .../github.com/robertkrimen/otto/console.go | 0 .../github.com/robertkrimen/otto/date_test.go | 0 .../github.com/robertkrimen/otto/dbg.go | 0 .../github.com/robertkrimen/otto/dbg/dbg.go | 0 .../robertkrimen/otto/documentation_test.go | 0 .../github.com/robertkrimen/otto/error.go | 0 .../robertkrimen/otto/error_native_test.go | 0 .../robertkrimen/otto/error_test.go | 0 .../github.com/robertkrimen/otto/evaluate.go | 0 .../robertkrimen/otto/file/README.markdown | 0 .../github.com/robertkrimen/otto/file/file.go | 0 .../robertkrimen/otto/function_stack_test.go | 0 .../robertkrimen/otto/function_test.go | 0 .../github.com/robertkrimen/otto/global.go | 0 .../robertkrimen/otto/global_test.go | 0 .../github.com/robertkrimen/otto/inline.go | 0 .../github.com/robertkrimen/otto/inline.pl | 0 .../github.com/robertkrimen/otto/json_test.go | 0 .../github.com/robertkrimen/otto/math_test.go | 0 .../robertkrimen/otto/native_stack_test.go | 0 .../robertkrimen/otto/number_test.go | 0 .../github.com/robertkrimen/otto/object.go | 0 .../robertkrimen/otto/object_class.go | 0 .../robertkrimen/otto/object_test.go | 0 .../github.com/robertkrimen/otto/otto.go | 0 .../robertkrimen/otto/otto/Makefile | 0 .../github.com/robertkrimen/otto/otto/main.go | 0 .../github.com/robertkrimen/otto/otto_.go | 0 .../robertkrimen/otto/otto_error_test.go | 0 .../github.com/robertkrimen/otto/otto_test.go | 0 .../robertkrimen/otto/panic_test.go | 0 .../robertkrimen/otto/parser/Makefile | 0 .../robertkrimen/otto/parser/README.markdown | 0 .../robertkrimen/otto/parser/comments_test.go | 0 .../robertkrimen/otto/parser/dbg.go | 0 .../robertkrimen/otto/parser/error.go | 0 .../robertkrimen/otto/parser/expression.go | 0 .../robertkrimen/otto/parser/lexer.go | 0 .../robertkrimen/otto/parser/lexer_test.go | 0 .../robertkrimen/otto/parser/marshal_test.go | 0 .../robertkrimen/otto/parser/parser.go | 0 .../robertkrimen/otto/parser/parser_test.go | 0 .../robertkrimen/otto/parser/regexp.go | 0 .../robertkrimen/otto/parser/regexp_test.go | 0 .../robertkrimen/otto/parser/scope.go | 0 .../robertkrimen/otto/parser/statement.go | 0 .../robertkrimen/otto/parser_test.go | 0 .../github.com/robertkrimen/otto/property.go | 0 .../robertkrimen/otto/reflect_test.go | 0 .../robertkrimen/otto/regexp_test.go | 0 .../otto/registry/README.markdown | 0 .../robertkrimen/otto/registry/registry.go | 0 .../robertkrimen/otto/repl/autocompleter.go | 0 .../github.com/robertkrimen/otto/repl/repl.go | 0 .../github.com/robertkrimen/otto/result.go | 0 .../github.com/robertkrimen/otto/runtime.go | 0 .../robertkrimen/otto/runtime_test.go | 0 .../github.com/robertkrimen/otto/scope.go | 0 .../github.com/robertkrimen/otto/script.go | 0 .../robertkrimen/otto/script_test.go | 0 .../robertkrimen/otto/sourcemap_test.go | 0 .../github.com/robertkrimen/otto/stash.go | 0 .../robertkrimen/otto/string_test.go | 0 .../robertkrimen/otto/terst/terst.go | 0 .../robertkrimen/otto/test/Makefile | 0 .../robertkrimen/otto/test/tester.go | 0 .../robertkrimen/otto/testing_test.go | 0 .../robertkrimen/otto/token/Makefile | 0 .../robertkrimen/otto/token/README.markdown | 0 .../robertkrimen/otto/token/token.go | 0 .../robertkrimen/otto/token/token_const.go | 0 .../robertkrimen/otto/token/tokenfmt | 0 .../robertkrimen/otto/type_arguments.go | 0 .../robertkrimen/otto/type_array.go | 0 .../robertkrimen/otto/type_boolean.go | 0 .../github.com/robertkrimen/otto/type_date.go | 0 .../robertkrimen/otto/type_error.go | 0 .../robertkrimen/otto/type_function.go | 0 .../robertkrimen/otto/type_go_array.go | 0 .../robertkrimen/otto/type_go_map.go | 0 .../robertkrimen/otto/type_go_slice.go | 0 .../robertkrimen/otto/type_go_slice_test.go | 0 .../robertkrimen/otto/type_go_struct.go | 0 .../robertkrimen/otto/type_number.go | 0 .../robertkrimen/otto/type_reference.go | 0 .../robertkrimen/otto/type_regexp.go | 0 .../robertkrimen/otto/type_string.go | 0 .../robertkrimen/otto/underscore/Makefile | 0 .../otto/underscore/README.markdown | 0 .../robertkrimen/otto/underscore/source.go | 0 .../robertkrimen/otto/underscore/testify | 0 .../otto/underscore/underscore.go | 0 .../otto/underscore_arrays_test.go | 0 .../otto/underscore_chaining_test.go | 0 .../otto/underscore_collections_test.go | 0 .../otto/underscore_functions_test.go | 0 .../otto/underscore_objects_test.go | 0 .../robertkrimen/otto/underscore_test.go | 0 .../otto/underscore_utility_test.go | 0 .../github.com/robertkrimen/otto/value.go | 0 .../robertkrimen/otto/value_boolean.go | 0 .../robertkrimen/otto/value_number.go | 0 .../robertkrimen/otto/value_primitive.go | 0 .../robertkrimen/otto/value_string.go | 0 .../robertkrimen/otto/value_test.go | 0 .../github.com/rs/cors/.travis.yml | 0 .../github.com/rs/cors/LICENSE | 0 .../github.com/rs/cors/README.md | 0 .../github.com/rs/cors/cors.go | 0 .../github.com/rs/cors/utils.go | 0 .../github.com/rs/xhandler/.travis.yml | 0 .../github.com/rs/xhandler/LICENSE | 0 .../github.com/rs/xhandler/README.md | 0 .../github.com/rs/xhandler/chain.go | 0 .../github.com/rs/xhandler/middleware.go | 0 .../github.com/rs/xhandler/xhandler.go | 0 .../github.com/syndtr/goleveldb/LICENSE | 0 .../syndtr/goleveldb/leveldb/batch.go | 0 .../syndtr/goleveldb/leveldb/cache/cache.go | 0 .../syndtr/goleveldb/leveldb/cache/lru.go | 0 .../syndtr/goleveldb/leveldb/comparer.go | 0 .../leveldb/comparer/bytes_comparer.go | 0 .../goleveldb/leveldb/comparer/comparer.go | 0 .../github.com/syndtr/goleveldb/leveldb/db.go | 0 .../syndtr/goleveldb/leveldb/db_compaction.go | 0 .../syndtr/goleveldb/leveldb/db_iter.go | 0 .../syndtr/goleveldb/leveldb/db_snapshot.go | 0 .../syndtr/goleveldb/leveldb/db_state.go | 0 .../goleveldb/leveldb/db_transaction.go | 0 .../syndtr/goleveldb/leveldb/db_util.go | 0 .../syndtr/goleveldb/leveldb/db_write.go | 0 .../syndtr/goleveldb/leveldb/doc.go | 0 .../syndtr/goleveldb/leveldb/errors.go | 0 .../syndtr/goleveldb/leveldb/errors/errors.go | 0 .../syndtr/goleveldb/leveldb/filter.go | 0 .../syndtr/goleveldb/leveldb/filter/bloom.go | 0 .../syndtr/goleveldb/leveldb/filter/filter.go | 0 .../goleveldb/leveldb/iterator/array_iter.go | 0 .../leveldb/iterator/indexed_iter.go | 0 .../syndtr/goleveldb/leveldb/iterator/iter.go | 0 .../goleveldb/leveldb/iterator/merged_iter.go | 0 .../goleveldb/leveldb/journal/journal.go | 0 .../syndtr/goleveldb/leveldb/key.go | 0 .../syndtr/goleveldb/leveldb/memdb/memdb.go | 0 .../syndtr/goleveldb/leveldb/opt/options.go | 0 .../syndtr/goleveldb/leveldb/options.go | 0 .../syndtr/goleveldb/leveldb/session.go | 0 .../goleveldb/leveldb/session_compaction.go | 0 .../goleveldb/leveldb/session_record.go | 0 .../syndtr/goleveldb/leveldb/session_util.go | 0 .../goleveldb/leveldb/storage/file_storage.go | 0 .../leveldb/storage/file_storage_plan9.go | 0 .../leveldb/storage/file_storage_solaris.go | 0 .../leveldb/storage/file_storage_unix.go | 0 .../leveldb/storage/file_storage_windows.go | 0 .../goleveldb/leveldb/storage/mem_storage.go | 0 .../goleveldb/leveldb/storage/storage.go | 0 .../syndtr/goleveldb/leveldb/table.go | 0 .../syndtr/goleveldb/leveldb/table/reader.go | 0 .../syndtr/goleveldb/leveldb/table/table.go | 0 .../syndtr/goleveldb/leveldb/table/writer.go | 0 .../syndtr/goleveldb/leveldb/util.go | 0 .../syndtr/goleveldb/leveldb/util/buffer.go | 0 .../goleveldb/leveldb/util/buffer_pool.go | 0 .../syndtr/goleveldb/leveldb/util/crc32.go | 0 .../syndtr/goleveldb/leveldb/util/hash.go | 0 .../syndtr/goleveldb/leveldb/util/range.go | 0 .../syndtr/goleveldb/leveldb/util/util.go | 0 .../syndtr/goleveldb/leveldb/version.go | 0 .../golang.org/x/crypto/LICENSE | 0 .../golang.org/x/crypto/PATENTS | 0 .../golang.org/x/crypto/pbkdf2/pbkdf2.go | 0 .../x/crypto/ripemd160/ripemd160.go | 0 .../x/crypto/ripemd160/ripemd160block.go | 0 .../golang.org/x/crypto/scrypt/scrypt.go | 0 .../golang.org/x/net/LICENSE | 0 .../golang.org/x/net/PATENTS | 0 .../golang.org/x/net/context/context.go | 0 .../golang.org/x/net/context/go17.go | 0 .../golang.org/x/net/context/pre_go17.go | 0 .../golang.org/x/net/html/atom/atom.go | 0 .../golang.org/x/net/html/atom/gen.go | 0 .../golang.org/x/net/html/atom/table.go | 0 .../golang.org/x/net/html/charset/charset.go | 0 .../golang.org/x/net/html/const.go | 0 .../golang.org/x/net/html/doc.go | 0 .../golang.org/x/net/html/doctype.go | 0 .../golang.org/x/net/html/entity.go | 0 .../golang.org/x/net/html/escape.go | 0 .../golang.org/x/net/html/foreign.go | 0 .../golang.org/x/net/html/node.go | 0 .../golang.org/x/net/html/parse.go | 0 .../golang.org/x/net/html/render.go | 0 .../golang.org/x/net/html/token.go | 0 .../golang.org/x/net/websocket/client.go | 0 .../golang.org/x/net/websocket/hybi.go | 0 .../golang.org/x/net/websocket/server.go | 0 .../golang.org/x/net/websocket/websocket.go | 0 .../golang.org/x/sys/LICENSE | 0 .../golang.org/x/sys/PATENTS | 0 .../x/sys/windows/asm_windows_386.s | 0 .../x/sys/windows/asm_windows_amd64.s | 0 .../golang.org/x/sys/windows/dll_windows.go | 0 .../golang.org/x/sys/windows/env_unset.go | 0 .../golang.org/x/sys/windows/env_windows.go | 0 .../golang.org/x/sys/windows/eventlog.go | 0 .../golang.org/x/sys/windows/exec_windows.go | 0 .../golang.org/x/sys/windows/race.go | 0 .../golang.org/x/sys/windows/race0.go | 0 .../x/sys/windows/security_windows.go | 0 .../golang.org/x/sys/windows/service.go | 0 .../golang.org/x/sys/windows/str.go | 0 .../golang.org/x/sys/windows/syscall.go | 0 .../x/sys/windows/syscall_windows.go | 0 .../x/sys/windows/zsyscall_windows.go | 0 .../x/sys/windows/ztypes_windows.go | 0 .../x/sys/windows/ztypes_windows_386.go | 0 .../x/sys/windows/ztypes_windows_amd64.go | 0 .../golang.org/x/text/LICENSE | 0 .../golang.org/x/text/PATENTS | 0 .../x/text/encoding/charmap/charmap.go | 0 .../x/text/encoding/charmap/maketables.go | 0 .../x/text/encoding/charmap/tables.go | 0 .../golang.org/x/text/encoding/encoding.go | 0 .../x/text/encoding/htmlindex/gen.go | 0 .../x/text/encoding/htmlindex/htmlindex.go | 0 .../x/text/encoding/htmlindex/map.go | 0 .../x/text/encoding/htmlindex/tables.go | 0 .../text/encoding/internal/identifier/gen.go | 0 .../internal/identifier/identifier.go | 0 .../text/encoding/internal/identifier/mib.go | 0 .../x/text/encoding/internal/internal.go | 0 .../x/text/encoding/japanese/all.go | 0 .../x/text/encoding/japanese/eucjp.go | 0 .../x/text/encoding/japanese/iso2022jp.go | 0 .../x/text/encoding/japanese/maketables.go | 0 .../x/text/encoding/japanese/shiftjis.go | 0 .../x/text/encoding/japanese/tables.go | 0 .../x/text/encoding/korean/euckr.go | 0 .../x/text/encoding/korean/maketables.go | 0 .../x/text/encoding/korean/tables.go | 0 .../x/text/encoding/simplifiedchinese/all.go | 0 .../x/text/encoding/simplifiedchinese/gbk.go | 0 .../encoding/simplifiedchinese/hzgb2312.go | 0 .../encoding/simplifiedchinese/maketables.go | 0 .../text/encoding/simplifiedchinese/tables.go | 0 .../text/encoding/traditionalchinese/big5.go | 0 .../encoding/traditionalchinese/maketables.go | 0 .../encoding/traditionalchinese/tables.go | 0 .../x/text/encoding/unicode/override.go | 0 .../x/text/encoding/unicode/unicode.go | 0 .../golang.org/x/text/internal/gen/code.go | 0 .../golang.org/x/text/internal/gen/gen.go | 0 .../golang.org/x/text/internal/tag/tag.go | 0 .../x/text/internal/testtext/codesize.go | 0 .../x/text/internal/testtext/flag.go | 0 .../x/text/internal/testtext/text.go | 0 .../internal/utf8internal/utf8internal.go | 0 .../golang.org/x/text/language/Makefile | 0 .../golang.org/x/text/language/common.go | 0 .../golang.org/x/text/language/coverage.go | 0 .../golang.org/x/text/language/gen_common.go | 0 .../golang.org/x/text/language/gen_index.go | 0 .../golang.org/x/text/language/go1_1.go | 0 .../golang.org/x/text/language/go1_2.go | 0 .../golang.org/x/text/language/index.go | 0 .../golang.org/x/text/language/language.go | 0 .../golang.org/x/text/language/lookup.go | 0 .../golang.org/x/text/language/maketables.go | 0 .../golang.org/x/text/language/match.go | 0 .../golang.org/x/text/language/parse.go | 0 .../golang.org/x/text/language/tables.go | 0 .../golang.org/x/text/language/tags.go | 0 .../golang.org/x/text/runes/cond.go | 0 .../golang.org/x/text/runes/runes.go | 0 .../golang.org/x/text/transform/transform.go | 0 .../golang.org/x/text/unicode/cldr/base.go | 0 .../golang.org/x/text/unicode/cldr/cldr.go | 0 .../x/text/unicode/cldr/cldr_test.go | 0 .../golang.org/x/text/unicode/cldr/collate.go | 0 .../x/text/unicode/cldr/collate_test.go | 0 .../x/text/unicode/cldr/data_test.go | 0 .../golang.org/x/text/unicode/cldr/decode.go | 0 .../x/text/unicode/cldr/examples_test.go | 0 .../golang.org/x/text/unicode/cldr/makexml.go | 0 .../golang.org/x/text/unicode/cldr/resolve.go | 0 .../x/text/unicode/cldr/resolve_test.go | 0 .../golang.org/x/text/unicode/cldr/slice.go | 0 .../x/text/unicode/cldr/slice_test.go | 0 .../golang.org/x/text/unicode/cldr/xml.go | 0 .../x/text/unicode/norm/composition.go | 0 .../x/text/unicode/norm/composition_test.go | 0 .../x/text/unicode/norm/example_iter_test.go | 0 .../x/text/unicode/norm/forminfo.go | 0 .../x/text/unicode/norm/forminfo_test.go | 0 .../golang.org/x/text/unicode/norm/input.go | 0 .../golang.org/x/text/unicode/norm/iter.go | 0 .../x/text/unicode/norm/iter_test.go | 0 .../x/text/unicode/norm/maketables.go | 0 .../x/text/unicode/norm/norm_test.go | 0 .../x/text/unicode/norm/normalize.go | 0 .../x/text/unicode/norm/normalize_test.go | 0 .../x/text/unicode/norm/readwriter.go | 0 .../x/text/unicode/norm/readwriter_test.go | 0 .../golang.org/x/text/unicode/norm/tables.go | 0 .../x/text/unicode/norm/transform.go | 0 .../x/text/unicode/norm/transform_test.go | 0 .../golang.org/x/text/unicode/norm/trie.go | 0 .../golang.org/x/text/unicode/norm/triegen.go | 0 .../x/text/unicode/norm/ucd_test.go | 0 .../golang.org/x/tools/LICENSE | 0 .../golang.org/x/tools/PATENTS | 0 .../x/tools/go/ast/astutil/enclosing.go | 0 .../x/tools/go/ast/astutil/imports.go | 0 .../golang.org/x/tools/go/ast/astutil/util.go | 0 .../golang.org/x/tools/imports/fix.go | 0 .../golang.org/x/tools/imports/imports.go | 0 .../golang.org/x/tools/imports/mkindex.go | 0 .../golang.org/x/tools/imports/mkstdlib.go | 0 .../golang.org/x/tools/imports/sortimports.go | 0 .../golang.org/x/tools/imports/zstdlib.go | 0 .../gopkg.in/fatih/set.v0/.travis.yml | 0 .../gopkg.in/fatih/set.v0/LICENSE.md | 0 .../gopkg.in/fatih/set.v0/README.md | 0 .../gopkg.in/fatih/set.v0/set.go | 0 .../gopkg.in/fatih/set.v0/set_nots.go | 0 .../gopkg.in/fatih/set.v0/set_ts.go | 0 .../gopkg.in/karalabe/cookiejar.v2/LICENSE | 0 .../cookiejar.v2/collections/prque/prque.go | 0 .../cookiejar.v2/collections/prque/sstack.go | 0 .../gopkg.in/sourcemap.v1/.travis.yml | 0 .../gopkg.in/sourcemap.v1/Makefile | 0 .../gopkg.in/sourcemap.v1/README.md | 0 .../sourcemap.v1/base64vlq/base64_vlq.go | 0 .../sourcemap.v1/base64vlq/base64_vlq_test.go | 0 .../gopkg.in/sourcemap.v1/consumer.go | 0 .../gopkg.in/sourcemap.v1/consumer_test.go | 0 .../gopkg.in/sourcemap.v1/example_test.go | 0 .../gopkg.in/urfave/cli.v1/.gitignore | 0 .../gopkg.in/urfave/cli.v1/.travis.yml | 0 .../gopkg.in/urfave/cli.v1/CHANGELOG.md | 0 .../gopkg.in/urfave/cli.v1/LICENSE | 0 .../gopkg.in/urfave/cli.v1/README.md | 0 .../gopkg.in/urfave/cli.v1/app.go | 0 .../gopkg.in/urfave/cli.v1/appveyor.yml | 0 .../gopkg.in/urfave/cli.v1/category.go | 0 .../gopkg.in/urfave/cli.v1/cli.go | 0 .../gopkg.in/urfave/cli.v1/command.go | 0 .../gopkg.in/urfave/cli.v1/context.go | 0 .../gopkg.in/urfave/cli.v1/errors.go | 0 .../gopkg.in/urfave/cli.v1/flag.go | 0 .../gopkg.in/urfave/cli.v1/funcs.go | 0 .../gopkg.in/urfave/cli.v1/help.go | 0 .../gopkg.in/urfave/cli.v1/runtests | 0 1092 files changed, 4188 insertions(+), 4610 deletions(-) rename {src => common}/types.go (98%) create mode 100644 common/utils.go rename {src/extkeys => extkeys}/hdkey.go (100%) rename {src/extkeys => extkeys}/hdkey_test.go (98%) rename {src/extkeys => extkeys}/mnemonic.go (99%) rename {src/extkeys => extkeys}/mnemonic_test.go (87%) rename {src/extkeys => extkeys}/mnemonic_vectors.json (100%) rename {src/extkeys => extkeys}/utils.go (100%) create mode 100644 src/node.go delete mode 100644 src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/remote.go delete mode 100644 src/vendor/github.com/ethereum/go-ethereum/cmd/utils/client.go delete mode 100644 src/vendor/github.com/ethereum/go-ethereum/common/compiler/solidity.go delete mode 100644 src/vendor/github.com/ethereum/go-ethereum/eth/downloader/api.go delete mode 100644 src/vendor/github.com/ethereum/go-ethereum/eth/filters/api.go delete mode 100644 src/vendor/github.com/ethereum/go-ethereum/eth/filters/filter_system.go delete mode 100644 src/vendor/github.com/ethereum/go-ethereum/rpc/http.go delete mode 100644 src/vendor/github.com/ethereum/go-ethereum/rpc/inproc.go delete mode 100644 src/vendor/github.com/ethereum/go-ethereum/rpc/ipc.go delete mode 100644 src/vendor/github.com/ethereum/go-ethereum/rpc/notification.go delete mode 100644 src/vendor/github.com/ethereum/go-ethereum/rpc/websocket.go rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/cl.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/context.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/device.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/device12.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/image.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/kernel.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/kernel10.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/kernel12.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/platform.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/program.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/queue.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/types.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/types12.go (100%) rename {src/vendor => vendor}/github.com/Gustav-Simonsson/go-opencl/cl/types_darwin.go (100%) rename {src/vendor => vendor}/github.com/aristanetworks/goarista/COPYING (100%) rename {src/vendor => vendor}/github.com/aristanetworks/goarista/atime/issue15006.s (100%) rename {src/vendor => vendor}/github.com/aristanetworks/goarista/atime/nanotime.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/LICENSE (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/README.md (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/btcec.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/ciphering.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/doc.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/field.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/genprecomps.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/gensecp256k1.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/precompute.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/privkey.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/pubkey.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/secp256k1.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/btcec/signature.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/chaincfg/README.md (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/chaincfg/chainhash/README.md (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/chaincfg/chainhash/doc.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/chaincfg/chainhash/hash.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/chaincfg/chainhash/hashfuncs.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/chaincfg/doc.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/chaincfg/genesis.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/chaincfg/params.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/README.md (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/blockheader.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/common.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/doc.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/error.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/invvect.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/message.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgaddr.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgalert.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgblock.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgfilteradd.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgfilterclear.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgfilterload.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msggetaddr.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msggetblocks.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msggetdata.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msggetheaders.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgheaders.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msginv.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgmempool.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgmerkleblock.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgnotfound.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgping.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgpong.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgreject.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgsendheaders.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgtx.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgverack.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/msgversion.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/netaddress.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcd/wire/protocol.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/LICENSE (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/README.md (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/address.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/amount.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/appdata.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/base58/README.md (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/base58/alphabet.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/base58/base58.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/base58/base58check.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/base58/cov_report.sh (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/base58/doc.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/base58/genalphabet.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/block.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/certgen.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/const.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/cov_report.sh (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/doc.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/goclean.sh (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/hash160.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/hdkeychain/README.md (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/hdkeychain/cov_report.sh (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/hdkeychain/doc.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/hdkeychain/extendedkey.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/hdkeychain/test_coverage.txt (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/net.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/net_noop.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/test_coverage.txt (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/tx.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/btcutil/wif.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/fastsha256/LICENSE.md (100%) rename {src/vendor => vendor}/github.com/btcsuite/fastsha256/sha256.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/fastsha256/sha256block.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/fastsha256/sha256block_386.s (100%) rename {src/vendor => vendor}/github.com/btcsuite/fastsha256/sha256block_amd64.s (100%) rename {src/vendor => vendor}/github.com/btcsuite/fastsha256/sha256block_decl.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/golangcrypto/LICENSE (100%) rename {src/vendor => vendor}/github.com/btcsuite/golangcrypto/PATENTS (100%) rename {src/vendor => vendor}/github.com/btcsuite/golangcrypto/ripemd160/ripemd160.go (100%) rename {src/vendor => vendor}/github.com/btcsuite/golangcrypto/ripemd160/ripemd160block.go (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/.gitignore (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/.travis.yml (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/CMakeLists.txt (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/MANIFEST.in (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/Makefile (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/README.md (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/Vagrantfile (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/appveyor.yml (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/ethash.go (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/ethash_opencl.go (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/ethash_opencl_kernel_go_str.go (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/ethashc.go (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/setup.py (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/benchmark/CMakeLists.txt (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/benchmark/benchmark.cpp (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/CMakeLists.txt (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/compiler.h (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/data_sizes.h (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/endian.h (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/ethash.h (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/fnv.h (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/internal.c (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/internal.h (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/io.c (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/io.h (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/io_posix.c (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/io_win32.c (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/mmap.h (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/mmap_win32.c (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/sha3.c (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/sha3.h (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.h (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/util.h (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/libethash/util_win32.c (100%) rename {src/vendor => vendor}/github.com/ethereum/ethash/src/python/core.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/COPYING (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/COPYING.LESSER (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/abi.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/argument.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/bind/auth.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/bind/backend.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/nil.go (100%) create mode 100644 vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/remote.go rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/simulated.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/bind/base.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/bind/bind.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/bind/template.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/doc.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/error.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/event.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/method.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/numbers.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/packing.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/reflect.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/abi/type.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/account_manager.go (87%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/addrcache.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/key.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/key_store_passphrase.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/key_store_plain.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/presale.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/watch.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/accounts/watch_fallback.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/abigen/main.go (91%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/bootnode/main.go (87%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/disasm/main.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/evm/code.txt (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/evm/input.txt (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/evm/main.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go (93%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/geth/chaincmd.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/geth/consolecmd.go (86%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/geth/info_test.json (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/geth/library.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/geth/library.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/geth/library_android.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/geth/main.go (82%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/geth/monitorcmd.go (92%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/geth/usage.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/gethrpctest/main.go (83%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/rlpdump/main.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/utils/bootnodes.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/utils/cmd.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/utils/customflags.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_freebsd.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_unix.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_windows.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/cmd/utils/flags.go (86%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/big.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/bytes.go (100%) create mode 100644 vendor/github.com/ethereum/go-ethereum/common/compiler/solidity.go rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/debug.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/defaults.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/httpclient/httpclient.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/icap.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/list.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/math/dist.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/mclock/mclock.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/natspec/natspec.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/natspec/natspec_js.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/number/int.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/path.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/registrar/contracts.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/registrar/ethreg/api.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/registrar/registrar.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/size.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/test_utils.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/types.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/common/types_template.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/compression/rle/read_write.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/console/bridge.go (66%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/console/console.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/console/prompter.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/asm.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/block_validator.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/blockchain.go (99%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/blocks.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/chain_makers.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/chain_pow.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/config.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/dao.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/database_util.go (98%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/default_genesis.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/error.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/events.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/execution.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/fees.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/gaspool.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/genesis.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/headerchain.go (99%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/state/dump.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/state/iterator.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/state/managed_state.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/state/state_object.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/state/statedb.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/state/sync.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/state_processor.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/state_transition.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/tx_pool.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/types.go (83%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/types/block.go (94%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/types/bloom9.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/types/derive_sha.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/types/receipt.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/types/transaction.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/analysis.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/asm.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/common.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/contract.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/contracts.go (96%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/disasm.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/doc.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/environment.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/errors.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/gas.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/instructions.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/jit.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/jit_optimiser.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/jit_util.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/jump_table.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/log.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/logger.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/memory.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/opcodes.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/runtime/doc.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/runtime/env.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/runtime/runtime.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/segments.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/stack.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/virtual_machine.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/vm.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/vm_jit.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm/vm_jit_fake.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/core/vm_env.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/crypto.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/ecies/LICENSE (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/ecies/README (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/ecies/asn1.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/ecies/ecies.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/ecies/params.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/randentropy/rand_entropy.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/curve.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/COPYING (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/Makefile.am (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/TODO (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/autogen.sh (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/configure.ac (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_ecdh.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_recovery.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_schnorr.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/libsecp256k1.pc.in (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/basic-config.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_ecdh.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_internal.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_recover.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_schnorr_verify.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_sign.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_verify.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecdsa.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecdsa_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/eckey.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/eckey_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_const.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_const_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_gen.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_gen_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_asm_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_int128_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/gen_context.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/group.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/group_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/hash.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/hash_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org/bitcoin/NativeSecp256k1.java (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/Makefile.am.include (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/main_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/tests_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/Makefile.am.include (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/tests_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/Makefile.am.include (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/main_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/schnorr.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/schnorr_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/tests_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_gmp.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_gmp_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_4x64.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_4x64_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_8x32.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_8x32_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/testrand.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/testrand_impl.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/tests.c (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/util.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/notes.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/panic_cb.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/pubkey_scalar_mul.h (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/secp256k1/secp256.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/sha3/LICENSE (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/sha3/PATENTS (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/sha3/doc.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/sha3/hashes.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/sha3/keccakf.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/sha3/register.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/sha3/sha3.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/sha3/shake.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/sha3/xor.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/sha3/xor_generic.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/crypto/sha3/xor_unaligned.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/errs/errors.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/api.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/api_backend.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/backend.go (93%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/bad_block.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/bind.go (98%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/cpu_mining.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/db_upgrade.go (97%) create mode 100644 vendor/github.com/ethereum/go-ethereum/eth/downloader/api.go rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/downloader/downloader.go (71%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/downloader/events.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/downloader/metrics.go (79%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/downloader/modes.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/downloader/peer.go (90%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/downloader/queue.go (89%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/downloader/types.go (87%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/fetcher/fetcher.go (90%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/fetcher/metrics.go (90%) create mode 100644 vendor/github.com/ethereum/go-ethereum/eth/filters/api.go rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/filters/filter.go (63%) create mode 100644 vendor/github.com/ethereum/go-ethereum/eth/filters/filter_system.go rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/gasprice/gasprice.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/gasprice/lightprice.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/gpu_mining.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/handler.go (83%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/metrics.go (82%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/peer.go (84%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/protocol.go (79%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/eth/sync.go (96%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/ethdb/database.go (99%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/ethdb/interface.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/ethdb/memory_database.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/event/event.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/event/filter/filter.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/event/filter/generic_filter.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/generators/defaults.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/debug/api.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/debug/flags.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/debug/loudpanic.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/debug/loudpanic_fallback.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/debug/trace.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/debug/trace_fallback.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/ethapi/api.go (88%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/ethapi/backend.go (92%) create mode 100644 vendor/github.com/ethereum/go-ethereum/internal/ethapi/solc.go rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/ethapi/status_backend.go (97%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/jsre/bignumber_js.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/jsre/completion.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/jsre/ethereum_js.go (99%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/jsre/jsre.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/jsre/pretty.go (99%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/internal/web3ext/web3ext.go (98%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/api_backend.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/backend.go (95%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/fetcher.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/flowcontrol/control.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/flowcontrol/manager.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/handler.go (99%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/metrics.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/odr.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/odr_peerset.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/odr_requests.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/peer.go (97%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/protocol.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/server.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/status/txqueue.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/sync.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/les/txrelay.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/light/lightchain.go (97%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/light/odr.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/light/odr_util.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/light/state.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/light/state_object.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/light/trie.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/light/txpool.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/light/vm_env.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/logger/glog/LICENSE (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/logger/glog/README (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/logger/glog/glog.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/logger/glog/glog_file.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/logger/log.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/logger/loggers.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/logger/logsystem.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/logger/sys.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/logger/types.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/logger/verbosity.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/metrics/disk.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/metrics/disk_linux.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/metrics/disk_nop.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/metrics/metrics.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/miner/agent.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/miner/miner.go (89%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/miner/remote_agent.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/miner/worker.go (99%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/node/api.go (95%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/node/config.go (82%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/node/errors.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/node/node.go (94%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/node/service.go (89%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/dial.go (98%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/discover/database.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/discover/node.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/discover/ntp.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/discover/table.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/discover/udp.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/discover/udp_notwindows.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/discover/udp_windows.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/message.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/metrics.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/nat/nat.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/nat/natpmp.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/nat/natupnp.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/peer.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/peer_error.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/protocol.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/rlpx.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/p2p/server.go (97%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/params/dao.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/params/protocol_params.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/params/util.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/pow/block.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/pow/dagger/dagger.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/pow/ezp/pow.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/pow/pow.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/release/contract.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/release/contract.sol (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/release/generator.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/release/release.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rlp/decode.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rlp/doc.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rlp/encode.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rlp/raw.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rlp/typecache.go (100%) create mode 100644 vendor/github.com/ethereum/go-ethereum/rpc/client.go create mode 100644 vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.4.go create mode 100644 vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.5.go create mode 100644 vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.6.go create mode 100644 vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.7.go rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rpc/doc.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rpc/errors.go (59%) create mode 100644 vendor/github.com/ethereum/go-ethereum/rpc/http.go create mode 100644 vendor/github.com/ethereum/go-ethereum/rpc/inproc.go create mode 100644 vendor/github.com/ethereum/go-ethereum/rpc/ipc.go rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rpc/ipc_unix.go (90%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rpc/ipc_windows.go (70%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rpc/json.go (87%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rpc/server.go (95%) create mode 100644 vendor/github.com/ethereum/go-ethereum/rpc/subscription.go rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rpc/types.go (88%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/rpc/utils.go (85%) create mode 100644 vendor/github.com/ethereum/go-ethereum/rpc/websocket.go rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/trie/arc.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/trie/encoding.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/trie/errors.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/trie/iterator.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/trie/node.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/trie/proof.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/trie/secure_trie.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/trie/sync.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/trie/trie.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/whisper/api.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/whisper/doc.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/whisper/envelope.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/whisper/filter.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/whisper/main.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/whisper/message.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/whisper/peer.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/whisper/topic.go (100%) rename {src/vendor => vendor}/github.com/ethereum/go-ethereum/whisper/whisper.go (97%) rename {src/vendor => vendor}/github.com/golang/snappy/.gitignore (100%) rename {src/vendor => vendor}/github.com/golang/snappy/AUTHORS (100%) rename {src/vendor => vendor}/github.com/golang/snappy/CONTRIBUTORS (100%) rename {src/vendor => vendor}/github.com/golang/snappy/LICENSE (100%) rename {src/vendor => vendor}/github.com/golang/snappy/README (100%) rename {src/vendor => vendor}/github.com/golang/snappy/decode.go (100%) rename {src/vendor => vendor}/github.com/golang/snappy/decode_amd64.go (100%) rename {src/vendor => vendor}/github.com/golang/snappy/decode_amd64.s (100%) rename {src/vendor => vendor}/github.com/golang/snappy/decode_other.go (100%) rename {src/vendor => vendor}/github.com/golang/snappy/encode.go (100%) rename {src/vendor => vendor}/github.com/golang/snappy/encode_amd64.go (100%) rename {src/vendor => vendor}/github.com/golang/snappy/encode_amd64.s (100%) rename {src/vendor => vendor}/github.com/golang/snappy/encode_other.go (100%) rename {src/vendor => vendor}/github.com/golang/snappy/snappy.go (100%) rename {src/vendor => vendor}/github.com/hashicorp/golang-lru/.gitignore (100%) rename {src/vendor => vendor}/github.com/hashicorp/golang-lru/2q.go (100%) rename {src/vendor => vendor}/github.com/hashicorp/golang-lru/LICENSE (100%) rename {src/vendor => vendor}/github.com/hashicorp/golang-lru/README.md (100%) rename {src/vendor => vendor}/github.com/hashicorp/golang-lru/arc.go (100%) rename {src/vendor => vendor}/github.com/hashicorp/golang-lru/lru.go (100%) rename {src/vendor => vendor}/github.com/hashicorp/golang-lru/simplelru/lru.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/.gitignore (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/LICENSE (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/README.md (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/dcps/internetgateway1/internetgateway1.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/dcps/internetgateway2/internetgateway2.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/device.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/goupnp.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/httpu/httpu.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/httpu/serve.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/scpd/scpd.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/service_client.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/soap/soap.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/soap/types.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/ssdp/registry.go (100%) rename {src/vendor => vendor}/github.com/huin/goupnp/ssdp/ssdp.go (100%) rename {src/vendor => vendor}/github.com/jackpal/go-nat-pmp/.travis.yml (100%) rename {src/vendor => vendor}/github.com/jackpal/go-nat-pmp/LICENSE (100%) rename {src/vendor => vendor}/github.com/jackpal/go-nat-pmp/README.md (100%) rename {src/vendor => vendor}/github.com/jackpal/go-nat-pmp/natpmp.go (100%) rename {src/vendor => vendor}/github.com/jackpal/go-nat-pmp/network.go (100%) rename {src/vendor => vendor}/github.com/jackpal/go-nat-pmp/recorder.go (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/.gitignore (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/LICENSE (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/README.md (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/backup.go (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/file.go (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/fileinfo.go (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/pipe.go (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/privilege.go (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/reparse.go (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/sd.go (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/syscall.go (100%) rename {src/vendor => vendor}/github.com/microsoft/go-winio/zsyscall.go (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/.travis.yml (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/CONTRIBUTING.md (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/CONTRIBUTORS (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/LICENSE (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/README.md (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/dce.go (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/doc.go (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/hash.go (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/json.go (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/node.go (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/sql.go (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/time.go (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/util.go (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/uuid.go (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/version1.go (100%) rename {src/vendor => vendor}/github.com/pborman/uuid/version4.go (100%) rename {src/vendor => vendor}/github.com/pkg/errors/.gitignore (100%) rename {src/vendor => vendor}/github.com/pkg/errors/.travis.yml (100%) rename {src/vendor => vendor}/github.com/pkg/errors/LICENSE (100%) rename {src/vendor => vendor}/github.com/pkg/errors/README.md (100%) rename {src/vendor => vendor}/github.com/pkg/errors/errors.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/.gitignore (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/.travis.yml (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/LICENSE (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/README.md (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/counter.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/debug.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/ewma.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/gauge.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/gauge_float64.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/graphite.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/healthcheck.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/histogram.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/json.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/log.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/memory.md (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/meter.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/metrics.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/opentsdb.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/registry.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/runtime.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/runtime_cgo.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/runtime_gccpufraction.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/runtime_no_cgo.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/runtime_no_gccpufraction.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/sample.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/syslog.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/timer.go (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/validate.sh (100%) rename {src/vendor => vendor}/github.com/rcrowley/go-metrics/writer.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/.gitignore (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/.travis.yml (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/AUTHORS (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/LICENSE (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/README.md (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/appveyor.yml (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/debug.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/debug_debug.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/doc.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/event.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/event_fen.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/event_fsevents.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/event_inotify.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/event_kqueue.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/event_readdcw.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/event_stub.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/event_trigger.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/node.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/notify.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/tree.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/tree_nonrecursive.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/tree_recursive.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/util.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watcher.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watcher_fen.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watcher_fen_cgo.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watcher_fsevents.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watcher_fsevents_cgo.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watcher_inotify.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watcher_kqueue.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watcher_readdcw.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watcher_stub.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watcher_trigger.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watchpoint.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watchpoint_other.go (100%) rename {src/vendor => vendor}/github.com/rjeczalik/notify/watchpoint_readdcw.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/DESIGN.markdown (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/LICENSE (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/Makefile (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/README.markdown (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/array_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/ast/README.markdown (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/ast/comments.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/ast/comments_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/ast/node.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/bug_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_array.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_boolean.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_date.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_error.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_function.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_json.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_math.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_number.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_object.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_regexp.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_string.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/builtin_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/call_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/clone.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/clone_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/cmpl.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/cmpl_evaluate.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/cmpl_evaluate_expression.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/cmpl_evaluate_statement.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/cmpl_parse.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/cmpl_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/console.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/date_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/dbg.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/dbg/dbg.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/documentation_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/error.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/error_native_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/error_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/evaluate.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/file/README.markdown (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/file/file.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/function_stack_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/function_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/global.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/global_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/inline.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/inline.pl (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/json_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/math_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/native_stack_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/number_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/object.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/object_class.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/object_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/otto.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/otto/Makefile (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/otto/main.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/otto_.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/otto_error_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/otto_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/panic_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/Makefile (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/README.markdown (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/comments_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/dbg.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/error.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/expression.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/lexer.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/lexer_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/marshal_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/parser.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/parser_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/regexp.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/regexp_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/scope.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser/statement.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/parser_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/property.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/reflect_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/regexp_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/registry/README.markdown (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/registry/registry.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/repl/autocompleter.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/repl/repl.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/result.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/runtime.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/runtime_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/scope.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/script.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/script_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/sourcemap_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/stash.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/string_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/terst/terst.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/test/Makefile (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/test/tester.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/testing_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/token/Makefile (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/token/README.markdown (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/token/token.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/token/token_const.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/token/tokenfmt (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_arguments.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_array.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_boolean.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_date.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_error.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_function.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_go_array.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_go_map.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_go_slice.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_go_slice_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_go_struct.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_number.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_reference.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_regexp.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/type_string.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore/Makefile (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore/README.markdown (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore/source.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore/testify (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore/underscore.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore_arrays_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore_chaining_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore_collections_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore_functions_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore_objects_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/underscore_utility_test.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/value.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/value_boolean.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/value_number.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/value_primitive.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/value_string.go (100%) rename {src/vendor => vendor}/github.com/robertkrimen/otto/value_test.go (100%) rename {src/vendor => vendor}/github.com/rs/cors/.travis.yml (100%) rename {src/vendor => vendor}/github.com/rs/cors/LICENSE (100%) rename {src/vendor => vendor}/github.com/rs/cors/README.md (100%) rename {src/vendor => vendor}/github.com/rs/cors/cors.go (100%) rename {src/vendor => vendor}/github.com/rs/cors/utils.go (100%) rename {src/vendor => vendor}/github.com/rs/xhandler/.travis.yml (100%) rename {src/vendor => vendor}/github.com/rs/xhandler/LICENSE (100%) rename {src/vendor => vendor}/github.com/rs/xhandler/README.md (100%) rename {src/vendor => vendor}/github.com/rs/xhandler/chain.go (100%) rename {src/vendor => vendor}/github.com/rs/xhandler/middleware.go (100%) rename {src/vendor => vendor}/github.com/rs/xhandler/xhandler.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/LICENSE (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/batch.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/cache/cache.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/cache/lru.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/comparer.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/db.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/db_compaction.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/db_iter.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/db_snapshot.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/db_state.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/db_transaction.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/db_util.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/db_write.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/doc.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/errors.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/errors/errors.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/filter.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/filter/bloom.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/filter/filter.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/iterator/iter.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/journal/journal.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/key.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/opt/options.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/options.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/session.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/session_compaction.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/session_record.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/session_util.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/storage/file_storage_windows.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/storage/storage.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/table.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/table/reader.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/table/table.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/table/writer.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/util.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/util/buffer.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/util/crc32.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/util/hash.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/util/range.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/util/util.go (100%) rename {src/vendor => vendor}/github.com/syndtr/goleveldb/leveldb/version.go (100%) rename {src/vendor => vendor}/golang.org/x/crypto/LICENSE (100%) rename {src/vendor => vendor}/golang.org/x/crypto/PATENTS (100%) rename {src/vendor => vendor}/golang.org/x/crypto/pbkdf2/pbkdf2.go (100%) rename {src/vendor => vendor}/golang.org/x/crypto/ripemd160/ripemd160.go (100%) rename {src/vendor => vendor}/golang.org/x/crypto/ripemd160/ripemd160block.go (100%) rename {src/vendor => vendor}/golang.org/x/crypto/scrypt/scrypt.go (100%) rename {src/vendor => vendor}/golang.org/x/net/LICENSE (100%) rename {src/vendor => vendor}/golang.org/x/net/PATENTS (100%) rename {src/vendor => vendor}/golang.org/x/net/context/context.go (100%) rename {src/vendor => vendor}/golang.org/x/net/context/go17.go (100%) rename {src/vendor => vendor}/golang.org/x/net/context/pre_go17.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/atom/atom.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/atom/gen.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/atom/table.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/charset/charset.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/const.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/doc.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/doctype.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/entity.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/escape.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/foreign.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/node.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/parse.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/render.go (100%) rename {src/vendor => vendor}/golang.org/x/net/html/token.go (100%) rename {src/vendor => vendor}/golang.org/x/net/websocket/client.go (100%) rename {src/vendor => vendor}/golang.org/x/net/websocket/hybi.go (100%) rename {src/vendor => vendor}/golang.org/x/net/websocket/server.go (100%) rename {src/vendor => vendor}/golang.org/x/net/websocket/websocket.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/LICENSE (100%) rename {src/vendor => vendor}/golang.org/x/sys/PATENTS (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/asm_windows_386.s (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/asm_windows_amd64.s (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/dll_windows.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/env_unset.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/env_windows.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/eventlog.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/exec_windows.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/race.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/race0.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/security_windows.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/service.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/str.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/syscall.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/syscall_windows.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/zsyscall_windows.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/ztypes_windows.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/ztypes_windows_386.go (100%) rename {src/vendor => vendor}/golang.org/x/sys/windows/ztypes_windows_amd64.go (100%) rename {src/vendor => vendor}/golang.org/x/text/LICENSE (100%) rename {src/vendor => vendor}/golang.org/x/text/PATENTS (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/charmap/charmap.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/charmap/maketables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/charmap/tables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/encoding.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/htmlindex/gen.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/htmlindex/htmlindex.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/htmlindex/map.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/htmlindex/tables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/internal/identifier/gen.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/internal/identifier/identifier.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/internal/identifier/mib.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/internal/internal.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/japanese/all.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/japanese/eucjp.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/japanese/iso2022jp.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/japanese/maketables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/japanese/shiftjis.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/japanese/tables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/korean/euckr.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/korean/maketables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/korean/tables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/simplifiedchinese/all.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/simplifiedchinese/gbk.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/simplifiedchinese/maketables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/simplifiedchinese/tables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/traditionalchinese/big5.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/traditionalchinese/maketables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/traditionalchinese/tables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/unicode/override.go (100%) rename {src/vendor => vendor}/golang.org/x/text/encoding/unicode/unicode.go (100%) rename {src/vendor => vendor}/golang.org/x/text/internal/gen/code.go (100%) rename {src/vendor => vendor}/golang.org/x/text/internal/gen/gen.go (100%) rename {src/vendor => vendor}/golang.org/x/text/internal/tag/tag.go (100%) rename {src/vendor => vendor}/golang.org/x/text/internal/testtext/codesize.go (100%) rename {src/vendor => vendor}/golang.org/x/text/internal/testtext/flag.go (100%) rename {src/vendor => vendor}/golang.org/x/text/internal/testtext/text.go (100%) rename {src/vendor => vendor}/golang.org/x/text/internal/utf8internal/utf8internal.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/Makefile (100%) rename {src/vendor => vendor}/golang.org/x/text/language/common.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/coverage.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/gen_common.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/gen_index.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/go1_1.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/go1_2.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/index.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/language.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/lookup.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/maketables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/match.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/parse.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/tables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/language/tags.go (100%) rename {src/vendor => vendor}/golang.org/x/text/runes/cond.go (100%) rename {src/vendor => vendor}/golang.org/x/text/runes/runes.go (100%) rename {src/vendor => vendor}/golang.org/x/text/transform/transform.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/base.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/cldr.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/cldr_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/collate.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/collate_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/data_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/decode.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/examples_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/makexml.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/resolve.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/resolve_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/slice.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/slice_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/cldr/xml.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/composition.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/composition_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/example_iter_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/forminfo.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/forminfo_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/input.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/iter.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/iter_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/maketables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/norm_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/normalize.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/normalize_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/readwriter.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/readwriter_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/tables.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/transform.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/transform_test.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/trie.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/triegen.go (100%) rename {src/vendor => vendor}/golang.org/x/text/unicode/norm/ucd_test.go (100%) rename {src/vendor => vendor}/golang.org/x/tools/LICENSE (100%) rename {src/vendor => vendor}/golang.org/x/tools/PATENTS (100%) rename {src/vendor => vendor}/golang.org/x/tools/go/ast/astutil/enclosing.go (100%) rename {src/vendor => vendor}/golang.org/x/tools/go/ast/astutil/imports.go (100%) rename {src/vendor => vendor}/golang.org/x/tools/go/ast/astutil/util.go (100%) rename {src/vendor => vendor}/golang.org/x/tools/imports/fix.go (100%) rename {src/vendor => vendor}/golang.org/x/tools/imports/imports.go (100%) rename {src/vendor => vendor}/golang.org/x/tools/imports/mkindex.go (100%) rename {src/vendor => vendor}/golang.org/x/tools/imports/mkstdlib.go (100%) rename {src/vendor => vendor}/golang.org/x/tools/imports/sortimports.go (100%) rename {src/vendor => vendor}/golang.org/x/tools/imports/zstdlib.go (100%) rename {src/vendor => vendor}/gopkg.in/fatih/set.v0/.travis.yml (100%) rename {src/vendor => vendor}/gopkg.in/fatih/set.v0/LICENSE.md (100%) rename {src/vendor => vendor}/gopkg.in/fatih/set.v0/README.md (100%) rename {src/vendor => vendor}/gopkg.in/fatih/set.v0/set.go (100%) rename {src/vendor => vendor}/gopkg.in/fatih/set.v0/set_nots.go (100%) rename {src/vendor => vendor}/gopkg.in/fatih/set.v0/set_ts.go (100%) rename {src/vendor => vendor}/gopkg.in/karalabe/cookiejar.v2/LICENSE (100%) rename {src/vendor => vendor}/gopkg.in/karalabe/cookiejar.v2/collections/prque/prque.go (100%) rename {src/vendor => vendor}/gopkg.in/karalabe/cookiejar.v2/collections/prque/sstack.go (100%) rename {src/vendor => vendor}/gopkg.in/sourcemap.v1/.travis.yml (100%) rename {src/vendor => vendor}/gopkg.in/sourcemap.v1/Makefile (100%) rename {src/vendor => vendor}/gopkg.in/sourcemap.v1/README.md (100%) rename {src/vendor => vendor}/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go (100%) rename {src/vendor => vendor}/gopkg.in/sourcemap.v1/base64vlq/base64_vlq_test.go (100%) rename {src/vendor => vendor}/gopkg.in/sourcemap.v1/consumer.go (100%) rename {src/vendor => vendor}/gopkg.in/sourcemap.v1/consumer_test.go (100%) rename {src/vendor => vendor}/gopkg.in/sourcemap.v1/example_test.go (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/.gitignore (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/.travis.yml (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/CHANGELOG.md (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/LICENSE (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/README.md (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/app.go (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/appveyor.yml (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/category.go (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/cli.go (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/command.go (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/context.go (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/errors.go (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/flag.go (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/funcs.go (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/help.go (100%) rename {src/vendor => vendor}/gopkg.in/urfave/cli.v1/runtests (100%) diff --git a/src/types.go b/common/types.go similarity index 98% rename from src/types.go rename to common/types.go index 9b4cf458e..d9d7c35ef 100644 --- a/src/types.go +++ b/common/types.go @@ -1,4 +1,4 @@ -package main +package common import ( "github.com/ethereum/go-ethereum/les/status" diff --git a/common/utils.go b/common/utils.go new file mode 100644 index 000000000..23354ee0e --- /dev/null +++ b/common/utils.go @@ -0,0 +1,26 @@ +package common + +import ( + "io" + "os" +) + +func copyFile(dst, src string) error { + s, err := os.Open(src) + if err != nil { + return err + } + defer s.Close() + + d, err := os.Create(dst) + if err != nil { + return err + } + defer d.Close() + + if _, err := io.Copy(d, s); err != nil { + return err + } + + return nil +} diff --git a/src/extkeys/hdkey.go b/extkeys/hdkey.go similarity index 100% rename from src/extkeys/hdkey.go rename to extkeys/hdkey.go diff --git a/src/extkeys/hdkey_test.go b/extkeys/hdkey_test.go similarity index 98% rename from src/extkeys/hdkey_test.go rename to extkeys/hdkey_test.go index 495234347..913c04a55 100644 --- a/src/extkeys/hdkey_test.go +++ b/extkeys/hdkey_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/btcsuite/btcd/chaincfg" - "github.com/status-im/status-go/src/extkeys" + "github.com/status-im/status-go/extkeys" ) func TestBIP32Vectors(t *testing.T) { @@ -122,7 +122,7 @@ tests: } if !extKey.IsPrivate { - t.Errorf("Master node must feature private key") + t.Error("Master node must feature private key") continue } @@ -416,7 +416,7 @@ func TestErrors(t *testing.T) { } // Generate a new key and neuter it to a public extended key. - mnemonic := extkeys.NewMnemonic() + mnemonic := extkeys.NewMnemonic(extkeys.Salt) phrase, err := mnemonic.MnemonicPhrase(128, extkeys.EnglishLanguage) if err != nil { @@ -505,12 +505,12 @@ func TestBIP44ChildDerivation(t *testing.T) { extKey, err := extkeys.NewKeyFromString(keyString) if err != nil { - t.Errorf("NewKeyFromString: cannot create extended key") + t.Error("NewKeyFromString: cannot create extended key") } accounKey1, err := extKey.BIP44Child(extkeys.CoinTypeETH, 0) if err != nil { - t.Errorf("Error dering BIP44-compliant key") + t.Error("Error dering BIP44-compliant key") } if accounKey1.String() != derivedKey1String { t.Errorf("BIP44Child: key mismatch -- got: %v, want: %v", accounKey1.String(), derivedKey1String) @@ -519,7 +519,7 @@ func TestBIP44ChildDerivation(t *testing.T) { accounKey2, err := extKey.BIP44Child(extkeys.CoinTypeETH, 1) if err != nil { - t.Errorf("Error dering BIP44-compliant key") + t.Error("Error dering BIP44-compliant key") } if accounKey2.String() != derivedKey2String { t.Errorf("BIP44Child: key mismatch -- got: %v, want: %v", accounKey2.String(), derivedKey2String) diff --git a/src/extkeys/mnemonic.go b/extkeys/mnemonic.go similarity index 99% rename from src/extkeys/mnemonic.go rename to extkeys/mnemonic.go index b6e9fa23a..d96cf9292 100644 --- a/src/extkeys/mnemonic.go +++ b/extkeys/mnemonic.go @@ -64,10 +64,13 @@ type Mnemonic struct { wordLists [totalAvailableLanguages]*WordList } -func NewMnemonic() *Mnemonic { +func NewMnemonic(salt string) *Mnemonic { + if len(salt) == 0 { + salt = Salt + } mnemonic := &Mnemonic{ - salt: Salt, + salt: salt, } mnemonic.wordLists[EnglishLanguage] = &WordList{"abandon", "ability", "able", "about", "above", "absent", "absorb", "abstract", "absurd", "abuse", "access", "accident", "account", "accuse", "achieve", "acid", "acoustic", "acquire", "across", "act", "action", "actor", "actress", "actual", "adapt", "add", "addict", "address", "adjust", "admit", "adult", "advance", "advice", "aerobic", "affair", "afford", "afraid", "again", "age", "agent", "agree", "ahead", "aim", "air", "airport", "aisle", "alarm", "album", "alcohol", "alert", "alien", "all", "alley", "allow", "almost", "alone", "alpha", "already", "also", "alter", "always", "amateur", "amazing", "among", "amount", "amused", "analyst", "anchor", "ancient", "anger", "angle", "angry", "animal", "ankle", "announce", "annual", "another", "answer", "antenna", "antique", "anxiety", "any", "apart", "apology", "appear", "apple", "approve", "april", "arch", "arctic", "area", "arena", "argue", "arm", "armed", "armor", "army", "around", "arrange", "arrest", "arrive", "arrow", "art", "artefact", "artist", "artwork", "ask", "aspect", "assault", "asset", "assist", "assume", "asthma", "athlete", "atom", "attack", "attend", "attitude", "attract", "auction", "audit", "august", "aunt", "author", "auto", "autumn", "average", "avocado", "avoid", "awake", "aware", "away", "awesome", "awful", "awkward", "axis", "baby", "bachelor", "bacon", "badge", "bag", "balance", "balcony", "ball", "bamboo", "banana", "banner", "bar", "barely", "bargain", "barrel", "base", "basic", "basket", "battle", "beach", "bean", "beauty", "because", "become", "beef", "before", "begin", "behave", "behind", "believe", "below", "belt", "bench", "benefit", "best", "betray", "better", "between", "beyond", "bicycle", "bid", "bike", "bind", "biology", "bird", "birth", "bitter", "black", "blade", "blame", "blanket", "blast", "bleak", "bless", "blind", "blood", "blossom", "blouse", "blue", "blur", "blush", "board", "boat", "body", "boil", "bomb", "bone", "bonus", "book", "boost", "border", "boring", "borrow", "boss", "bottom", "bounce", "box", "boy", "bracket", "brain", "brand", "brass", "brave", "bread", "breeze", "brick", "bridge", "brief", "bright", "bring", "brisk", "broccoli", "broken", "bronze", "broom", "brother", "brown", "brush", "bubble", "buddy", "budget", "buffalo", "build", "bulb", "bulk", "bullet", "bundle", "bunker", "burden", "burger", "burst", "bus", "business", "busy", "butter", "buyer", "buzz", "cabbage", "cabin", "cable", "cactus", "cage", "cake", "call", "calm", "camera", "camp", "can", "canal", "cancel", "candy", "cannon", "canoe", "canvas", "canyon", "capable", "capital", "captain", "car", "carbon", "card", "cargo", "carpet", "carry", "cart", "case", "cash", "casino", "castle", "casual", "cat", "catalog", "catch", "category", "cattle", "caught", "cause", "caution", "cave", "ceiling", "celery", "cement", "census", "century", "cereal", "certain", "chair", "chalk", "champion", "change", "chaos", "chapter", "charge", "chase", "chat", "cheap", "check", "cheese", "chef", "cherry", "chest", "chicken", "chief", "child", "chimney", "choice", "choose", "chronic", "chuckle", "chunk", "churn", "cigar", "cinnamon", "circle", "citizen", "city", "civil", "claim", "clap", "clarify", "claw", "clay", "clean", "clerk", "clever", "click", "client", "cliff", "climb", "clinic", "clip", "clock", "clog", "close", "cloth", "cloud", "clown", "club", "clump", "cluster", "clutch", "coach", "coast", "coconut", "code", "coffee", "coil", "coin", "collect", "color", "column", "combine", "come", "comfort", "comic", "common", "company", "concert", "conduct", "confirm", "congress", "connect", "consider", "control", "convince", "cook", "cool", "copper", "copy", "coral", "core", "corn", "correct", "cost", "cotton", "couch", "country", "couple", "course", "cousin", "cover", "coyote", "crack", "cradle", "craft", "cram", "crane", "crash", "crater", "crawl", "crazy", "cream", "credit", "creek", "crew", "cricket", "crime", "crisp", "critic", "crop", "cross", "crouch", "crowd", "crucial", "cruel", "cruise", "crumble", "crunch", "crush", "cry", "crystal", "cube", "culture", "cup", "cupboard", "curious", "current", "curtain", "curve", "cushion", "custom", "cute", "cycle", "dad", "damage", "damp", "dance", "danger", "daring", "dash", "daughter", "dawn", "day", "deal", "debate", "debris", "decade", "december", "decide", "decline", "decorate", "decrease", "deer", "defense", "define", "defy", "degree", "delay", "deliver", "demand", "demise", "denial", "dentist", "deny", "depart", "depend", "deposit", "depth", "deputy", "derive", "describe", "desert", "design", "desk", "despair", "destroy", "detail", "detect", "develop", "device", "devote", "diagram", "dial", "diamond", "diary", "dice", "diesel", "diet", "differ", "digital", "dignity", "dilemma", "dinner", "dinosaur", "direct", "dirt", "disagree", "discover", "disease", "dish", "dismiss", "disorder", "display", "distance", "divert", "divide", "divorce", "dizzy", "doctor", "document", "dog", "doll", "dolphin", "domain", "donate", "donkey", "donor", "door", "dose", "double", "dove", "draft", "dragon", "drama", "drastic", "draw", "dream", "dress", "drift", "drill", "drink", "drip", "drive", "drop", "drum", "dry", "duck", "dumb", "dune", "during", "dust", "dutch", "duty", "dwarf", "dynamic", "eager", "eagle", "early", "earn", "earth", "easily", "east", "easy", "echo", "ecology", "economy", "edge", "edit", "educate", "effort", "egg", "eight", "either", "elbow", "elder", "electric", "elegant", "element", "elephant", "elevator", "elite", "else", "embark", "embody", "embrace", "emerge", "emotion", "employ", "empower", "empty", "enable", "enact", "end", "endless", "endorse", "enemy", "energy", "enforce", "engage", "engine", "enhance", "enjoy", "enlist", "enough", "enrich", "enroll", "ensure", "enter", "entire", "entry", "envelope", "episode", "equal", "equip", "era", "erase", "erode", "erosion", "error", "erupt", "escape", "essay", "essence", "estate", "eternal", "ethics", "evidence", "evil", "evoke", "evolve", "exact", "example", "excess", "exchange", "excite", "exclude", "excuse", "execute", "exercise", "exhaust", "exhibit", "exile", "exist", "exit", "exotic", "expand", "expect", "expire", "explain", "expose", "express", "extend", "extra", "eye", "eyebrow", "fabric", "face", "faculty", "fade", "faint", "faith", "fall", "false", "fame", "family", "famous", "fan", "fancy", "fantasy", "farm", "fashion", "fat", "fatal", "father", "fatigue", "fault", "favorite", "feature", "february", "federal", "fee", "feed", "feel", "female", "fence", "festival", "fetch", "fever", "few", "fiber", "fiction", "field", "figure", "file", "film", "filter", "final", "find", "fine", "finger", "finish", "fire", "firm", "first", "fiscal", "fish", "fit", "fitness", "fix", "flag", "flame", "flash", "flat", "flavor", "flee", "flight", "flip", "float", "flock", "floor", "flower", "fluid", "flush", "fly", "foam", "focus", "fog", "foil", "fold", "follow", "food", "foot", "force", "forest", "forget", "fork", "fortune", "forum", "forward", "fossil", "foster", "found", "fox", "fragile", "frame", "frequent", "fresh", "friend", "fringe", "frog", "front", "frost", "frown", "frozen", "fruit", "fuel", "fun", "funny", "furnace", "fury", "future", "gadget", "gain", "galaxy", "gallery", "game", "gap", "garage", "garbage", "garden", "garlic", "garment", "gas", "gasp", "gate", "gather", "gauge", "gaze", "general", "genius", "genre", "gentle", "genuine", "gesture", "ghost", "giant", "gift", "giggle", "ginger", "giraffe", "girl", "give", "glad", "glance", "glare", "glass", "glide", "glimpse", "globe", "gloom", "glory", "glove", "glow", "glue", "goat", "goddess", "gold", "good", "goose", "gorilla", "gospel", "gossip", "govern", "gown", "grab", "grace", "grain", "grant", "grape", "grass", "gravity", "great", "green", "grid", "grief", "grit", "grocery", "group", "grow", "grunt", "guard", "guess", "guide", "guilt", "guitar", "gun", "gym", "habit", "hair", "half", "hammer", "hamster", "hand", "happy", "harbor", "hard", "harsh", "harvest", "hat", "have", "hawk", "hazard", "head", "health", "heart", "heavy", "hedgehog", "height", "hello", "helmet", "help", "hen", "hero", "hidden", "high", "hill", "hint", "hip", "hire", "history", "hobby", "hockey", "hold", "hole", "holiday", "hollow", "home", "honey", "hood", "hope", "horn", "horror", "horse", "hospital", "host", "hotel", "hour", "hover", "hub", "huge", "human", "humble", "humor", "hundred", "hungry", "hunt", "hurdle", "hurry", "hurt", "husband", "hybrid", "ice", "icon", "idea", "identify", "idle", "ignore", "ill", "illegal", "illness", "image", "imitate", "immense", "immune", "impact", "impose", "improve", "impulse", "inch", "include", "income", "increase", "index", "indicate", "indoor", "industry", "infant", "inflict", "inform", "inhale", "inherit", "initial", "inject", "injury", "inmate", "inner", "innocent", "input", "inquiry", "insane", "insect", "inside", "inspire", "install", "intact", "interest", "into", "invest", "invite", "involve", "iron", "island", "isolate", "issue", "item", "ivory", "jacket", "jaguar", "jar", "jazz", "jealous", "jeans", "jelly", "jewel", "job", "join", "joke", "journey", "joy", "judge", "juice", "jump", "jungle", "junior", "junk", "just", "kangaroo", "keen", "keep", "ketchup", "key", "kick", "kid", "kidney", "kind", "kingdom", "kiss", "kit", "kitchen", "kite", "kitten", "kiwi", "knee", "knife", "knock", "know", "lab", "label", "labor", "ladder", "lady", "lake", "lamp", "language", "laptop", "large", "later", "latin", "laugh", "laundry", "lava", "law", "lawn", "lawsuit", "layer", "lazy", "leader", "leaf", "learn", "leave", "lecture", "left", "leg", "legal", "legend", "leisure", "lemon", "lend", "length", "lens", "leopard", "lesson", "letter", "level", "liar", "liberty", "library", "license", "life", "lift", "light", "like", "limb", "limit", "link", "lion", "liquid", "list", "little", "live", "lizard", "load", "loan", "lobster", "local", "lock", "logic", "lonely", "long", "loop", "lottery", "loud", "lounge", "love", "loyal", "lucky", "luggage", "lumber", "lunar", "lunch", "luxury", "lyrics", "machine", "mad", "magic", "magnet", "maid", "mail", "main", "major", "make", "mammal", "man", "manage", "mandate", "mango", "mansion", "manual", "maple", "marble", "march", "margin", "marine", "market", "marriage", "mask", "mass", "master", "match", "material", "math", "matrix", "matter", "maximum", "maze", "meadow", "mean", "measure", "meat", "mechanic", "medal", "media", "melody", "melt", "member", "memory", "mention", "menu", "mercy", "merge", "merit", "merry", "mesh", "message", "metal", "method", "middle", "midnight", "milk", "million", "mimic", "mind", "minimum", "minor", "minute", "miracle", "mirror", "misery", "miss", "mistake", "mix", "mixed", "mixture", "mobile", "model", "modify", "mom", "moment", "monitor", "monkey", "monster", "month", "moon", "moral", "more", "morning", "mosquito", "mother", "motion", "motor", "mountain", "mouse", "move", "movie", "much", "muffin", "mule", "multiply", "muscle", "museum", "mushroom", "music", "must", "mutual", "myself", "mystery", "myth", "naive", "name", "napkin", "narrow", "nasty", "nation", "nature", "near", "neck", "need", "negative", "neglect", "neither", "nephew", "nerve", "nest", "net", "network", "neutral", "never", "news", "next", "nice", "night", "noble", "noise", "nominee", "noodle", "normal", "north", "nose", "notable", "note", "nothing", "notice", "novel", "now", "nuclear", "number", "nurse", "nut", "oak", "obey", "object", "oblige", "obscure", "observe", "obtain", "obvious", "occur", "ocean", "october", "odor", "off", "offer", "office", "often", "oil", "okay", "old", "olive", "olympic", "omit", "once", "one", "onion", "online", "only", "open", "opera", "opinion", "oppose", "option", "orange", "orbit", "orchard", "order", "ordinary", "organ", "orient", "original", "orphan", "ostrich", "other", "outdoor", "outer", "output", "outside", "oval", "oven", "over", "own", "owner", "oxygen", "oyster", "ozone", "pact", "paddle", "page", "pair", "palace", "palm", "panda", "panel", "panic", "panther", "paper", "parade", "parent", "park", "parrot", "party", "pass", "patch", "path", "patient", "patrol", "pattern", "pause", "pave", "payment", "peace", "peanut", "pear", "peasant", "pelican", "pen", "penalty", "pencil", "people", "pepper", "perfect", "permit", "person", "pet", "phone", "photo", "phrase", "physical", "piano", "picnic", "picture", "piece", "pig", "pigeon", "pill", "pilot", "pink", "pioneer", "pipe", "pistol", "pitch", "pizza", "place", "planet", "plastic", "plate", "play", "please", "pledge", "pluck", "plug", "plunge", "poem", "poet", "point", "polar", "pole", "police", "pond", "pony", "pool", "popular", "portion", "position", "possible", "post", "potato", "pottery", "poverty", "powder", "power", "practice", "praise", "predict", "prefer", "prepare", "present", "pretty", "prevent", "price", "pride", "primary", "print", "priority", "prison", "private", "prize", "problem", "process", "produce", "profit", "program", "project", "promote", "proof", "property", "prosper", "protect", "proud", "provide", "public", "pudding", "pull", "pulp", "pulse", "pumpkin", "punch", "pupil", "puppy", "purchase", "purity", "purpose", "purse", "push", "put", "puzzle", "pyramid", "quality", "quantum", "quarter", "question", "quick", "quit", "quiz", "quote", "rabbit", "raccoon", "race", "rack", "radar", "radio", "rail", "rain", "raise", "rally", "ramp", "ranch", "random", "range", "rapid", "rare", "rate", "rather", "raven", "raw", "razor", "ready", "real", "reason", "rebel", "rebuild", "recall", "receive", "recipe", "record", "recycle", "reduce", "reflect", "reform", "refuse", "region", "regret", "regular", "reject", "relax", "release", "relief", "rely", "remain", "remember", "remind", "remove", "render", "renew", "rent", "reopen", "repair", "repeat", "replace", "report", "require", "rescue", "resemble", "resist", "resource", "response", "result", "retire", "retreat", "return", "reunion", "reveal", "review", "reward", "rhythm", "rib", "ribbon", "rice", "rich", "ride", "ridge", "rifle", "right", "rigid", "ring", "riot", "ripple", "risk", "ritual", "rival", "river", "road", "roast", "robot", "robust", "rocket", "romance", "roof", "rookie", "room", "rose", "rotate", "rough", "round", "route", "royal", "rubber", "rude", "rug", "rule", "run", "runway", "rural", "sad", "saddle", "sadness", "safe", "sail", "salad", "salmon", "salon", "salt", "salute", "same", "sample", "sand", "satisfy", "satoshi", "sauce", "sausage", "save", "say", "scale", "scan", "scare", "scatter", "scene", "scheme", "school", "science", "scissors", "scorpion", "scout", "scrap", "screen", "script", "scrub", "sea", "search", "season", "seat", "second", "secret", "section", "security", "seed", "seek", "segment", "select", "sell", "seminar", "senior", "sense", "sentence", "series", "service", "session", "settle", "setup", "seven", "shadow", "shaft", "shallow", "share", "shed", "shell", "sheriff", "shield", "shift", "shine", "ship", "shiver", "shock", "shoe", "shoot", "shop", "short", "shoulder", "shove", "shrimp", "shrug", "shuffle", "shy", "sibling", "sick", "side", "siege", "sight", "sign", "silent", "silk", "silly", "silver", "similar", "simple", "since", "sing", "siren", "sister", "situate", "six", "size", "skate", "sketch", "ski", "skill", "skin", "skirt", "skull", "slab", "slam", "sleep", "slender", "slice", "slide", "slight", "slim", "slogan", "slot", "slow", "slush", "small", "smart", "smile", "smoke", "smooth", "snack", "snake", "snap", "sniff", "snow", "soap", "soccer", "social", "sock", "soda", "soft", "solar", "soldier", "solid", "solution", "solve", "someone", "song", "soon", "sorry", "sort", "soul", "sound", "soup", "source", "south", "space", "spare", "spatial", "spawn", "speak", "special", "speed", "spell", "spend", "sphere", "spice", "spider", "spike", "spin", "spirit", "split", "spoil", "sponsor", "spoon", "sport", "spot", "spray", "spread", "spring", "spy", "square", "squeeze", "squirrel", "stable", "stadium", "staff", "stage", "stairs", "stamp", "stand", "start", "state", "stay", "steak", "steel", "stem", "step", "stereo", "stick", "still", "sting", "stock", "stomach", "stone", "stool", "story", "stove", "strategy", "street", "strike", "strong", "struggle", "student", "stuff", "stumble", "style", "subject", "submit", "subway", "success", "such", "sudden", "suffer", "sugar", "suggest", "suit", "summer", "sun", "sunny", "sunset", "super", "supply", "supreme", "sure", "surface", "surge", "surprise", "surround", "survey", "suspect", "sustain", "swallow", "swamp", "swap", "swarm", "swear", "sweet", "swift", "swim", "swing", "switch", "sword", "symbol", "symptom", "syrup", "system", "table", "tackle", "tag", "tail", "talent", "talk", "tank", "tape", "target", "task", "taste", "tattoo", "taxi", "teach", "team", "tell", "ten", "tenant", "tennis", "tent", "term", "test", "text", "thank", "that", "theme", "then", "theory", "there", "they", "thing", "this", "thought", "three", "thrive", "throw", "thumb", "thunder", "ticket", "tide", "tiger", "tilt", "timber", "time", "tiny", "tip", "tired", "tissue", "title", "toast", "tobacco", "today", "toddler", "toe", "together", "toilet", "token", "tomato", "tomorrow", "tone", "tongue", "tonight", "tool", "tooth", "top", "topic", "topple", "torch", "tornado", "tortoise", "toss", "total", "tourist", "toward", "tower", "town", "toy", "track", "trade", "traffic", "tragic", "train", "transfer", "trap", "trash", "travel", "tray", "treat", "tree", "trend", "trial", "tribe", "trick", "trigger", "trim", "trip", "trophy", "trouble", "truck", "true", "truly", "trumpet", "trust", "truth", "try", "tube", "tuition", "tumble", "tuna", "tunnel", "turkey", "turn", "turtle", "twelve", "twenty", "twice", "twin", "twist", "two", "type", "typical", "ugly", "umbrella", "unable", "unaware", "uncle", "uncover", "under", "undo", "unfair", "unfold", "unhappy", "uniform", "unique", "unit", "universe", "unknown", "unlock", "until", "unusual", "unveil", "update", "upgrade", "uphold", "upon", "upper", "upset", "urban", "urge", "usage", "use", "used", "useful", "useless", "usual", "utility", "vacant", "vacuum", "vague", "valid", "valley", "valve", "van", "vanish", "vapor", "various", "vast", "vault", "vehicle", "velvet", "vendor", "venture", "venue", "verb", "verify", "version", "very", "vessel", "veteran", "viable", "vibrant", "vicious", "victory", "video", "view", "village", "vintage", "violin", "virtual", "virus", "visa", "visit", "visual", "vital", "vivid", "vocal", "voice", "void", "volcano", "volume", "vote", "voyage", "wage", "wagon", "wait", "walk", "wall", "walnut", "want", "warfare", "warm", "warrior", "wash", "wasp", "waste", "water", "wave", "way", "wealth", "weapon", "wear", "weasel", "weather", "web", "wedding", "weekend", "weird", "welcome", "west", "wet", "whale", "what", "wheat", "wheel", "when", "where", "whip", "whisper", "wide", "width", "wife", "wild", "will", "win", "window", "wine", "wing", "wink", "winner", "winter", "wire", "wisdom", "wise", "wish", "witness", "wolf", "woman", "wonder", "wood", "wool", "word", "work", "world", "worry", "worth", "wrap", "wreck", "wrestle", "wrist", "write", "wrong", "yard", "year", "yellow", "you", "young", "youth", "zebra", "zero", "zone", "zoo"} diff --git a/src/extkeys/mnemonic_test.go b/extkeys/mnemonic_test.go similarity index 87% rename from src/extkeys/mnemonic_test.go rename to extkeys/mnemonic_test.go index 8fe966fbb..ca25ba168 100644 --- a/src/extkeys/mnemonic_test.go +++ b/extkeys/mnemonic_test.go @@ -1,10 +1,11 @@ -package extkeys +package extkeys_test import ( "encoding/json" "fmt" "os" "testing" + "github.com/status-im/status-go/extkeys" ) type VectorsFile struct { @@ -19,13 +20,13 @@ type Vector struct { // TestMnemonicPhrase func TestMnemonicPhrase(t *testing.T) { - mnemonic := NewMnemonic() + mnemonic := extkeys.NewMnemonic(extkeys.Salt) // test mnemonic generation - t.Logf("Test mnemonic generation:") + t.Log("Test mnemonic generation:") for _, language := range mnemonic.AvailableLanguages() { phrase, err := mnemonic.MnemonicPhrase(128, language) - t.Logf("Mnemonic (%s): %s", Languages[language], phrase) + t.Logf("Mnemonic (%s): %s", extkeys.Languages[language], phrase) if err != nil { t.Errorf("Test failed: could not create seed: %s", err) @@ -42,11 +43,11 @@ func TestMnemonicPhrase(t *testing.T) { t.Error(err) } - t.Logf("Test against pre-computed seed vectors:") + t.Log("Test against pre-computed seed vectors:") stats := map[string]int{} for _, vector := range vectorsFile.vectors { stats[vector.language] += 1 - mnemonic.salt = vector.salt + mnemonic := extkeys.NewMnemonic(vector.salt) seed := mnemonic.MnemonicSeed(vector.mnemonic, vector.password) if fmt.Sprintf("%x", seed) != vector.seed { t.Errorf("Test failed (%s): incorrect seed (%x) generated (expected: %s)", vector.language, seed, vector.seed) diff --git a/src/extkeys/mnemonic_vectors.json b/extkeys/mnemonic_vectors.json similarity index 100% rename from src/extkeys/mnemonic_vectors.json rename to extkeys/mnemonic_vectors.json diff --git a/src/extkeys/utils.go b/extkeys/utils.go similarity index 100% rename from src/extkeys/utils.go rename to extkeys/utils.go diff --git a/src/main.go b/src/main.go index 76d8b7eb6..5f275bf03 100644 --- a/src/main.go +++ b/src/main.go @@ -1,177 +1,14 @@ package main import ( - "errors" - "flag" "fmt" - "github.com/ethereum/go-ethereum/accounts" - "github.com/ethereum/go-ethereum/cmd/utils" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/les" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" - "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/release" - "github.com/ethereum/go-ethereum/rlp" - "github.com/ethereum/go-ethereum/rpc" - "github.com/ethereum/go-ethereum/whisper" - "gopkg.in/urfave/cli.v1" - "io" - "os" - "path" - "path/filepath" - "runtime" -) - -const ( - clientIdentifier = "Geth" // Client identifier to advertise over the network - versionMajor = 1 // Major version component of the current release - versionMinor = 5 // Minor version component of the current release - versionPatch = 0 // Patch version component of the current release - versionMeta = "unstable" // Version metadata to append to the version string - - versionOracle = "0xfa7b9770ca4cb04296cac84f37736d4041251cdf" // Ethereum address of the Geth release oracle ) var ( - vString string // Combined textual representation of the version - rConfig release.Config // Structured version information and release oracle config - currentNode *node.Node // currently running geth node - c *cli.Context // the CLI context used to start the geth node - accountSync *[]node.Service // the object used to sync accounts between geth services - lightEthereum *les.LightEthereum // LES service - accountManager *accounts.Manager // the account manager attached to the currentNode - selectedAddress string // address of the account that was processed during the last call to SelectAccount() - whisperService *whisper.Whisper // whisper service - datadir string // data directory for geth - rpcport int = 8545 // RPC port (replaced in unit tests) - client rpc.Client - gitCommit = "rely on linker: -ldflags -X main.GitCommit" - buildStamp = "rely on linker: -ldflags -X main.buildStamp" -) - -var ( - ErrDataDirPreprocessingFailed = errors.New("Failed to pre-process data directory") + gitCommit = "rely on linker: -ldflags -X main.GitCommit" + buildStamp = "rely on linker: -ldflags -X main.buildStamp" ) func main() { fmt.Printf("Status\nGit Commit: %s\nBuild Time: %s\n", gitCommit, buildStamp) } - -// MakeNode create a geth node entity -func MakeNode(inputDir string) *node.Node { - - datadir := inputDir - - // TODO remove admin rpcapi flag - set := flag.NewFlagSet("test", 0) - set.Bool("lightkdf", true, "Reduce key-derivation RAM & CPU usage at some expense of KDF strength") - set.Bool("shh", true, "whisper") - set.Bool("light", true, "disable eth") - set.Bool("testnet", true, "light test network") - set.Bool("rpc", true, "enable rpc") - set.String("rpcaddr", "localhost", "host for RPC") - set.Int("rpcport", rpcport, "rpc port") - set.String("rpccorsdomain", "*", "allow all domains") - set.String("verbosity", "3", "verbosity level") - set.String("rpcapi", "db,eth,net,web3,shh,personal,admin", "rpc api(s)") - set.String("datadir", datadir, "data directory for geth") - set.String("logdir", datadir, "log dir for glog") - c = cli.NewContext(nil, set, nil) - - // Construct the textual version string from the individual components - vString = fmt.Sprintf("%d.%d.%d", versionMajor, versionMinor, versionPatch) - - // Construct the version release oracle configuration - rConfig.Oracle = common.HexToAddress(versionOracle) - - rConfig.Major = uint32(versionMajor) - rConfig.Minor = uint32(versionMinor) - rConfig.Patch = uint32(versionPatch) - - utils.DebugSetup(c) - currentNode, accountSync = utils.MakeSystemNode(clientIdentifier, vString, rConfig, makeDefaultExtra(), c) - - return currentNode - -} - -// StartNode starts a geth node entity -func RunNode(nodeIn *node.Node) { - utils.StartNode(nodeIn) - - if err := nodeIn.Service(&accountManager); err != nil { - glog.V(logger.Warn).Infoln("cannot get account manager:", err) - } - if err := nodeIn.Service(&whisperService); err != nil { - glog.V(logger.Warn).Infoln("cannot get whisper service:", err) - } - if err := nodeIn.Service(&lightEthereum); err != nil { - glog.V(logger.Warn).Infoln("cannot get light ethereum service:", err) - } - lightEthereum.StatusBackend.SetTransactionQueueHandler(onSendTransactionRequest) - - client, _ = nodeIn.Attach() - nodeIn.Wait() -} - -func makeDefaultExtra() []byte { - var clientInfo = struct { - Version uint - Name string - GoVersion string - Os string - }{uint(versionMajor<<16 | versionMinor<<8 | versionPatch), clientIdentifier, runtime.Version(), runtime.GOOS} - extra, err := rlp.EncodeToBytes(clientInfo) - if err != nil { - glog.V(logger.Warn).Infoln("error setting canonical miner information:", err) - } - - if uint64(len(extra)) > params.MaximumExtraDataSize.Uint64() { - glog.V(logger.Warn).Infoln("error setting canonical miner information: extra exceeds", params.MaximumExtraDataSize) - glog.V(logger.Debug).Infof("extra: %x\n", extra) - return nil - } - return extra -} - -func preprocessDataDir(dataDir string) (string, error) { - testDataDir := path.Join(dataDir, "testnet", "keystore") - if _, err := os.Stat(testDataDir); os.IsNotExist(err) { - if err := os.MkdirAll(testDataDir, 0755); err != nil { - return dataDir, ErrDataDirPreprocessingFailed - } - } - - // copy over static peer nodes list (LES auto-discovery is not stable yet) - dst := filepath.Join(dataDir, "testnet", "static-nodes.json") - if _, err := os.Stat(dst); os.IsNotExist(err) { - src := filepath.Join("data", "static-nodes.json") - if err := copyFile(dst, src); err != nil { - return dataDir, err - } - } - - return dataDir, nil -} - -func copyFile(dst, src string) error { - s, err := os.Open(src) - if err != nil { - return err - } - defer s.Close() - - d, err := os.Create(dst) - if err != nil { - return err - } - defer d.Close() - - if _, err := io.Copy(d, s); err != nil { - return err - } - - return nil -} diff --git a/src/node.go b/src/node.go new file mode 100644 index 000000000..c1af626c5 --- /dev/null +++ b/src/node.go @@ -0,0 +1,162 @@ +package main + +import ( + "errors" + "flag" + "fmt" + "os" + "path" + "path/filepath" + "runtime" + + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/les" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/release" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rpc" + "github.com/ethereum/go-ethereum/whisper" + "gopkg.in/urfave/cli.v1" +) + +const ( + clientIdentifier = "Geth" // Client identifier to advertise over the network + versionMajor = 1 // Major version component of the current release + versionMinor = 5 // Minor version component of the current release + versionPatch = 0 // Patch version component of the current release + versionMeta = "unstable" // Version metadata to append to the version string + + versionOracle = "0xfa7b9770ca4cb04296cac84f37736d4041251cdf" // Ethereum address of the Geth release oracle +) + +var ( + vString string // Combined textual representation of the version + rConfig release.Config // Structured version information and release oracle config + currentNode *node.Node // currently running geth node + c *cli.Context // the CLI context used to start the geth node + lightEthereum *les.LightEthereum // LES service + accountManager *accounts.Manager // the account manager attached to the currentNode + selectedAddress string // address of the account that was processed during the last call to SelectAccount() + whisperService *whisper.Whisper // whisper service + datadir string // data directory for geth + rpcport int = 8545 // RPC port (replaced in unit tests) + client *rpc.Client +) + +var ( + ErrDataDirPreprocessingFailed = errors.New("Failed to pre-process data directory") +) + +// MakeNode create a geth node entity +func MakeNode(inputDir string) *node.Node { + + datadir := inputDir + + // TODO remove admin rpcapi flag + set := flag.NewFlagSet("test", 0) + set.Bool("lightkdf", true, "Reduce key-derivation RAM & CPU usage at some expense of KDF strength") + set.Bool("shh", true, "whisper") + set.Bool("light", true, "disable eth") + set.Bool("testnet", true, "light test network") + set.Bool("rpc", true, "enable rpc") + set.String("rpcaddr", "localhost", "host for RPC") + set.Int("rpcport", rpcport, "rpc port") + set.String("rpccorsdomain", "*", "allow all domains") + set.String("verbosity", "3", "verbosity level") + set.String("rpcapi", "db,eth,net,web3,shh,personal,admin", "rpc api(s)") + set.String("datadir", datadir, "data directory for geth") + set.String("logdir", datadir, "log dir for glog") + c = cli.NewContext(nil, set, nil) + + // Construct the textual version string from the individual components + vString = fmt.Sprintf("%d.%d.%d", versionMajor, versionMinor, versionPatch) + + // Construct the version release oracle configuration + rConfig.Oracle = common.HexToAddress(versionOracle) + + rConfig.Major = uint32(versionMajor) + rConfig.Minor = uint32(versionMinor) + rConfig.Patch = uint32(versionPatch) + + utils.DebugSetup(c) + currentNode = makeNode(c, clientIdentifier, vString) + + return currentNode + +} + +func makeNode(ctx *cli.Context, name, version string) *node.Node { + nodeIn := utils.MakeNode(ctx, name, version) + utils.RegisterEthService(ctx, nodeIn, rConfig, makeDefaultExtra()) + // Whisper must be explicitly enabled, but is auto-enabled in --dev mode. + shhEnabled := ctx.GlobalBool(utils.WhisperEnabledFlag.Name) + shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DevModeFlag.Name) + if shhEnabled || shhAutoEnabled { + utils.RegisterShhService(nodeIn) + } + return nodeIn +} + +// StartNode starts a geth node entity +func RunNode(nodeIn *node.Node) { + utils.StartNode(nodeIn) + + if err := nodeIn.Service(&accountManager); err != nil { + glog.V(logger.Warn).Infoln("cannot get account manager:", err) + } + if err := nodeIn.Service(&whisperService); err != nil { + glog.V(logger.Warn).Infoln("cannot get whisper service:", err) + } + if err := nodeIn.Service(&lightEthereum); err != nil { + glog.V(logger.Warn).Infoln("cannot get light ethereum service:", err) + } + lightEthereum.StatusBackend.SetTransactionQueueHandler(onSendTransactionRequest) + + client, _ = nodeIn.Attach() + nodeIn.Wait() +} + +func makeDefaultExtra() []byte { + var clientInfo = struct { + Version uint + Name string + GoVersion string + Os string + }{uint(versionMajor<<16 | versionMinor<<8 | versionPatch), clientIdentifier, runtime.Version(), runtime.GOOS} + extra, err := rlp.EncodeToBytes(clientInfo) + if err != nil { + glog.V(logger.Warn).Infoln("error setting canonical miner information:", err) + } + + if uint64(len(extra)) > params.MaximumExtraDataSize.Uint64() { + glog.V(logger.Warn).Infoln("error setting canonical miner information: extra exceeds", params.MaximumExtraDataSize) + glog.V(logger.Debug).Infof("extra: %x\n", extra) + return nil + } + return extra +} + +func preprocessDataDir(dataDir string) (string, error) { + testDataDir := path.Join(dataDir, "testnet", "keystore") + if _, err := os.Stat(testDataDir); os.IsNotExist(err) { + if err := os.MkdirAll(testDataDir, 0755); err != nil { + return dataDir, ErrDataDirPreprocessingFailed + } + } + + // copy over static peer nodes list (LES auto-discovery is not stable yet) + dst := filepath.Join(dataDir, "testnet", "static-nodes.json") + if _, err := os.Stat(dst); os.IsNotExist(err) { + src := filepath.Join("data", "static-nodes.json") + if err := copyFile(dst, src); err != nil { + return dataDir, err + } + } + + return dataDir, nil +} diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/remote.go b/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/remote.go deleted file mode 100644 index 4793143e4..000000000 --- a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/remote.go +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright 2016 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package backends - -import ( - "encoding/json" - "fmt" - "math/big" - "sync" - "sync/atomic" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/rlp" - "github.com/ethereum/go-ethereum/rpc" - "golang.org/x/net/context" -) - -// This nil assignment ensures compile time that rpcBackend implements bind.ContractBackend. -var _ bind.ContractBackend = (*rpcBackend)(nil) - -// rpcBackend implements bind.ContractBackend, and acts as the data provider to -// Ethereum contracts bound to Go structs. It uses an RPC connection to delegate -// all its functionality. -// -// Note: The current implementation is a blocking one. This should be replaced -// by a proper async version when a real RPC client is created. -type rpcBackend struct { - client rpc.Client // RPC client connection to interact with an API server - autoid uint32 // ID number to use for the next API request - lock sync.Mutex // Singleton access until we get to request multiplexing -} - -// NewRPCBackend creates a new binding backend to an RPC provider that can be -// used to interact with remote contracts. -func NewRPCBackend(client rpc.Client) bind.ContractBackend { - return &rpcBackend{ - client: client, - } -} - -// request is a JSON RPC request package assembled internally from the client -// method calls. -type request struct { - JSONRPC string `json:"jsonrpc"` // Version of the JSON RPC protocol, always set to 2.0 - ID int `json:"id"` // Auto incrementing ID number for this request - Method string `json:"method"` // Remote procedure name to invoke on the server - Params []interface{} `json:"params"` // List of parameters to pass through (keep types simple) -} - -// response is a JSON RPC response package sent back from the API server. -type response struct { - JSONRPC string `json:"jsonrpc"` // Version of the JSON RPC protocol, always set to 2.0 - ID int `json:"id"` // Auto incrementing ID number for this request - Error *failure `json:"error"` // Any error returned by the remote side - Result json.RawMessage `json:"result"` // Whatever the remote side sends us in reply -} - -// failure is a JSON RPC response error field sent back from the API server. -type failure struct { - Code int `json:"code"` // JSON RPC error code associated with the failure - Message string `json:"message"` // Specific error message of the failure -} - -// request forwards an API request to the RPC server, and parses the response. -// -// This is currently painfully non-concurrent, but it will have to do until we -// find the time for niceties like this :P -func (b *rpcBackend) request(ctx context.Context, method string, params []interface{}) (json.RawMessage, error) { - b.lock.Lock() - defer b.lock.Unlock() - - if ctx == nil { - ctx = context.Background() - } - - // Ugly hack to serialize an empty list properly - if params == nil { - params = []interface{}{} - } - // Assemble the request object - reqID := int(atomic.AddUint32(&b.autoid, 1)) - req := &request{ - JSONRPC: "2.0", - ID: reqID, - Method: method, - Params: params, - } - if err := b.client.Send(req); err != nil { - return nil, err - } - res := new(response) - errc := make(chan error, 1) - go func() { - errc <- b.client.Recv(res) - }() - select { - case err := <-errc: - if err != nil { - return nil, err - } - case <-ctx.Done(): - return nil, ctx.Err() - } - if res.Error != nil { - if res.Error.Message == bind.ErrNoCode.Error() { - return nil, bind.ErrNoCode - } - return nil, fmt.Errorf("remote error: %s", res.Error.Message) - } - return res.Result, nil -} - -// HasCode implements ContractVerifier.HasCode by retrieving any code associated -// with the contract from the remote node, and checking its size. -func (b *rpcBackend) HasCode(ctx context.Context, contract common.Address, pending bool) (bool, error) { - // Execute the RPC code retrieval - block := "latest" - if pending { - block = "pending" - } - res, err := b.request(ctx, "eth_getCode", []interface{}{contract.Hex(), block}) - if err != nil { - return false, err - } - var hex string - if err := json.Unmarshal(res, &hex); err != nil { - return false, err - } - // Convert the response back to a Go byte slice and return - return len(common.FromHex(hex)) > 0, nil -} - -// ContractCall implements ContractCaller.ContractCall, delegating the execution of -// a contract call to the remote node, returning the reply to for local processing. -func (b *rpcBackend) ContractCall(ctx context.Context, contract common.Address, data []byte, pending bool) ([]byte, error) { - // Pack up the request into an RPC argument - args := struct { - To common.Address `json:"to"` - Data string `json:"data"` - }{ - To: contract, - Data: common.ToHex(data), - } - // Execute the RPC call and retrieve the response - block := "latest" - if pending { - block = "pending" - } - res, err := b.request(ctx, "eth_call", []interface{}{args, block}) - if err != nil { - return nil, err - } - var hex string - if err := json.Unmarshal(res, &hex); err != nil { - return nil, err - } - // Convert the response back to a Go byte slice and return - return common.FromHex(hex), nil -} - -// PendingAccountNonce implements ContractTransactor.PendingAccountNonce, delegating -// the current account nonce retrieval to the remote node. -func (b *rpcBackend) PendingAccountNonce(ctx context.Context, account common.Address) (uint64, error) { - res, err := b.request(ctx, "eth_getTransactionCount", []interface{}{account.Hex(), "pending"}) - if err != nil { - return 0, err - } - var hex string - if err := json.Unmarshal(res, &hex); err != nil { - return 0, err - } - nonce, ok := new(big.Int).SetString(hex, 0) - if !ok { - return 0, fmt.Errorf("invalid nonce hex: %s", hex) - } - return nonce.Uint64(), nil -} - -// SuggestGasPrice implements ContractTransactor.SuggestGasPrice, delegating the -// gas price oracle request to the remote node. -func (b *rpcBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) { - res, err := b.request(ctx, "eth_gasPrice", nil) - if err != nil { - return nil, err - } - var hex string - if err := json.Unmarshal(res, &hex); err != nil { - return nil, err - } - price, ok := new(big.Int).SetString(hex, 0) - if !ok { - return nil, fmt.Errorf("invalid price hex: %s", hex) - } - return price, nil -} - -// EstimateGasLimit implements ContractTransactor.EstimateGasLimit, delegating -// the gas estimation to the remote node. -func (b *rpcBackend) EstimateGasLimit(ctx context.Context, sender common.Address, contract *common.Address, value *big.Int, data []byte) (*big.Int, error) { - // Pack up the request into an RPC argument - args := struct { - From common.Address `json:"from"` - To *common.Address `json:"to"` - Value *rpc.HexNumber `json:"value"` - Data string `json:"data"` - }{ - From: sender, - To: contract, - Data: common.ToHex(data), - Value: rpc.NewHexNumber(value), - } - // Execute the RPC call and retrieve the response - res, err := b.request(ctx, "eth_estimateGas", []interface{}{args}) - if err != nil { - return nil, err - } - var hex string - if err := json.Unmarshal(res, &hex); err != nil { - return nil, err - } - estimate, ok := new(big.Int).SetString(hex, 0) - if !ok { - return nil, fmt.Errorf("invalid estimate hex: %s", hex) - } - return estimate, nil -} - -// SendTransaction implements ContractTransactor.SendTransaction, delegating the -// raw transaction injection to the remote node. -func (b *rpcBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error { - data, err := rlp.EncodeToBytes(tx) - if err != nil { - return err - } - res, err := b.request(ctx, "eth_sendRawTransaction", []interface{}{common.ToHex(data)}) - if err != nil { - return err - } - var hex string - if err := json.Unmarshal(res, &hex); err != nil { - return err - } - return nil -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/utils/client.go b/src/vendor/github.com/ethereum/go-ethereum/cmd/utils/client.go deleted file mode 100644 index cc9647580..000000000 --- a/src/vendor/github.com/ethereum/go-ethereum/cmd/utils/client.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of go-ethereum. -// -// go-ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// go-ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with go-ethereum. If not, see . - -package utils - -import ( - "fmt" - "strings" - - "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/rpc" - "gopkg.in/urfave/cli.v1" -) - -// NewRemoteRPCClient returns a RPC client which connects to a running geth instance. -// Depending on the given context this can either be a IPC or a HTTP client. -func NewRemoteRPCClient(ctx *cli.Context) (rpc.Client, error) { - if ctx.Args().Present() { - endpoint := ctx.Args().First() - return NewRemoteRPCClientFromString(endpoint) - } - // use IPC by default - return rpc.NewIPCClient(node.DefaultIPCEndpoint()) -} - -// NewRemoteRPCClientFromString returns a RPC client which connects to the given -// endpoint. It must start with either `ipc:` or `rpc:` (HTTP). -func NewRemoteRPCClientFromString(endpoint string) (rpc.Client, error) { - if strings.HasPrefix(endpoint, "ipc:") { - return rpc.NewIPCClient(endpoint[4:]) - } - if strings.HasPrefix(endpoint, "rpc:") { - return rpc.NewHTTPClient(endpoint[4:]) - } - if strings.HasPrefix(endpoint, "http://") { - return rpc.NewHTTPClient(endpoint) - } - if strings.HasPrefix(endpoint, "ws:") { - return rpc.NewWSClient(endpoint) - } - return nil, fmt.Errorf("invalid endpoint") -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/compiler/solidity.go b/src/vendor/github.com/ethereum/go-ethereum/common/compiler/solidity.go deleted file mode 100644 index 6a5bfecd8..000000000 --- a/src/vendor/github.com/ethereum/go-ethereum/common/compiler/solidity.go +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package compiler - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "regexp" - "strings" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" -) - -var ( - versionRegexp = regexp.MustCompile("[0-9]+\\.[0-9]+\\.[0-9]+") - legacyRegexp = regexp.MustCompile("0\\.(9\\..*|1\\.[01])") - paramsLegacy = []string{ - "--binary", // Request to output the contract in binary (hexadecimal). - "file", // - "--json-abi", // Request to output the contract's JSON ABI interface. - "file", // - "--natspec-user", // Request to output the contract's Natspec user documentation. - "file", // - "--natspec-dev", // Request to output the contract's Natspec developer documentation. - "file", - "--add-std", - "1", - } - paramsNew = []string{ - "--bin", // Request to output the contract in binary (hexadecimal). - "--abi", // Request to output the contract's JSON ABI interface. - "--userdoc", // Request to output the contract's Natspec user documentation. - "--devdoc", // Request to output the contract's Natspec developer documentation. - "--add-std", // include standard lib contracts - "--optimize", // code optimizer switched on - "-o", // output directory - } -) - -type Contract struct { - Code string `json:"code"` - Info ContractInfo `json:"info"` -} - -type ContractInfo struct { - Source string `json:"source"` - Language string `json:"language"` - LanguageVersion string `json:"languageVersion"` - CompilerVersion string `json:"compilerVersion"` - CompilerOptions string `json:"compilerOptions"` - AbiDefinition interface{} `json:"abiDefinition"` - UserDoc interface{} `json:"userDoc"` - DeveloperDoc interface{} `json:"developerDoc"` -} - -type Solidity struct { - solcPath string - version string - fullVersion string - legacy bool -} - -func New(solcPath string) (sol *Solidity, err error) { - // set default solc - if len(solcPath) == 0 { - solcPath = "solc" - } - solcPath, err = exec.LookPath(solcPath) - if err != nil { - return - } - - cmd := exec.Command(solcPath, "--version") - var out bytes.Buffer - cmd.Stdout = &out - err = cmd.Run() - if err != nil { - return - } - - fullVersion := out.String() - version := versionRegexp.FindString(fullVersion) - legacy := legacyRegexp.MatchString(version) - - sol = &Solidity{ - solcPath: solcPath, - version: version, - fullVersion: fullVersion, - legacy: legacy, - } - glog.V(logger.Info).Infoln(sol.Info()) - return -} - -func (sol *Solidity) Info() string { - return fmt.Sprintf("%s\npath: %s", sol.fullVersion, sol.solcPath) -} - -func (sol *Solidity) Version() string { - return sol.version -} - -// Compile builds and returns all the contracts contained within a source string. -func (sol *Solidity) Compile(source string) (map[string]*Contract, error) { - // Short circuit if no source code was specified - if len(source) == 0 { - return nil, errors.New("solc: empty source string") - } - // Create a safe place to dump compilation output - wd, err := ioutil.TempDir("", "solc") - if err != nil { - return nil, fmt.Errorf("solc: failed to create temporary build folder: %v", err) - } - defer os.RemoveAll(wd) - - // Assemble the compiler command, change to the temp folder and capture any errors - stderr := new(bytes.Buffer) - - var params []string - if sol.legacy { - params = paramsLegacy - } else { - params = paramsNew - params = append(params, wd) - } - compilerOptions := strings.Join(params, " ") - - cmd := exec.Command(sol.solcPath, params...) - cmd.Stdin = strings.NewReader(source) - cmd.Stderr = stderr - - if err := cmd.Run(); err != nil { - return nil, fmt.Errorf("solc: %v\n%s", err, string(stderr.Bytes())) - } - // Sanity check that something was actually built - matches, _ := filepath.Glob(filepath.Join(wd, "*.bin*")) - if len(matches) < 1 { - return nil, fmt.Errorf("solc: no build results found") - } - // Compilation succeeded, assemble and return the contracts - contracts := make(map[string]*Contract) - for _, path := range matches { - _, file := filepath.Split(path) - base := strings.Split(file, ".")[0] - - // Parse the individual compilation results (code binary, ABI definitions, user and dev docs) - var binary []byte - binext := ".bin" - if sol.legacy { - binext = ".binary" - } - if binary, err = ioutil.ReadFile(filepath.Join(wd, base+binext)); err != nil { - return nil, fmt.Errorf("solc: error reading compiler output for code: %v", err) - } - - var abi interface{} - if blob, err := ioutil.ReadFile(filepath.Join(wd, base+".abi")); err != nil { - return nil, fmt.Errorf("solc: error reading abi definition: %v", err) - } else if err = json.Unmarshal(blob, &abi); err != nil { - return nil, fmt.Errorf("solc: error parsing abi definition: %v", err) - } - - var userdoc interface{} - if blob, err := ioutil.ReadFile(filepath.Join(wd, base+".docuser")); err != nil { - return nil, fmt.Errorf("solc: error reading user doc: %v", err) - } else if err = json.Unmarshal(blob, &userdoc); err != nil { - return nil, fmt.Errorf("solc: error parsing user doc: %v", err) - } - - var devdoc interface{} - if blob, err := ioutil.ReadFile(filepath.Join(wd, base+".docdev")); err != nil { - return nil, fmt.Errorf("solc: error reading dev doc: %v", err) - } else if err = json.Unmarshal(blob, &devdoc); err != nil { - return nil, fmt.Errorf("solc: error parsing dev doc: %v", err) - } - // Assemble the final contract - contracts[base] = &Contract{ - Code: "0x" + string(binary), - Info: ContractInfo{ - Source: source, - Language: "Solidity", - LanguageVersion: sol.version, - CompilerVersion: sol.version, - CompilerOptions: compilerOptions, - AbiDefinition: abi, - UserDoc: userdoc, - DeveloperDoc: devdoc, - }, - } - } - return contracts, nil -} - -func SaveInfo(info *ContractInfo, filename string) (contenthash common.Hash, err error) { - infojson, err := json.Marshal(info) - if err != nil { - return - } - contenthash = common.BytesToHash(crypto.Keccak256(infojson)) - err = ioutil.WriteFile(filename, infojson, 0600) - return -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/api.go b/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/api.go deleted file mode 100644 index 94cd6515f..000000000 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/api.go +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package downloader - -import ( - "sync" - - "golang.org/x/net/context" - - "github.com/ethereum/go-ethereum/event" - "github.com/ethereum/go-ethereum/rpc" -) - -// PublicDownloaderAPI provides an API which gives information about the current synchronisation status. -// It offers only methods that operates on data that can be available to anyone without security risks. -type PublicDownloaderAPI struct { - d *Downloader - mux *event.TypeMux - muSyncSubscriptions sync.Mutex - syncSubscriptions map[string]rpc.Subscription -} - -// NewPublicDownloaderAPI create a new PublicDownloaderAPI. -func NewPublicDownloaderAPI(d *Downloader, m *event.TypeMux) *PublicDownloaderAPI { - api := &PublicDownloaderAPI{d: d, mux: m, syncSubscriptions: make(map[string]rpc.Subscription)} - - go api.run() - - return api -} - -func (api *PublicDownloaderAPI) run() { - sub := api.mux.Subscribe(StartEvent{}, DoneEvent{}, FailedEvent{}) - - for event := range sub.Chan() { - var notification interface{} - - switch event.Data.(type) { - case StartEvent: - result := &SyncingResult{Syncing: true} - result.Status.Origin, result.Status.Current, result.Status.Height, result.Status.Pulled, result.Status.Known = api.d.Progress() - notification = result - case DoneEvent, FailedEvent: - notification = false - } - - api.muSyncSubscriptions.Lock() - for id, sub := range api.syncSubscriptions { - if sub.Notify(notification) == rpc.ErrNotificationNotFound { - delete(api.syncSubscriptions, id) - } - } - api.muSyncSubscriptions.Unlock() - } -} - -// Progress gives progress indications when the node is synchronising with the Ethereum network. -type Progress struct { - Origin uint64 `json:"startingBlock"` - Current uint64 `json:"currentBlock"` - Height uint64 `json:"highestBlock"` - Pulled uint64 `json:"pulledStates"` - Known uint64 `json:"knownStates"` -} - -// SyncingResult provides information about the current synchronisation status for this node. -type SyncingResult struct { - Syncing bool `json:"syncing"` - Status Progress `json:"status"` -} - -// Syncing provides information when this nodes starts synchronising with the Ethereum network and when it's finished. -func (api *PublicDownloaderAPI) Syncing(ctx context.Context) (rpc.Subscription, error) { - notifier, supported := rpc.NotifierFromContext(ctx) - if !supported { - return nil, rpc.ErrNotificationsUnsupported - } - - subscription, err := notifier.NewSubscription(func(id string) { - api.muSyncSubscriptions.Lock() - delete(api.syncSubscriptions, id) - api.muSyncSubscriptions.Unlock() - }) - - if err != nil { - return nil, err - } - - api.muSyncSubscriptions.Lock() - api.syncSubscriptions[subscription.ID()] = subscription - api.muSyncSubscriptions.Unlock() - - return subscription, nil -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/filters/api.go b/src/vendor/github.com/ethereum/go-ethereum/eth/filters/api.go deleted file mode 100644 index fd1cbd913..000000000 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/filters/api.go +++ /dev/null @@ -1,655 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package filters - -import ( - "crypto/rand" - "encoding/hex" - "encoding/json" - "errors" - "fmt" - "sync" - "time" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/event" - "github.com/ethereum/go-ethereum/internal/ethapi" - "github.com/ethereum/go-ethereum/rpc" - - "golang.org/x/net/context" -) - -var ( - filterTickerTime = 5 * time.Minute -) - -// byte will be inferred -const ( - unknownFilterTy = iota - blockFilterTy - transactionFilterTy - logFilterTy -) - -// PublicFilterAPI offers support to create and manage filters. This will allow external clients to retrieve various -// information related to the Ethereum protocol such als blocks, transactions and logs. -type PublicFilterAPI struct { - apiBackend ethapi.Backend - - quit chan struct{} - chainDb ethdb.Database - mux *event.TypeMux - - filterManager *FilterSystem - - filterMapMu sync.RWMutex - filterMapping map[string]int // maps between filter internal filter identifiers and external filter identifiers - - logMu sync.RWMutex - logQueue map[int]*logQueue - - blockMu sync.RWMutex - blockQueue map[int]*hashQueue - - transactionMu sync.RWMutex - transactionQueue map[int]*hashQueue - - transactMu sync.Mutex -} - -// NewPublicFilterAPI returns a new PublicFilterAPI instance. -func NewPublicFilterAPI(apiBackend ethapi.Backend) *PublicFilterAPI { - svc := &PublicFilterAPI{ - apiBackend: apiBackend, - mux: apiBackend.EventMux(), - chainDb: apiBackend.ChainDb(), - filterManager: NewFilterSystem(apiBackend.EventMux()), - filterMapping: make(map[string]int), - logQueue: make(map[int]*logQueue), - blockQueue: make(map[int]*hashQueue), - transactionQueue: make(map[int]*hashQueue), - } - go svc.start() - return svc -} - -// Stop quits the work loop. -func (s *PublicFilterAPI) Stop() { - close(s.quit) -} - -// start the work loop, wait and process events. -func (s *PublicFilterAPI) start() { - timer := time.NewTicker(2 * time.Second) - defer timer.Stop() -done: - for { - select { - case <-timer.C: - s.logMu.Lock() - for id, filter := range s.logQueue { - if time.Since(filter.timeout) > filterTickerTime { - s.filterManager.Remove(id) - delete(s.logQueue, id) - } - } - s.logMu.Unlock() - - s.blockMu.Lock() - for id, filter := range s.blockQueue { - if time.Since(filter.timeout) > filterTickerTime { - s.filterManager.Remove(id) - delete(s.blockQueue, id) - } - } - s.blockMu.Unlock() - - s.transactionMu.Lock() - for id, filter := range s.transactionQueue { - if time.Since(filter.timeout) > filterTickerTime { - s.filterManager.Remove(id) - delete(s.transactionQueue, id) - } - } - s.transactionMu.Unlock() - case <-s.quit: - break done - } - } - -} - -// NewBlockFilter create a new filter that returns blocks that are included into the canonical chain. -func (s *PublicFilterAPI) NewBlockFilter() (string, error) { - externalId, err := newFilterId() - if err != nil { - return "", err - } - - s.blockMu.Lock() - filter := New(s.apiBackend) - id, err := s.filterManager.Add(filter, ChainFilter) - if err != nil { - return "", err - } - - s.blockQueue[id] = &hashQueue{timeout: time.Now()} - - filter.BlockCallback = func(block *types.Block, logs vm.Logs) { - s.blockMu.Lock() - defer s.blockMu.Unlock() - - if queue := s.blockQueue[id]; queue != nil { - queue.add(block.Hash()) - } - } - - defer s.blockMu.Unlock() - - s.filterMapMu.Lock() - s.filterMapping[externalId] = id - s.filterMapMu.Unlock() - - return externalId, nil -} - -// NewPendingTransactionFilter creates a filter that returns new pending transactions. -func (s *PublicFilterAPI) NewPendingTransactionFilter() (string, error) { - externalId, err := newFilterId() - if err != nil { - return "", err - } - - s.transactionMu.Lock() - defer s.transactionMu.Unlock() - - filter := New(s.apiBackend) - id, err := s.filterManager.Add(filter, PendingTxFilter) - if err != nil { - return "", err - } - - s.transactionQueue[id] = &hashQueue{timeout: time.Now()} - - filter.TransactionCallback = func(tx *types.Transaction) { - s.transactionMu.Lock() - defer s.transactionMu.Unlock() - - if queue := s.transactionQueue[id]; queue != nil { - queue.add(tx.Hash()) - } - } - - s.filterMapMu.Lock() - s.filterMapping[externalId] = id - s.filterMapMu.Unlock() - - return externalId, nil -} - -// newLogFilter creates a new log filter. -func (s *PublicFilterAPI) newLogFilter(earliest, latest int64, addresses []common.Address, topics [][]common.Hash, callback func(log *vm.Log, removed bool)) (int, error) { - s.logMu.Lock() - defer s.logMu.Unlock() - - filter := New(s.apiBackend) - id, err := s.filterManager.Add(filter, LogFilter) - if err != nil { - return 0, err - } - - s.logQueue[id] = &logQueue{timeout: time.Now()} - - filter.SetBeginBlock(earliest) - filter.SetEndBlock(latest) - filter.SetAddresses(addresses) - filter.SetTopics(topics) - filter.LogCallback = func(log *vm.Log, removed bool) { - if callback != nil { - callback(log, removed) - } else { - s.logMu.Lock() - defer s.logMu.Unlock() - if queue := s.logQueue[id]; queue != nil { - queue.add(vmlog{log, removed}) - } - } - } - - return id, nil -} - -// Logs creates a subscription that fires for all new log that match the given filter criteria. -func (s *PublicFilterAPI) Logs(ctx context.Context, args NewFilterArgs) (rpc.Subscription, error) { - notifier, supported := rpc.NotifierFromContext(ctx) - if !supported { - return nil, rpc.ErrNotificationsUnsupported - } - - var ( - externalId string - subscription rpc.Subscription - err error - ) - - if externalId, err = newFilterId(); err != nil { - return nil, err - } - - // uninstall filter when subscription is unsubscribed/cancelled - if subscription, err = notifier.NewSubscription(func(string) { - s.UninstallFilter(externalId) - }); err != nil { - return nil, err - } - - notifySubscriber := func(log *vm.Log, removed bool) { - rpcLog := toRPCLogs(vm.Logs{log}, removed) - if err := subscription.Notify(rpcLog); err != nil { - subscription.Cancel() - } - } - - // from and to block number are not used since subscriptions don't allow you to travel to "time" - var id int - if len(args.Addresses) > 0 { - id, err = s.newLogFilter(-1, -1, args.Addresses, args.Topics, notifySubscriber) - } else { - id, err = s.newLogFilter(-1, -1, nil, args.Topics, notifySubscriber) - } - - if err != nil { - subscription.Cancel() - return nil, err - } - - s.filterMapMu.Lock() - s.filterMapping[externalId] = id - s.filterMapMu.Unlock() - - return subscription, err -} - -// NewFilterArgs represents a request to create a new filter. -type NewFilterArgs struct { - FromBlock rpc.BlockNumber - ToBlock rpc.BlockNumber - Addresses []common.Address - Topics [][]common.Hash -} - -// UnmarshalJSON sets *args fields with given data. -func (args *NewFilterArgs) UnmarshalJSON(data []byte) error { - type input struct { - From *rpc.BlockNumber `json:"fromBlock"` - ToBlock *rpc.BlockNumber `json:"toBlock"` - Addresses interface{} `json:"address"` - Topics []interface{} `json:"topics"` - } - - var raw input - if err := json.Unmarshal(data, &raw); err != nil { - return err - } - - if raw.From == nil || raw.From.Int64() < 0 { - args.FromBlock = rpc.LatestBlockNumber - } else { - args.FromBlock = *raw.From - } - - if raw.ToBlock == nil || raw.ToBlock.Int64() < 0 { - args.ToBlock = rpc.LatestBlockNumber - } else { - args.ToBlock = *raw.ToBlock - } - - args.Addresses = []common.Address{} - - if raw.Addresses != nil { - // raw.Address can contain a single address or an array of addresses - var addresses []common.Address - if strAddrs, ok := raw.Addresses.([]interface{}); ok { - for i, addr := range strAddrs { - if strAddr, ok := addr.(string); ok { - if len(strAddr) >= 2 && strAddr[0] == '0' && (strAddr[1] == 'x' || strAddr[1] == 'X') { - strAddr = strAddr[2:] - } - if decAddr, err := hex.DecodeString(strAddr); err == nil { - addresses = append(addresses, common.BytesToAddress(decAddr)) - } else { - return fmt.Errorf("invalid address given") - } - } else { - return fmt.Errorf("invalid address on index %d", i) - } - } - } else if singleAddr, ok := raw.Addresses.(string); ok { - if len(singleAddr) >= 2 && singleAddr[0] == '0' && (singleAddr[1] == 'x' || singleAddr[1] == 'X') { - singleAddr = singleAddr[2:] - } - if decAddr, err := hex.DecodeString(singleAddr); err == nil { - addresses = append(addresses, common.BytesToAddress(decAddr)) - } else { - return fmt.Errorf("invalid address given") - } - } else { - return errors.New("invalid address(es) given") - } - args.Addresses = addresses - } - - // helper function which parses a string to a topic hash - topicConverter := func(raw string) (common.Hash, error) { - if len(raw) == 0 { - return common.Hash{}, nil - } - if len(raw) >= 2 && raw[0] == '0' && (raw[1] == 'x' || raw[1] == 'X') { - raw = raw[2:] - } - if len(raw) != 2*common.HashLength { - return common.Hash{}, errors.New("invalid topic(s)") - } - if decAddr, err := hex.DecodeString(raw); err == nil { - return common.BytesToHash(decAddr), nil - } - return common.Hash{}, errors.New("invalid topic(s)") - } - - // topics is an array consisting of strings and/or arrays of strings. - // JSON null values are converted to common.Hash{} and ignored by the filter manager. - if len(raw.Topics) > 0 { - args.Topics = make([][]common.Hash, len(raw.Topics)) - for i, t := range raw.Topics { - if t == nil { // ignore topic when matching logs - args.Topics[i] = []common.Hash{common.Hash{}} - } else if topic, ok := t.(string); ok { // match specific topic - top, err := topicConverter(topic) - if err != nil { - return err - } - args.Topics[i] = []common.Hash{top} - } else if topics, ok := t.([]interface{}); ok { // or case e.g. [null, "topic0", "topic1"] - for _, rawTopic := range topics { - if rawTopic == nil { - args.Topics[i] = append(args.Topics[i], common.Hash{}) - } else if topic, ok := rawTopic.(string); ok { - parsed, err := topicConverter(topic) - if err != nil { - return err - } - args.Topics[i] = append(args.Topics[i], parsed) - } else { - return fmt.Errorf("invalid topic(s)") - } - } - } else { - return fmt.Errorf("invalid topic(s)") - } - } - } - - return nil -} - -// NewFilter creates a new filter and returns the filter id. It can be uses to retrieve logs. -func (s *PublicFilterAPI) NewFilter(args NewFilterArgs) (string, error) { - externalId, err := newFilterId() - if err != nil { - return "", err - } - - var id int - if len(args.Addresses) > 0 { - id, err = s.newLogFilter(args.FromBlock.Int64(), args.ToBlock.Int64(), args.Addresses, args.Topics, nil) - } else { - id, err = s.newLogFilter(args.FromBlock.Int64(), args.ToBlock.Int64(), nil, args.Topics, nil) - } - if err != nil { - return "", err - } - - s.filterMapMu.Lock() - s.filterMapping[externalId] = id - s.filterMapMu.Unlock() - - return externalId, nil -} - -// GetLogs returns the logs matching the given argument. -func (s *PublicFilterAPI) GetLogs(ctx context.Context, args NewFilterArgs) ([]vmlog, error) { - filter := New(s.apiBackend) - filter.SetBeginBlock(args.FromBlock.Int64()) - filter.SetEndBlock(args.ToBlock.Int64()) - filter.SetAddresses(args.Addresses) - filter.SetTopics(args.Topics) - - logs, err := filter.Find(ctx) - return toRPCLogs(logs, false), err -} - -// UninstallFilter removes the filter with the given filter id. -func (s *PublicFilterAPI) UninstallFilter(filterId string) bool { - s.filterMapMu.Lock() - defer s.filterMapMu.Unlock() - - id, ok := s.filterMapping[filterId] - if !ok { - return false - } - - defer s.filterManager.Remove(id) - delete(s.filterMapping, filterId) - - if _, ok := s.logQueue[id]; ok { - s.logMu.Lock() - defer s.logMu.Unlock() - delete(s.logQueue, id) - return true - } - if _, ok := s.blockQueue[id]; ok { - s.blockMu.Lock() - defer s.blockMu.Unlock() - delete(s.blockQueue, id) - return true - } - if _, ok := s.transactionQueue[id]; ok { - s.transactionMu.Lock() - defer s.transactionMu.Unlock() - delete(s.transactionQueue, id) - return true - } - - return false -} - -// getFilterType is a helper utility that determine the type of filter for the given filter id. -func (s *PublicFilterAPI) getFilterType(id int) byte { - if _, ok := s.blockQueue[id]; ok { - return blockFilterTy - } else if _, ok := s.transactionQueue[id]; ok { - return transactionFilterTy - } else if _, ok := s.logQueue[id]; ok { - return logFilterTy - } - - return unknownFilterTy -} - -// blockFilterChanged returns a collection of block hashes for the block filter with the given id. -func (s *PublicFilterAPI) blockFilterChanged(id int) []common.Hash { - s.blockMu.Lock() - defer s.blockMu.Unlock() - - if s.blockQueue[id] != nil { - res := s.blockQueue[id].get() - return res - } - return nil -} - -// transactionFilterChanged returns a collection of transaction hashes for the pending -// transaction filter with the given id. -func (s *PublicFilterAPI) transactionFilterChanged(id int) []common.Hash { - s.blockMu.Lock() - defer s.blockMu.Unlock() - - if s.transactionQueue[id] != nil { - return s.transactionQueue[id].get() - } - return nil -} - -// logFilterChanged returns a collection of logs for the log filter with the given id. -func (s *PublicFilterAPI) logFilterChanged(id int) []vmlog { - s.logMu.Lock() - defer s.logMu.Unlock() - - if s.logQueue[id] != nil { - return s.logQueue[id].get() - } - return nil -} - -// GetFilterLogs returns the logs for the filter with the given id. -func (s *PublicFilterAPI) GetFilterLogs(ctx context.Context, filterId string) ([]vmlog, error) { - id, ok := s.filterMapping[filterId] - if !ok { - return toRPCLogs(nil, false), nil - } - - if filter := s.filterManager.Get(id); filter != nil { - logs, err := filter.Find(ctx) - return toRPCLogs(logs, false), err - } - - return toRPCLogs(nil, false), nil -} - -// GetFilterChanges returns the logs for the filter with the given id since last time is was called. -// This can be used for polling. -func (s *PublicFilterAPI) GetFilterChanges(filterId string) interface{} { - s.filterMapMu.Lock() - id, ok := s.filterMapping[filterId] - s.filterMapMu.Unlock() - - if !ok { // filter not found - return []interface{}{} - } - - switch s.getFilterType(id) { - case blockFilterTy: - return returnHashes(s.blockFilterChanged(id)) - case transactionFilterTy: - return returnHashes(s.transactionFilterChanged(id)) - case logFilterTy: - return s.logFilterChanged(id) - } - - return []interface{}{} -} - -type vmlog struct { - *vm.Log - Removed bool `json:"removed"` -} - -type logQueue struct { - mu sync.Mutex - - logs []vmlog - timeout time.Time - id int -} - -func (l *logQueue) add(logs ...vmlog) { - l.mu.Lock() - defer l.mu.Unlock() - - l.logs = append(l.logs, logs...) -} - -func (l *logQueue) get() []vmlog { - l.mu.Lock() - defer l.mu.Unlock() - - l.timeout = time.Now() - tmp := l.logs - l.logs = nil - return tmp -} - -type hashQueue struct { - mu sync.Mutex - - hashes []common.Hash - timeout time.Time - id int -} - -func (l *hashQueue) add(hashes ...common.Hash) { - l.mu.Lock() - defer l.mu.Unlock() - - l.hashes = append(l.hashes, hashes...) -} - -func (l *hashQueue) get() []common.Hash { - l.mu.Lock() - defer l.mu.Unlock() - - l.timeout = time.Now() - tmp := l.hashes - l.hashes = nil - return tmp -} - -// newFilterId generates a new random filter identifier that can be exposed to the outer world. By publishing random -// identifiers it is not feasible for DApp's to guess filter id's for other DApp's and uninstall or poll for them -// causing the affected DApp to miss data. -func newFilterId() (string, error) { - var subid [16]byte - n, _ := rand.Read(subid[:]) - if n != 16 { - return "", errors.New("Unable to generate filter id") - } - return "0x" + hex.EncodeToString(subid[:]), nil -} - -// toRPCLogs is a helper that will convert a vm.Logs array to an structure which -// can hold additional information about the logs such as whether it was deleted. -// Additionally when nil is given it will by default instead create an empty slice -// instead. This is required by the RPC specification. -func toRPCLogs(logs vm.Logs, removed bool) []vmlog { - convertedLogs := make([]vmlog, len(logs)) - for i, log := range logs { - convertedLogs[i] = vmlog{Log: log, Removed: removed} - } - return convertedLogs -} - -// returnHashes is a helper that will return an empty hash array case the given hash array is nil, otherwise is will -// return the given hashes. The RPC interfaces defines that always an array is returned. -func returnHashes(hashes []common.Hash) []common.Hash { - if hashes == nil { - return []common.Hash{} - } - return hashes -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/filters/filter_system.go b/src/vendor/github.com/ethereum/go-ethereum/eth/filters/filter_system.go deleted file mode 100644 index 4343dfa21..000000000 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/filters/filter_system.go +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -// package filters implements an ethereum filtering system for block, -// transactions and log events. -package filters - -import ( - "fmt" - "sync" - "time" - - "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/event" -) - -// FilterType determines the type of filter and is used to put the filter in to -// the correct bucket when added. -type FilterType byte - -const ( - ChainFilter FilterType = iota // new block events filter - PendingTxFilter // pending transaction filter - LogFilter // new or removed log filter - PendingLogFilter // pending log filter -) - -// FilterSystem manages filters that filter specific events such as -// block, transaction and log events. The Filtering system can be used to listen -// for specific LOG events fired by the EVM (Ethereum Virtual Machine). -type FilterSystem struct { - filterMu sync.RWMutex - filterId int - - chainFilters map[int]*Filter - pendingTxFilters map[int]*Filter - logFilters map[int]*Filter - pendingLogFilters map[int]*Filter - - // generic is an ugly hack for Get - generic map[int]*Filter - - sub event.Subscription -} - -// NewFilterSystem returns a newly allocated filter manager -func NewFilterSystem(mux *event.TypeMux) *FilterSystem { - fs := &FilterSystem{ - chainFilters: make(map[int]*Filter), - pendingTxFilters: make(map[int]*Filter), - logFilters: make(map[int]*Filter), - pendingLogFilters: make(map[int]*Filter), - generic: make(map[int]*Filter), - } - fs.sub = mux.Subscribe( - core.PendingLogsEvent{}, - core.RemovedLogsEvent{}, - core.ChainEvent{}, - core.TxPreEvent{}, - vm.Logs(nil), - ) - go fs.filterLoop() - return fs -} - -// Stop quits the filter loop required for polling events -func (fs *FilterSystem) Stop() { - fs.sub.Unsubscribe() -} - -// Add adds a filter to the filter manager -func (fs *FilterSystem) Add(filter *Filter, filterType FilterType) (int, error) { - fs.filterMu.Lock() - defer fs.filterMu.Unlock() - - id := fs.filterId - filter.created = time.Now() - - switch filterType { - case ChainFilter: - fs.chainFilters[id] = filter - case PendingTxFilter: - fs.pendingTxFilters[id] = filter - case LogFilter: - fs.logFilters[id] = filter - case PendingLogFilter: - fs.pendingLogFilters[id] = filter - default: - return 0, fmt.Errorf("unknown filter type %v", filterType) - } - fs.generic[id] = filter - - fs.filterId++ - - return id, nil -} - -// Remove removes a filter by filter id -func (fs *FilterSystem) Remove(id int) { - fs.filterMu.Lock() - defer fs.filterMu.Unlock() - - delete(fs.chainFilters, id) - delete(fs.pendingTxFilters, id) - delete(fs.logFilters, id) - delete(fs.pendingLogFilters, id) - delete(fs.generic, id) -} - -func (fs *FilterSystem) Get(id int) *Filter { - fs.filterMu.RLock() - defer fs.filterMu.RUnlock() - - return fs.generic[id] -} - -// filterLoop waits for specific events from ethereum and fires their handlers -// when the filter matches the requirements. -func (fs *FilterSystem) filterLoop() { - for event := range fs.sub.Chan() { - switch ev := event.Data.(type) { - case core.ChainEvent: - fs.filterMu.RLock() - for _, filter := range fs.chainFilters { - if filter.BlockCallback != nil && !filter.created.After(event.Time) { - filter.BlockCallback(ev.Block, ev.Logs) - } - } - fs.filterMu.RUnlock() - case core.TxPreEvent: - fs.filterMu.RLock() - for _, filter := range fs.pendingTxFilters { - if filter.TransactionCallback != nil && !filter.created.After(event.Time) { - filter.TransactionCallback(ev.Tx) - } - } - fs.filterMu.RUnlock() - - case vm.Logs: - fs.filterMu.RLock() - for _, filter := range fs.logFilters { - if filter.LogCallback != nil && !filter.created.After(event.Time) { - for _, log := range filter.FilterLogs(ev) { - filter.LogCallback(log, false) - } - } - } - fs.filterMu.RUnlock() - case core.RemovedLogsEvent: - fs.filterMu.RLock() - for _, filter := range fs.logFilters { - if filter.LogCallback != nil && !filter.created.After(event.Time) { - for _, removedLog := range filter.FilterLogs(ev.Logs) { - filter.LogCallback(removedLog, true) - } - } - } - fs.filterMu.RUnlock() - case core.PendingLogsEvent: - fs.filterMu.RLock() - for _, filter := range fs.pendingLogFilters { - if filter.LogCallback != nil && !filter.created.After(event.Time) { - for _, pendingLog := range ev.Logs { - filter.LogCallback(pendingLog, false) - } - } - } - fs.filterMu.RUnlock() - } - } -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/http.go b/src/vendor/github.com/ethereum/go-ethereum/rpc/http.go deleted file mode 100644 index 9283ce0ec..000000000 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/http.go +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package rpc - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "strings" - - "github.com/rs/cors" -) - -const ( - maxHTTPRequestContentLength = 1024 * 128 -) - -// httpClient connects to a geth RPC server over HTTP. -type httpClient struct { - endpoint *url.URL // HTTP-RPC server endpoint - httpClient http.Client // reuse connection - lastRes []byte // HTTP requests are synchronous, store last response -} - -// NewHTTPClient create a new RPC clients that connection to a geth RPC server -// over HTTP. -func NewHTTPClient(endpoint string) (Client, error) { - url, err := url.Parse(endpoint) - if err != nil { - return nil, err - } - return &httpClient{endpoint: url}, nil -} - -// Send will serialize the given msg to JSON and sends it to the RPC server. -// Since HTTP is synchronous the response is stored until Recv is called. -func (client *httpClient) Send(msg interface{}) error { - var body []byte - var err error - - client.lastRes = nil - if body, err = json.Marshal(msg); err != nil { - return err - } - - resp, err := client.httpClient.Post(client.endpoint.String(), "application/json", bytes.NewReader(body)) - if err != nil { - return err - } - - defer resp.Body.Close() - if resp.StatusCode == http.StatusOK { - client.lastRes, err = ioutil.ReadAll(resp.Body) - return err - } - - return fmt.Errorf("request failed: %s", resp.Status) -} - -// Recv will try to deserialize the last received response into the given msg. -func (client *httpClient) Recv(msg interface{}) error { - return json.Unmarshal(client.lastRes, &msg) -} - -// Close is not necessary for httpClient -func (client *httpClient) Close() { -} - -// SupportedModules will return the collection of offered RPC modules. -func (client *httpClient) SupportedModules() (map[string]string, error) { - return SupportedModules(client) -} - -// httpReadWriteNopCloser wraps a io.Reader and io.Writer with a NOP Close method. -type httpReadWriteNopCloser struct { - io.Reader - io.Writer -} - -// Close does nothing and returns always nil -func (t *httpReadWriteNopCloser) Close() error { - return nil -} - -// newJSONHTTPHandler creates a HTTP handler that will parse incoming JSON requests, -// send the request to the given API provider and sends the response back to the caller. -func newJSONHTTPHandler(srv *Server) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - if r.ContentLength > maxHTTPRequestContentLength { - http.Error(w, - fmt.Sprintf("content length too large (%d>%d)", r.ContentLength, maxHTTPRequestContentLength), - http.StatusRequestEntityTooLarge) - return - } - - w.Header().Set("content-type", "application/json") - - // create a codec that reads direct from the request body until - // EOF and writes the response to w and order the server to process - // a single request. - codec := NewJSONCodec(&httpReadWriteNopCloser{r.Body, w}) - defer codec.Close() - srv.ServeSingleRequest(codec, OptionMethodInvocation) - } -} - -// NewHTTPServer creates a new HTTP RPC server around an API provider. -func NewHTTPServer(corsString string, srv *Server) *http.Server { - var allowedOrigins []string - for _, domain := range strings.Split(corsString, ",") { - allowedOrigins = append(allowedOrigins, strings.TrimSpace(domain)) - } - - c := cors.New(cors.Options{ - AllowedOrigins: allowedOrigins, - AllowedMethods: []string{"POST", "GET"}, - }) - - handler := c.Handler(newJSONHTTPHandler(srv)) - - return &http.Server{ - Handler: handler, - } -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/inproc.go b/src/vendor/github.com/ethereum/go-ethereum/rpc/inproc.go deleted file mode 100644 index 250f5c787..000000000 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/inproc.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2016 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package rpc - -import ( - "encoding/json" - "io" - "net" -) - -// inProcClient is an in-process buffer stream attached to an RPC server. -type inProcClient struct { - server *Server - cl io.Closer - enc *json.Encoder - dec *json.Decoder -} - -// Close tears down the request channel of the in-proc client. -func (c *inProcClient) Close() { - c.cl.Close() -} - -// NewInProcRPCClient creates an in-process buffer stream attachment to a given -// RPC server. -func NewInProcRPCClient(handler *Server) Client { - p1, p2 := net.Pipe() - go handler.ServeCodec(NewJSONCodec(p1), OptionMethodInvocation|OptionSubscriptions) - return &inProcClient{handler, p2, json.NewEncoder(p2), json.NewDecoder(p2)} -} - -// Send marshals a message into a json format and injects in into the client -// request channel. -func (c *inProcClient) Send(msg interface{}) error { - return c.enc.Encode(msg) -} - -// Recv reads a message from the response channel and tries to parse it into the -// given msg interface. -func (c *inProcClient) Recv(msg interface{}) error { - return c.dec.Decode(msg) -} - -// Returns the collection of modules the RPC server offers. -func (c *inProcClient) SupportedModules() (map[string]string, error) { - return SupportedModules(c) -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/ipc.go b/src/vendor/github.com/ethereum/go-ethereum/rpc/ipc.go deleted file mode 100644 index 05d8909ca..000000000 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/ipc.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package rpc - -import ( - "encoding/json" - "net" -) - -// CreateIPCListener creates an listener, on Unix platforms this is a unix socket, on Windows this is a named pipe -func CreateIPCListener(endpoint string) (net.Listener, error) { - return ipcListen(endpoint) -} - -// ipcClient represent an IPC RPC client. It will connect to a given endpoint and tries to communicate with a node using -// JSON serialization. -type ipcClient struct { - endpoint string - conn net.Conn - out *json.Encoder - in *json.Decoder -} - -// NewIPCClient create a new IPC client that will connect on the given endpoint. Messages are JSON encoded and encoded. -// On Unix it assumes the endpoint is the full path to a unix socket, and Windows the endpoint is an identifier for a -// named pipe. -func NewIPCClient(endpoint string) (Client, error) { - conn, err := newIPCConnection(endpoint) - if err != nil { - return nil, err - } - return &ipcClient{endpoint: endpoint, conn: conn, in: json.NewDecoder(conn), out: json.NewEncoder(conn)}, nil -} - -// Send will serialize the given message and send it to the server. -// When sending the message fails it will try to reconnect once and send the message again. -func (client *ipcClient) Send(msg interface{}) error { - if err := client.out.Encode(msg); err == nil { - return nil - } - - // retry once - client.conn.Close() - - conn, err := newIPCConnection(client.endpoint) - if err != nil { - return err - } - - client.conn = conn - client.in = json.NewDecoder(conn) - client.out = json.NewEncoder(conn) - - return client.out.Encode(msg) -} - -// Recv will read a message from the connection and tries to parse it. It assumes the received message is JSON encoded. -func (client *ipcClient) Recv(msg interface{}) error { - return client.in.Decode(&msg) -} - -// Close will close the underlying IPC connection -func (client *ipcClient) Close() { - client.conn.Close() -} - -// SupportedModules will return the collection of offered RPC modules. -func (client *ipcClient) SupportedModules() (map[string]string, error) { - return SupportedModules(client) -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/notification.go b/src/vendor/github.com/ethereum/go-ethereum/rpc/notification.go deleted file mode 100644 index e84e26a58..000000000 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/notification.go +++ /dev/null @@ -1,297 +0,0 @@ -// Copyright 2016 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package rpc - -import ( - "errors" - "sync" - "time" - - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" - "golang.org/x/net/context" -) - -var ( - // ErrNotificationsUnsupported is returned when the connection doesn't support notifications - ErrNotificationsUnsupported = errors.New("notifications not supported") - - // ErrNotificationNotFound is returned when the notification for the given id is not found - ErrNotificationNotFound = errors.New("notification not found") - - // errNotifierStopped is returned when the notifier is stopped (e.g. codec is closed) - errNotifierStopped = errors.New("unable to send notification") - - // errNotificationQueueFull is returns when there are too many notifications in the queue - errNotificationQueueFull = errors.New("too many pending notifications") -) - -// unsubSignal is a signal that the subscription is unsubscribed. It is used to flush buffered -// notifications that might be pending in the internal queue. -var unsubSignal = new(struct{}) - -// UnsubscribeCallback defines a callback that is called when a subcription ends. -// It receives the subscription id as argument. -type UnsubscribeCallback func(id string) - -// notification is a helper object that holds event data for a subscription -type notification struct { - sub *bufferedSubscription // subscription id - data interface{} // event data -} - -// A Notifier type describes the interface for objects that can send create subscriptions -type Notifier interface { - // Create a new subscription. The given callback is called when this subscription - // is cancelled (e.g. client send an unsubscribe, connection closed). - NewSubscription(UnsubscribeCallback) (Subscription, error) - // Cancel subscription - Unsubscribe(id string) error -} - -type notifierKey struct{} - -// NotifierFromContext returns the Notifier value stored in ctx, if any. -func NotifierFromContext(ctx context.Context) (Notifier, bool) { - n, ok := ctx.Value(notifierKey{}).(Notifier) - return n, ok -} - -// Subscription defines the interface for objects that can notify subscribers -type Subscription interface { - // Inform client of an event - Notify(data interface{}) error - // Unique identifier - ID() string - // Cancel subscription - Cancel() error -} - -// bufferedSubscription is a subscription that uses a bufferedNotifier to send -// notifications to subscribers. -type bufferedSubscription struct { - id string - unsubOnce sync.Once // call unsub method once - unsub UnsubscribeCallback // called on Unsubscribed - notifier *bufferedNotifier // forward notifications to - pending chan interface{} // closed when active - flushed chan interface{} // closed when all buffered notifications are send - lastNotification time.Time // last time a notification was send -} - -// ID returns the subscription identifier that the client uses to refer to this instance. -func (s *bufferedSubscription) ID() string { - return s.id -} - -// Cancel informs the notifier that this subscription is cancelled by the API -func (s *bufferedSubscription) Cancel() error { - return s.notifier.Unsubscribe(s.id) -} - -// Notify the subscriber of a particular event. -func (s *bufferedSubscription) Notify(data interface{}) error { - return s.notifier.send(s.id, data) -} - -// bufferedNotifier is a notifier that queues notifications in an internal queue and -// send them as fast as possible to the client from this queue. It will stop if the -// queue grows past a given size. -type bufferedNotifier struct { - codec ServerCodec // underlying connection - mu sync.Mutex // guard internal state - subscriptions map[string]*bufferedSubscription // keep track of subscriptions associated with codec - queueSize int // max number of items in queue - queue chan *notification // notification queue - stopped bool // indication if this notifier is ordered to stop -} - -// newBufferedNotifier returns a notifier that queues notifications in an internal queue -// from which notifications are send as fast as possible to the client. If the queue size -// limit is reached (client is unable to keep up) it will stop and closes the codec. -func newBufferedNotifier(codec ServerCodec, size int) *bufferedNotifier { - notifier := &bufferedNotifier{ - codec: codec, - subscriptions: make(map[string]*bufferedSubscription), - queue: make(chan *notification, size), - queueSize: size, - } - - go notifier.run() - - return notifier -} - -// NewSubscription creates a new subscription that forwards events to this instance internal -// queue. The given callback is called when the subscription is unsubscribed/cancelled. -func (n *bufferedNotifier) NewSubscription(callback UnsubscribeCallback) (Subscription, error) { - id, err := newSubscriptionID() - if err != nil { - return nil, err - } - - n.mu.Lock() - defer n.mu.Unlock() - - if n.stopped { - return nil, errNotifierStopped - } - - sub := &bufferedSubscription{ - id: id, - unsub: callback, - notifier: n, - pending: make(chan interface{}), - flushed: make(chan interface{}), - lastNotification: time.Now(), - } - - n.subscriptions[id] = sub - - return sub, nil -} - -// Remove the given subscription. If subscription is not found notificationNotFoundErr is returned. -func (n *bufferedNotifier) Unsubscribe(subid string) error { - n.mu.Lock() - sub, found := n.subscriptions[subid] - n.mu.Unlock() - - if found { - // send the unsubscribe signal, this will cause the notifier not to accept new events - // for this subscription and will close the flushed channel after the last (buffered) - // notification was send to the client. - if err := n.send(subid, unsubSignal); err != nil { - return err - } - - // wait for confirmation that all (buffered) events are send for this subscription. - // this ensures that the unsubscribe method response is not send before all buffered - // events for this subscription are send. - <-sub.flushed - - return nil - } - - return ErrNotificationNotFound -} - -// Send enques the given data for the subscription with public ID on the internal queue. t returns -// an error when the notifier is stopped or the queue is full. If data is the unsubscribe signal it -// will remove the subscription with the given id from the subscription collection. -func (n *bufferedNotifier) send(id string, data interface{}) error { - n.mu.Lock() - defer n.mu.Unlock() - - if n.stopped { - return errNotifierStopped - } - - var ( - subscription *bufferedSubscription - found bool - ) - - // check if subscription is associated with this connection, it might be cancelled - // (subscribe/connection closed) - if subscription, found = n.subscriptions[id]; !found { - glog.V(logger.Error).Infof("received notification for unknown subscription %s\n", id) - return ErrNotificationNotFound - } - - // received the unsubscribe signal. Add it to the queue to make sure any pending notifications - // for this subscription are send. When the run loop receives this singal it will signal that - // all pending subscriptions are flushed and that the confirmation of the unsubscribe can be - // send to the user. Remove the subscriptions to make sure new notifications are not accepted. - if data == unsubSignal { - delete(n.subscriptions, id) - if subscription.unsub != nil { - subscription.unsubOnce.Do(func() { subscription.unsub(id) }) - } - } - - subscription.lastNotification = time.Now() - - if len(n.queue) >= n.queueSize { - glog.V(logger.Warn).Infoln("too many buffered notifications -> close connection") - n.codec.Close() - return errNotificationQueueFull - } - - n.queue <- ¬ification{subscription, data} - return nil -} - -// run reads notifications from the internal queue and sends them to the client. In case of an -// error, or when the codec is closed it will cancel all active subscriptions and returns. -func (n *bufferedNotifier) run() { - defer func() { - n.mu.Lock() - defer n.mu.Unlock() - - n.stopped = true - close(n.queue) - - // on exit call unsubscribe callback - for id, sub := range n.subscriptions { - if sub.unsub != nil { - sub.unsubOnce.Do(func() { sub.unsub(id) }) - } - close(sub.flushed) - delete(n.subscriptions, id) - } - }() - - for { - select { - case notification := <-n.queue: - // It can happen that an event is raised before the RPC server was able to send the sub - // id to the client. Therefore subscriptions are marked as pending until the sub id was - // send. The RPC server will activate the subscription by closing the pending chan. - <-notification.sub.pending - - if notification.data == unsubSignal { - // unsubSignal is the last accepted message for this subscription. Raise the signal - // that all buffered notifications are sent by closing the flushed channel. This - // indicates that the response for the unsubscribe can be send to the client. - close(notification.sub.flushed) - } else { - msg := n.codec.CreateNotification(notification.sub.id, notification.data) - if err := n.codec.Write(msg); err != nil { - n.codec.Close() - // unable to send notification to client, unsubscribe all subscriptions - glog.V(logger.Warn).Infof("unable to send notification - %v\n", err) - return - } - } - case <-n.codec.Closed(): // connection was closed - glog.V(logger.Debug).Infoln("codec closed, stop subscriptions") - return - } - } -} - -// Marks the subscription as active. This will causes the notifications for this subscription to be -// forwarded to the client. -func (n *bufferedNotifier) activate(subid string) { - n.mu.Lock() - defer n.mu.Unlock() - - if sub, found := n.subscriptions[subid]; found { - close(sub.pending) - } -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/websocket.go b/src/vendor/github.com/ethereum/go-ethereum/rpc/websocket.go deleted file mode 100644 index fe9354d94..000000000 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/websocket.go +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package rpc - -import ( - "fmt" - "net/http" - "os" - "strings" - "sync" - - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" - "golang.org/x/net/websocket" - "gopkg.in/fatih/set.v0" -) - -// wsReaderWriterCloser reads and write payloads from and to a websocket connection. -type wsReaderWriterCloser struct { - c *websocket.Conn -} - -// Read will read incoming payload data into p. -func (rw *wsReaderWriterCloser) Read(p []byte) (int, error) { - return rw.c.Read(p) -} - -// Write writes p to the websocket. -func (rw *wsReaderWriterCloser) Write(p []byte) (int, error) { - return rw.c.Write(p) -} - -// Close closes the websocket connection. -func (rw *wsReaderWriterCloser) Close() error { - return rw.c.Close() -} - -// wsHandshakeValidator returns a handler that verifies the origin during the -// websocket upgrade process. When a '*' is specified as an allowed origins all -// connections are accepted. -func wsHandshakeValidator(allowedOrigins []string) func(*websocket.Config, *http.Request) error { - origins := set.New() - allowAllOrigins := false - - for _, origin := range allowedOrigins { - if origin == "*" { - allowAllOrigins = true - } - if origin != "" { - origins.Add(strings.ToLower(origin)) - } - } - - // allow localhost if no allowedOrigins are specified. - if len(origins.List()) == 0 { - origins.Add("http://localhost") - if hostname, err := os.Hostname(); err == nil { - origins.Add("http://" + strings.ToLower(hostname)) - } - } - - glog.V(logger.Debug).Infof("Allowed origin(s) for WS RPC interface %v\n", origins.List()) - - f := func(cfg *websocket.Config, req *http.Request) error { - origin := strings.ToLower(req.Header.Get("Origin")) - if allowAllOrigins || origins.Has(origin) { - return nil - } - glog.V(logger.Debug).Infof("origin '%s' not allowed on WS-RPC interface\n", origin) - return fmt.Errorf("origin %s not allowed", origin) - } - - return f -} - -// NewWSServer creates a new websocket RPC server around an API provider. -func NewWSServer(allowedOrigins string, handler *Server) *http.Server { - return &http.Server{ - Handler: websocket.Server{ - Handshake: wsHandshakeValidator(strings.Split(allowedOrigins, ",")), - Handler: func(conn *websocket.Conn) { - handler.ServeCodec(NewJSONCodec(&wsReaderWriterCloser{conn}), - OptionMethodInvocation|OptionSubscriptions) - }, - }, - } -} - -// wsClient represents a RPC client that communicates over websockets with a -// RPC server. -type wsClient struct { - endpoint string - connMu sync.Mutex - conn *websocket.Conn -} - -// NewWSClientj creates a new RPC client that communicates with a RPC server -// that is listening on the given endpoint using JSON encoding. -func NewWSClient(endpoint string) (Client, error) { - return &wsClient{endpoint: endpoint}, nil -} - -// connection will return a websocket connection to the RPC server. It will -// (re)connect when necessary. -func (client *wsClient) connection() (*websocket.Conn, error) { - if client.conn != nil { - return client.conn, nil - } - - origin, err := os.Hostname() - if err != nil { - return nil, err - } - - origin = "http://" + origin - client.conn, err = websocket.Dial(client.endpoint, "", origin) - - return client.conn, err -} - -// SupportedModules is the collection of modules the RPC server offers. -func (client *wsClient) SupportedModules() (map[string]string, error) { - return SupportedModules(client) -} - -// Send writes the JSON serialized msg to the websocket. It will create a new -// websocket connection to the server if the client is currently not connected. -func (client *wsClient) Send(msg interface{}) (err error) { - client.connMu.Lock() - defer client.connMu.Unlock() - - var conn *websocket.Conn - if conn, err = client.connection(); err == nil { - if err = websocket.JSON.Send(conn, msg); err != nil { - client.conn.Close() - client.conn = nil - } - } - - return err -} - -// Recv reads a JSON message from the websocket and unmarshals it into msg. -func (client *wsClient) Recv(msg interface{}) (err error) { - client.connMu.Lock() - defer client.connMu.Unlock() - - var conn *websocket.Conn - if conn, err = client.connection(); err == nil { - if err = websocket.JSON.Receive(conn, msg); err != nil { - client.conn.Close() - client.conn = nil - } - } - return -} - -// Close closes the underlaying websocket connection. -func (client *wsClient) Close() { - client.connMu.Lock() - defer client.connMu.Unlock() - - if client.conn != nil { - client.conn.Close() - client.conn = nil - } - -} diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/cl.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/cl.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/cl.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/cl.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/context.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/context.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/context.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/context.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/device.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/device.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/device.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/device.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/device12.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/device12.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/device12.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/device12.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/image.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/image.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/image.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/image.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel10.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel10.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel10.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel10.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel12.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel12.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel12.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/kernel12.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/platform.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/platform.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/platform.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/platform.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/program.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/program.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/program.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/program.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/queue.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/queue.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/queue.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/queue.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/types.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/types.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/types.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/types.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/types12.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/types12.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/types12.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/types12.go diff --git a/src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/types_darwin.go b/vendor/github.com/Gustav-Simonsson/go-opencl/cl/types_darwin.go similarity index 100% rename from src/vendor/github.com/Gustav-Simonsson/go-opencl/cl/types_darwin.go rename to vendor/github.com/Gustav-Simonsson/go-opencl/cl/types_darwin.go diff --git a/src/vendor/github.com/aristanetworks/goarista/COPYING b/vendor/github.com/aristanetworks/goarista/COPYING similarity index 100% rename from src/vendor/github.com/aristanetworks/goarista/COPYING rename to vendor/github.com/aristanetworks/goarista/COPYING diff --git a/src/vendor/github.com/aristanetworks/goarista/atime/issue15006.s b/vendor/github.com/aristanetworks/goarista/atime/issue15006.s similarity index 100% rename from src/vendor/github.com/aristanetworks/goarista/atime/issue15006.s rename to vendor/github.com/aristanetworks/goarista/atime/issue15006.s diff --git a/src/vendor/github.com/aristanetworks/goarista/atime/nanotime.go b/vendor/github.com/aristanetworks/goarista/atime/nanotime.go similarity index 100% rename from src/vendor/github.com/aristanetworks/goarista/atime/nanotime.go rename to vendor/github.com/aristanetworks/goarista/atime/nanotime.go diff --git a/src/vendor/github.com/btcsuite/btcd/LICENSE b/vendor/github.com/btcsuite/btcd/LICENSE similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/LICENSE rename to vendor/github.com/btcsuite/btcd/LICENSE diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/README.md b/vendor/github.com/btcsuite/btcd/btcec/README.md similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/README.md rename to vendor/github.com/btcsuite/btcd/btcec/README.md diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/btcec.go b/vendor/github.com/btcsuite/btcd/btcec/btcec.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/btcec.go rename to vendor/github.com/btcsuite/btcd/btcec/btcec.go diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/ciphering.go b/vendor/github.com/btcsuite/btcd/btcec/ciphering.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/ciphering.go rename to vendor/github.com/btcsuite/btcd/btcec/ciphering.go diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/doc.go b/vendor/github.com/btcsuite/btcd/btcec/doc.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/doc.go rename to vendor/github.com/btcsuite/btcd/btcec/doc.go diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/field.go b/vendor/github.com/btcsuite/btcd/btcec/field.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/field.go rename to vendor/github.com/btcsuite/btcd/btcec/field.go diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/genprecomps.go b/vendor/github.com/btcsuite/btcd/btcec/genprecomps.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/genprecomps.go rename to vendor/github.com/btcsuite/btcd/btcec/genprecomps.go diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/gensecp256k1.go b/vendor/github.com/btcsuite/btcd/btcec/gensecp256k1.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/gensecp256k1.go rename to vendor/github.com/btcsuite/btcd/btcec/gensecp256k1.go diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/precompute.go b/vendor/github.com/btcsuite/btcd/btcec/precompute.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/precompute.go rename to vendor/github.com/btcsuite/btcd/btcec/precompute.go diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/privkey.go b/vendor/github.com/btcsuite/btcd/btcec/privkey.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/privkey.go rename to vendor/github.com/btcsuite/btcd/btcec/privkey.go diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/pubkey.go b/vendor/github.com/btcsuite/btcd/btcec/pubkey.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/pubkey.go rename to vendor/github.com/btcsuite/btcd/btcec/pubkey.go diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/secp256k1.go b/vendor/github.com/btcsuite/btcd/btcec/secp256k1.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/secp256k1.go rename to vendor/github.com/btcsuite/btcd/btcec/secp256k1.go diff --git a/src/vendor/github.com/btcsuite/btcd/btcec/signature.go b/vendor/github.com/btcsuite/btcd/btcec/signature.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/btcec/signature.go rename to vendor/github.com/btcsuite/btcd/btcec/signature.go diff --git a/src/vendor/github.com/btcsuite/btcd/chaincfg/README.md b/vendor/github.com/btcsuite/btcd/chaincfg/README.md similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/chaincfg/README.md rename to vendor/github.com/btcsuite/btcd/chaincfg/README.md diff --git a/src/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/README.md b/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/README.md similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/README.md rename to vendor/github.com/btcsuite/btcd/chaincfg/chainhash/README.md diff --git a/src/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/doc.go b/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/doc.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/doc.go rename to vendor/github.com/btcsuite/btcd/chaincfg/chainhash/doc.go diff --git a/src/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/hash.go b/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/hash.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/hash.go rename to vendor/github.com/btcsuite/btcd/chaincfg/chainhash/hash.go diff --git a/src/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/hashfuncs.go b/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/hashfuncs.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/chaincfg/chainhash/hashfuncs.go rename to vendor/github.com/btcsuite/btcd/chaincfg/chainhash/hashfuncs.go diff --git a/src/vendor/github.com/btcsuite/btcd/chaincfg/doc.go b/vendor/github.com/btcsuite/btcd/chaincfg/doc.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/chaincfg/doc.go rename to vendor/github.com/btcsuite/btcd/chaincfg/doc.go diff --git a/src/vendor/github.com/btcsuite/btcd/chaincfg/genesis.go b/vendor/github.com/btcsuite/btcd/chaincfg/genesis.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/chaincfg/genesis.go rename to vendor/github.com/btcsuite/btcd/chaincfg/genesis.go diff --git a/src/vendor/github.com/btcsuite/btcd/chaincfg/params.go b/vendor/github.com/btcsuite/btcd/chaincfg/params.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/chaincfg/params.go rename to vendor/github.com/btcsuite/btcd/chaincfg/params.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/README.md b/vendor/github.com/btcsuite/btcd/wire/README.md similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/README.md rename to vendor/github.com/btcsuite/btcd/wire/README.md diff --git a/src/vendor/github.com/btcsuite/btcd/wire/blockheader.go b/vendor/github.com/btcsuite/btcd/wire/blockheader.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/blockheader.go rename to vendor/github.com/btcsuite/btcd/wire/blockheader.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/common.go b/vendor/github.com/btcsuite/btcd/wire/common.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/common.go rename to vendor/github.com/btcsuite/btcd/wire/common.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/doc.go b/vendor/github.com/btcsuite/btcd/wire/doc.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/doc.go rename to vendor/github.com/btcsuite/btcd/wire/doc.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/error.go b/vendor/github.com/btcsuite/btcd/wire/error.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/error.go rename to vendor/github.com/btcsuite/btcd/wire/error.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/invvect.go b/vendor/github.com/btcsuite/btcd/wire/invvect.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/invvect.go rename to vendor/github.com/btcsuite/btcd/wire/invvect.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/message.go b/vendor/github.com/btcsuite/btcd/wire/message.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/message.go rename to vendor/github.com/btcsuite/btcd/wire/message.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgaddr.go b/vendor/github.com/btcsuite/btcd/wire/msgaddr.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgaddr.go rename to vendor/github.com/btcsuite/btcd/wire/msgaddr.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgalert.go b/vendor/github.com/btcsuite/btcd/wire/msgalert.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgalert.go rename to vendor/github.com/btcsuite/btcd/wire/msgalert.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgblock.go b/vendor/github.com/btcsuite/btcd/wire/msgblock.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgblock.go rename to vendor/github.com/btcsuite/btcd/wire/msgblock.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgfilteradd.go b/vendor/github.com/btcsuite/btcd/wire/msgfilteradd.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgfilteradd.go rename to vendor/github.com/btcsuite/btcd/wire/msgfilteradd.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgfilterclear.go b/vendor/github.com/btcsuite/btcd/wire/msgfilterclear.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgfilterclear.go rename to vendor/github.com/btcsuite/btcd/wire/msgfilterclear.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgfilterload.go b/vendor/github.com/btcsuite/btcd/wire/msgfilterload.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgfilterload.go rename to vendor/github.com/btcsuite/btcd/wire/msgfilterload.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msggetaddr.go b/vendor/github.com/btcsuite/btcd/wire/msggetaddr.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msggetaddr.go rename to vendor/github.com/btcsuite/btcd/wire/msggetaddr.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msggetblocks.go b/vendor/github.com/btcsuite/btcd/wire/msggetblocks.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msggetblocks.go rename to vendor/github.com/btcsuite/btcd/wire/msggetblocks.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msggetdata.go b/vendor/github.com/btcsuite/btcd/wire/msggetdata.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msggetdata.go rename to vendor/github.com/btcsuite/btcd/wire/msggetdata.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msggetheaders.go b/vendor/github.com/btcsuite/btcd/wire/msggetheaders.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msggetheaders.go rename to vendor/github.com/btcsuite/btcd/wire/msggetheaders.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgheaders.go b/vendor/github.com/btcsuite/btcd/wire/msgheaders.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgheaders.go rename to vendor/github.com/btcsuite/btcd/wire/msgheaders.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msginv.go b/vendor/github.com/btcsuite/btcd/wire/msginv.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msginv.go rename to vendor/github.com/btcsuite/btcd/wire/msginv.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgmempool.go b/vendor/github.com/btcsuite/btcd/wire/msgmempool.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgmempool.go rename to vendor/github.com/btcsuite/btcd/wire/msgmempool.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgmerkleblock.go b/vendor/github.com/btcsuite/btcd/wire/msgmerkleblock.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgmerkleblock.go rename to vendor/github.com/btcsuite/btcd/wire/msgmerkleblock.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgnotfound.go b/vendor/github.com/btcsuite/btcd/wire/msgnotfound.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgnotfound.go rename to vendor/github.com/btcsuite/btcd/wire/msgnotfound.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgping.go b/vendor/github.com/btcsuite/btcd/wire/msgping.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgping.go rename to vendor/github.com/btcsuite/btcd/wire/msgping.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgpong.go b/vendor/github.com/btcsuite/btcd/wire/msgpong.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgpong.go rename to vendor/github.com/btcsuite/btcd/wire/msgpong.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgreject.go b/vendor/github.com/btcsuite/btcd/wire/msgreject.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgreject.go rename to vendor/github.com/btcsuite/btcd/wire/msgreject.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgsendheaders.go b/vendor/github.com/btcsuite/btcd/wire/msgsendheaders.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgsendheaders.go rename to vendor/github.com/btcsuite/btcd/wire/msgsendheaders.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgtx.go b/vendor/github.com/btcsuite/btcd/wire/msgtx.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgtx.go rename to vendor/github.com/btcsuite/btcd/wire/msgtx.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgverack.go b/vendor/github.com/btcsuite/btcd/wire/msgverack.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgverack.go rename to vendor/github.com/btcsuite/btcd/wire/msgverack.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/msgversion.go b/vendor/github.com/btcsuite/btcd/wire/msgversion.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/msgversion.go rename to vendor/github.com/btcsuite/btcd/wire/msgversion.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/netaddress.go b/vendor/github.com/btcsuite/btcd/wire/netaddress.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/netaddress.go rename to vendor/github.com/btcsuite/btcd/wire/netaddress.go diff --git a/src/vendor/github.com/btcsuite/btcd/wire/protocol.go b/vendor/github.com/btcsuite/btcd/wire/protocol.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcd/wire/protocol.go rename to vendor/github.com/btcsuite/btcd/wire/protocol.go diff --git a/src/vendor/github.com/btcsuite/btcutil/LICENSE b/vendor/github.com/btcsuite/btcutil/LICENSE similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/LICENSE rename to vendor/github.com/btcsuite/btcutil/LICENSE diff --git a/src/vendor/github.com/btcsuite/btcutil/README.md b/vendor/github.com/btcsuite/btcutil/README.md similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/README.md rename to vendor/github.com/btcsuite/btcutil/README.md diff --git a/src/vendor/github.com/btcsuite/btcutil/address.go b/vendor/github.com/btcsuite/btcutil/address.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/address.go rename to vendor/github.com/btcsuite/btcutil/address.go diff --git a/src/vendor/github.com/btcsuite/btcutil/amount.go b/vendor/github.com/btcsuite/btcutil/amount.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/amount.go rename to vendor/github.com/btcsuite/btcutil/amount.go diff --git a/src/vendor/github.com/btcsuite/btcutil/appdata.go b/vendor/github.com/btcsuite/btcutil/appdata.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/appdata.go rename to vendor/github.com/btcsuite/btcutil/appdata.go diff --git a/src/vendor/github.com/btcsuite/btcutil/base58/README.md b/vendor/github.com/btcsuite/btcutil/base58/README.md similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/base58/README.md rename to vendor/github.com/btcsuite/btcutil/base58/README.md diff --git a/src/vendor/github.com/btcsuite/btcutil/base58/alphabet.go b/vendor/github.com/btcsuite/btcutil/base58/alphabet.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/base58/alphabet.go rename to vendor/github.com/btcsuite/btcutil/base58/alphabet.go diff --git a/src/vendor/github.com/btcsuite/btcutil/base58/base58.go b/vendor/github.com/btcsuite/btcutil/base58/base58.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/base58/base58.go rename to vendor/github.com/btcsuite/btcutil/base58/base58.go diff --git a/src/vendor/github.com/btcsuite/btcutil/base58/base58check.go b/vendor/github.com/btcsuite/btcutil/base58/base58check.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/base58/base58check.go rename to vendor/github.com/btcsuite/btcutil/base58/base58check.go diff --git a/src/vendor/github.com/btcsuite/btcutil/base58/cov_report.sh b/vendor/github.com/btcsuite/btcutil/base58/cov_report.sh similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/base58/cov_report.sh rename to vendor/github.com/btcsuite/btcutil/base58/cov_report.sh diff --git a/src/vendor/github.com/btcsuite/btcutil/base58/doc.go b/vendor/github.com/btcsuite/btcutil/base58/doc.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/base58/doc.go rename to vendor/github.com/btcsuite/btcutil/base58/doc.go diff --git a/src/vendor/github.com/btcsuite/btcutil/base58/genalphabet.go b/vendor/github.com/btcsuite/btcutil/base58/genalphabet.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/base58/genalphabet.go rename to vendor/github.com/btcsuite/btcutil/base58/genalphabet.go diff --git a/src/vendor/github.com/btcsuite/btcutil/block.go b/vendor/github.com/btcsuite/btcutil/block.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/block.go rename to vendor/github.com/btcsuite/btcutil/block.go diff --git a/src/vendor/github.com/btcsuite/btcutil/certgen.go b/vendor/github.com/btcsuite/btcutil/certgen.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/certgen.go rename to vendor/github.com/btcsuite/btcutil/certgen.go diff --git a/src/vendor/github.com/btcsuite/btcutil/const.go b/vendor/github.com/btcsuite/btcutil/const.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/const.go rename to vendor/github.com/btcsuite/btcutil/const.go diff --git a/src/vendor/github.com/btcsuite/btcutil/cov_report.sh b/vendor/github.com/btcsuite/btcutil/cov_report.sh similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/cov_report.sh rename to vendor/github.com/btcsuite/btcutil/cov_report.sh diff --git a/src/vendor/github.com/btcsuite/btcutil/doc.go b/vendor/github.com/btcsuite/btcutil/doc.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/doc.go rename to vendor/github.com/btcsuite/btcutil/doc.go diff --git a/src/vendor/github.com/btcsuite/btcutil/goclean.sh b/vendor/github.com/btcsuite/btcutil/goclean.sh similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/goclean.sh rename to vendor/github.com/btcsuite/btcutil/goclean.sh diff --git a/src/vendor/github.com/btcsuite/btcutil/hash160.go b/vendor/github.com/btcsuite/btcutil/hash160.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/hash160.go rename to vendor/github.com/btcsuite/btcutil/hash160.go diff --git a/src/vendor/github.com/btcsuite/btcutil/hdkeychain/README.md b/vendor/github.com/btcsuite/btcutil/hdkeychain/README.md similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/hdkeychain/README.md rename to vendor/github.com/btcsuite/btcutil/hdkeychain/README.md diff --git a/src/vendor/github.com/btcsuite/btcutil/hdkeychain/cov_report.sh b/vendor/github.com/btcsuite/btcutil/hdkeychain/cov_report.sh similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/hdkeychain/cov_report.sh rename to vendor/github.com/btcsuite/btcutil/hdkeychain/cov_report.sh diff --git a/src/vendor/github.com/btcsuite/btcutil/hdkeychain/doc.go b/vendor/github.com/btcsuite/btcutil/hdkeychain/doc.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/hdkeychain/doc.go rename to vendor/github.com/btcsuite/btcutil/hdkeychain/doc.go diff --git a/src/vendor/github.com/btcsuite/btcutil/hdkeychain/extendedkey.go b/vendor/github.com/btcsuite/btcutil/hdkeychain/extendedkey.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/hdkeychain/extendedkey.go rename to vendor/github.com/btcsuite/btcutil/hdkeychain/extendedkey.go diff --git a/src/vendor/github.com/btcsuite/btcutil/hdkeychain/test_coverage.txt b/vendor/github.com/btcsuite/btcutil/hdkeychain/test_coverage.txt similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/hdkeychain/test_coverage.txt rename to vendor/github.com/btcsuite/btcutil/hdkeychain/test_coverage.txt diff --git a/src/vendor/github.com/btcsuite/btcutil/net.go b/vendor/github.com/btcsuite/btcutil/net.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/net.go rename to vendor/github.com/btcsuite/btcutil/net.go diff --git a/src/vendor/github.com/btcsuite/btcutil/net_noop.go b/vendor/github.com/btcsuite/btcutil/net_noop.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/net_noop.go rename to vendor/github.com/btcsuite/btcutil/net_noop.go diff --git a/src/vendor/github.com/btcsuite/btcutil/test_coverage.txt b/vendor/github.com/btcsuite/btcutil/test_coverage.txt similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/test_coverage.txt rename to vendor/github.com/btcsuite/btcutil/test_coverage.txt diff --git a/src/vendor/github.com/btcsuite/btcutil/tx.go b/vendor/github.com/btcsuite/btcutil/tx.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/tx.go rename to vendor/github.com/btcsuite/btcutil/tx.go diff --git a/src/vendor/github.com/btcsuite/btcutil/wif.go b/vendor/github.com/btcsuite/btcutil/wif.go similarity index 100% rename from src/vendor/github.com/btcsuite/btcutil/wif.go rename to vendor/github.com/btcsuite/btcutil/wif.go diff --git a/src/vendor/github.com/btcsuite/fastsha256/LICENSE.md b/vendor/github.com/btcsuite/fastsha256/LICENSE.md similarity index 100% rename from src/vendor/github.com/btcsuite/fastsha256/LICENSE.md rename to vendor/github.com/btcsuite/fastsha256/LICENSE.md diff --git a/src/vendor/github.com/btcsuite/fastsha256/sha256.go b/vendor/github.com/btcsuite/fastsha256/sha256.go similarity index 100% rename from src/vendor/github.com/btcsuite/fastsha256/sha256.go rename to vendor/github.com/btcsuite/fastsha256/sha256.go diff --git a/src/vendor/github.com/btcsuite/fastsha256/sha256block.go b/vendor/github.com/btcsuite/fastsha256/sha256block.go similarity index 100% rename from src/vendor/github.com/btcsuite/fastsha256/sha256block.go rename to vendor/github.com/btcsuite/fastsha256/sha256block.go diff --git a/src/vendor/github.com/btcsuite/fastsha256/sha256block_386.s b/vendor/github.com/btcsuite/fastsha256/sha256block_386.s similarity index 100% rename from src/vendor/github.com/btcsuite/fastsha256/sha256block_386.s rename to vendor/github.com/btcsuite/fastsha256/sha256block_386.s diff --git a/src/vendor/github.com/btcsuite/fastsha256/sha256block_amd64.s b/vendor/github.com/btcsuite/fastsha256/sha256block_amd64.s similarity index 100% rename from src/vendor/github.com/btcsuite/fastsha256/sha256block_amd64.s rename to vendor/github.com/btcsuite/fastsha256/sha256block_amd64.s diff --git a/src/vendor/github.com/btcsuite/fastsha256/sha256block_decl.go b/vendor/github.com/btcsuite/fastsha256/sha256block_decl.go similarity index 100% rename from src/vendor/github.com/btcsuite/fastsha256/sha256block_decl.go rename to vendor/github.com/btcsuite/fastsha256/sha256block_decl.go diff --git a/src/vendor/github.com/btcsuite/golangcrypto/LICENSE b/vendor/github.com/btcsuite/golangcrypto/LICENSE similarity index 100% rename from src/vendor/github.com/btcsuite/golangcrypto/LICENSE rename to vendor/github.com/btcsuite/golangcrypto/LICENSE diff --git a/src/vendor/github.com/btcsuite/golangcrypto/PATENTS b/vendor/github.com/btcsuite/golangcrypto/PATENTS similarity index 100% rename from src/vendor/github.com/btcsuite/golangcrypto/PATENTS rename to vendor/github.com/btcsuite/golangcrypto/PATENTS diff --git a/src/vendor/github.com/btcsuite/golangcrypto/ripemd160/ripemd160.go b/vendor/github.com/btcsuite/golangcrypto/ripemd160/ripemd160.go similarity index 100% rename from src/vendor/github.com/btcsuite/golangcrypto/ripemd160/ripemd160.go rename to vendor/github.com/btcsuite/golangcrypto/ripemd160/ripemd160.go diff --git a/src/vendor/github.com/btcsuite/golangcrypto/ripemd160/ripemd160block.go b/vendor/github.com/btcsuite/golangcrypto/ripemd160/ripemd160block.go similarity index 100% rename from src/vendor/github.com/btcsuite/golangcrypto/ripemd160/ripemd160block.go rename to vendor/github.com/btcsuite/golangcrypto/ripemd160/ripemd160block.go diff --git a/src/vendor/github.com/ethereum/ethash/.gitignore b/vendor/github.com/ethereum/ethash/.gitignore similarity index 100% rename from src/vendor/github.com/ethereum/ethash/.gitignore rename to vendor/github.com/ethereum/ethash/.gitignore diff --git a/src/vendor/github.com/ethereum/ethash/.travis.yml b/vendor/github.com/ethereum/ethash/.travis.yml similarity index 100% rename from src/vendor/github.com/ethereum/ethash/.travis.yml rename to vendor/github.com/ethereum/ethash/.travis.yml diff --git a/src/vendor/github.com/ethereum/ethash/CMakeLists.txt b/vendor/github.com/ethereum/ethash/CMakeLists.txt similarity index 100% rename from src/vendor/github.com/ethereum/ethash/CMakeLists.txt rename to vendor/github.com/ethereum/ethash/CMakeLists.txt diff --git a/src/vendor/github.com/ethereum/ethash/MANIFEST.in b/vendor/github.com/ethereum/ethash/MANIFEST.in similarity index 100% rename from src/vendor/github.com/ethereum/ethash/MANIFEST.in rename to vendor/github.com/ethereum/ethash/MANIFEST.in diff --git a/src/vendor/github.com/ethereum/ethash/Makefile b/vendor/github.com/ethereum/ethash/Makefile similarity index 100% rename from src/vendor/github.com/ethereum/ethash/Makefile rename to vendor/github.com/ethereum/ethash/Makefile diff --git a/src/vendor/github.com/ethereum/ethash/README.md b/vendor/github.com/ethereum/ethash/README.md similarity index 100% rename from src/vendor/github.com/ethereum/ethash/README.md rename to vendor/github.com/ethereum/ethash/README.md diff --git a/src/vendor/github.com/ethereum/ethash/Vagrantfile b/vendor/github.com/ethereum/ethash/Vagrantfile similarity index 100% rename from src/vendor/github.com/ethereum/ethash/Vagrantfile rename to vendor/github.com/ethereum/ethash/Vagrantfile diff --git a/src/vendor/github.com/ethereum/ethash/appveyor.yml b/vendor/github.com/ethereum/ethash/appveyor.yml similarity index 100% rename from src/vendor/github.com/ethereum/ethash/appveyor.yml rename to vendor/github.com/ethereum/ethash/appveyor.yml diff --git a/src/vendor/github.com/ethereum/ethash/ethash.go b/vendor/github.com/ethereum/ethash/ethash.go similarity index 100% rename from src/vendor/github.com/ethereum/ethash/ethash.go rename to vendor/github.com/ethereum/ethash/ethash.go diff --git a/src/vendor/github.com/ethereum/ethash/ethash_opencl.go b/vendor/github.com/ethereum/ethash/ethash_opencl.go similarity index 100% rename from src/vendor/github.com/ethereum/ethash/ethash_opencl.go rename to vendor/github.com/ethereum/ethash/ethash_opencl.go diff --git a/src/vendor/github.com/ethereum/ethash/ethash_opencl_kernel_go_str.go b/vendor/github.com/ethereum/ethash/ethash_opencl_kernel_go_str.go similarity index 100% rename from src/vendor/github.com/ethereum/ethash/ethash_opencl_kernel_go_str.go rename to vendor/github.com/ethereum/ethash/ethash_opencl_kernel_go_str.go diff --git a/src/vendor/github.com/ethereum/ethash/ethashc.go b/vendor/github.com/ethereum/ethash/ethashc.go similarity index 100% rename from src/vendor/github.com/ethereum/ethash/ethashc.go rename to vendor/github.com/ethereum/ethash/ethashc.go diff --git a/src/vendor/github.com/ethereum/ethash/setup.py b/vendor/github.com/ethereum/ethash/setup.py similarity index 100% rename from src/vendor/github.com/ethereum/ethash/setup.py rename to vendor/github.com/ethereum/ethash/setup.py diff --git a/src/vendor/github.com/ethereum/ethash/src/benchmark/CMakeLists.txt b/vendor/github.com/ethereum/ethash/src/benchmark/CMakeLists.txt similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/benchmark/CMakeLists.txt rename to vendor/github.com/ethereum/ethash/src/benchmark/CMakeLists.txt diff --git a/src/vendor/github.com/ethereum/ethash/src/benchmark/benchmark.cpp b/vendor/github.com/ethereum/ethash/src/benchmark/benchmark.cpp similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/benchmark/benchmark.cpp rename to vendor/github.com/ethereum/ethash/src/benchmark/benchmark.cpp diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/CMakeLists.txt b/vendor/github.com/ethereum/ethash/src/libethash/CMakeLists.txt similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/CMakeLists.txt rename to vendor/github.com/ethereum/ethash/src/libethash/CMakeLists.txt diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/compiler.h b/vendor/github.com/ethereum/ethash/src/libethash/compiler.h similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/compiler.h rename to vendor/github.com/ethereum/ethash/src/libethash/compiler.h diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/data_sizes.h b/vendor/github.com/ethereum/ethash/src/libethash/data_sizes.h similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/data_sizes.h rename to vendor/github.com/ethereum/ethash/src/libethash/data_sizes.h diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/endian.h b/vendor/github.com/ethereum/ethash/src/libethash/endian.h similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/endian.h rename to vendor/github.com/ethereum/ethash/src/libethash/endian.h diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/ethash.h b/vendor/github.com/ethereum/ethash/src/libethash/ethash.h similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/ethash.h rename to vendor/github.com/ethereum/ethash/src/libethash/ethash.h diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/fnv.h b/vendor/github.com/ethereum/ethash/src/libethash/fnv.h similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/fnv.h rename to vendor/github.com/ethereum/ethash/src/libethash/fnv.h diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/internal.c b/vendor/github.com/ethereum/ethash/src/libethash/internal.c similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/internal.c rename to vendor/github.com/ethereum/ethash/src/libethash/internal.c diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/internal.h b/vendor/github.com/ethereum/ethash/src/libethash/internal.h similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/internal.h rename to vendor/github.com/ethereum/ethash/src/libethash/internal.h diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/io.c b/vendor/github.com/ethereum/ethash/src/libethash/io.c similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/io.c rename to vendor/github.com/ethereum/ethash/src/libethash/io.c diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/io.h b/vendor/github.com/ethereum/ethash/src/libethash/io.h similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/io.h rename to vendor/github.com/ethereum/ethash/src/libethash/io.h diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/io_posix.c b/vendor/github.com/ethereum/ethash/src/libethash/io_posix.c similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/io_posix.c rename to vendor/github.com/ethereum/ethash/src/libethash/io_posix.c diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/io_win32.c b/vendor/github.com/ethereum/ethash/src/libethash/io_win32.c similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/io_win32.c rename to vendor/github.com/ethereum/ethash/src/libethash/io_win32.c diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/mmap.h b/vendor/github.com/ethereum/ethash/src/libethash/mmap.h similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/mmap.h rename to vendor/github.com/ethereum/ethash/src/libethash/mmap.h diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/mmap_win32.c b/vendor/github.com/ethereum/ethash/src/libethash/mmap_win32.c similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/mmap_win32.c rename to vendor/github.com/ethereum/ethash/src/libethash/mmap_win32.c diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/sha3.c b/vendor/github.com/ethereum/ethash/src/libethash/sha3.c similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/sha3.c rename to vendor/github.com/ethereum/ethash/src/libethash/sha3.c diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/sha3.h b/vendor/github.com/ethereum/ethash/src/libethash/sha3.h similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/sha3.h rename to vendor/github.com/ethereum/ethash/src/libethash/sha3.h diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp b/vendor/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp rename to vendor/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.cpp diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.h b/vendor/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.h similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.h rename to vendor/github.com/ethereum/ethash/src/libethash/sha3_cryptopp.h diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/util.h b/vendor/github.com/ethereum/ethash/src/libethash/util.h similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/util.h rename to vendor/github.com/ethereum/ethash/src/libethash/util.h diff --git a/src/vendor/github.com/ethereum/ethash/src/libethash/util_win32.c b/vendor/github.com/ethereum/ethash/src/libethash/util_win32.c similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/libethash/util_win32.c rename to vendor/github.com/ethereum/ethash/src/libethash/util_win32.c diff --git a/src/vendor/github.com/ethereum/ethash/src/python/core.c b/vendor/github.com/ethereum/ethash/src/python/core.c similarity index 100% rename from src/vendor/github.com/ethereum/ethash/src/python/core.c rename to vendor/github.com/ethereum/ethash/src/python/core.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/COPYING b/vendor/github.com/ethereum/go-ethereum/COPYING similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/COPYING rename to vendor/github.com/ethereum/go-ethereum/COPYING diff --git a/src/vendor/github.com/ethereum/go-ethereum/COPYING.LESSER b/vendor/github.com/ethereum/go-ethereum/COPYING.LESSER similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/COPYING.LESSER rename to vendor/github.com/ethereum/go-ethereum/COPYING.LESSER diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/argument.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/argument.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/argument.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/argument.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/auth.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/auth.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/auth.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/auth.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backend.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backend.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backend.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backend.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/nil.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/nil.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/nil.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/nil.go diff --git a/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/remote.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/remote.go new file mode 100644 index 000000000..58edd791a --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/remote.go @@ -0,0 +1,136 @@ +// Copyright 2016 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package backends + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rpc" + "golang.org/x/net/context" +) + +// This nil assignment ensures compile time that rpcBackend implements bind.ContractBackend. +var _ bind.ContractBackend = (*rpcBackend)(nil) + +// rpcBackend implements bind.ContractBackend, and acts as the data provider to +// Ethereum contracts bound to Go structs. It uses an RPC connection to delegate +// all its functionality. +type rpcBackend struct { + client *rpc.Client // RPC client connection to interact with an API server +} + +// NewRPCBackend creates a new binding backend to an RPC provider that can be +// used to interact with remote contracts. +func NewRPCBackend(client *rpc.Client) bind.ContractBackend { + return &rpcBackend{client: client} +} + +// HasCode implements ContractVerifier.HasCode by retrieving any code associated +// with the contract from the remote node, and checking its size. +func (b *rpcBackend) HasCode(ctx context.Context, contract common.Address, pending bool) (bool, error) { + block := "latest" + if pending { + block = "pending" + } + var hex string + err := b.client.CallContext(ctx, &hex, "eth_getCode", contract, block) + if err != nil { + return false, err + } + return len(common.FromHex(hex)) > 0, nil +} + +// ContractCall implements ContractCaller.ContractCall, delegating the execution of +// a contract call to the remote node, returning the reply to for local processing. +func (b *rpcBackend) ContractCall(ctx context.Context, contract common.Address, data []byte, pending bool) ([]byte, error) { + args := struct { + To common.Address `json:"to"` + Data string `json:"data"` + }{ + To: contract, + Data: common.ToHex(data), + } + block := "latest" + if pending { + block = "pending" + } + var hex string + err := b.client.CallContext(ctx, &hex, "eth_call", args, block) + if err != nil { + return nil, err + } + return common.FromHex(hex), nil + +} + +// PendingAccountNonce implements ContractTransactor.PendingAccountNonce, delegating +// the current account nonce retrieval to the remote node. +func (b *rpcBackend) PendingAccountNonce(ctx context.Context, account common.Address) (uint64, error) { + var hex rpc.HexNumber + err := b.client.CallContext(ctx, &hex, "eth_getTransactionCount", account.Hex(), "pending") + if err != nil { + return 0, err + } + return hex.Uint64(), nil +} + +// SuggestGasPrice implements ContractTransactor.SuggestGasPrice, delegating the +// gas price oracle request to the remote node. +func (b *rpcBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) { + var hex rpc.HexNumber + if err := b.client.CallContext(ctx, &hex, "eth_gasPrice"); err != nil { + return nil, err + } + return (*big.Int)(&hex), nil +} + +// EstimateGasLimit implements ContractTransactor.EstimateGasLimit, delegating +// the gas estimation to the remote node. +func (b *rpcBackend) EstimateGasLimit(ctx context.Context, sender common.Address, contract *common.Address, value *big.Int, data []byte) (*big.Int, error) { + args := struct { + From common.Address `json:"from"` + To *common.Address `json:"to"` + Value *rpc.HexNumber `json:"value"` + Data string `json:"data"` + }{ + From: sender, + To: contract, + Data: common.ToHex(data), + Value: rpc.NewHexNumber(value), + } + // Execute the RPC call and retrieve the response + var hex rpc.HexNumber + err := b.client.CallContext(ctx, &hex, "eth_estimateGas", args) + if err != nil { + return nil, err + } + return (*big.Int)(&hex), nil +} + +// SendTransaction implements ContractTransactor.SendTransaction, delegating the +// raw transaction injection to the remote node. +func (b *rpcBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error { + data, err := rlp.EncodeToBytes(tx) + if err != nil { + return err + } + return b.client.CallContext(ctx, nil, "eth_sendRawTransaction", common.ToHex(data)) +} diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/simulated.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/simulated.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/simulated.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/backends/simulated.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/base.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/base.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/base.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/base.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/bind.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/bind.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/bind.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/bind.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/template.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/template.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/template.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/bind/template.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/doc.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/doc.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/doc.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/doc.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/error.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/error.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/error.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/error.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/event.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/event.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/event.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/event.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/method.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/method.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/method.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/method.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/numbers.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/numbers.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/numbers.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/numbers.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/packing.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/packing.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/packing.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/packing.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/reflect.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/reflect.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/reflect.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/reflect.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/abi/type.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/type.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/abi/type.go rename to vendor/github.com/ethereum/go-ethereum/accounts/abi/type.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/account_manager.go b/vendor/github.com/ethereum/go-ethereum/accounts/account_manager.go similarity index 87% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/account_manager.go rename to vendor/github.com/ethereum/go-ethereum/accounts/account_manager.go index af7485224..da2862b17 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/accounts/account_manager.go +++ b/vendor/github.com/ethereum/go-ethereum/accounts/account_manager.go @@ -34,10 +34,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/p2p" - "github.com/ethereum/go-ethereum/rpc" - "github.com/ethereum/go-ethereum/whisper" "github.com/status-im/status-go/src/extkeys" ) @@ -73,7 +69,6 @@ type Manager struct { keyStore keyStore mu sync.RWMutex unlocked map[common.Address]*unlocked - sync *[]node.Service } type unlocked struct { @@ -82,12 +77,9 @@ type unlocked struct { } // NewManager creates a manager for the given directory. -func NewManager(keydir string, scryptN, scryptP int, s *[]node.Service) *Manager { +func NewManager(keydir string, scryptN, scryptP int) *Manager { keydir, _ = filepath.Abs(keydir) - am := &Manager{ - keyStore: &keyStorePassphrase{keydir, scryptN, scryptP}, - sync: s, - } + am := &Manager{keyStore: &keyStorePassphrase{keydir, scryptN, scryptP}} am.init(keydir) return am } @@ -197,21 +189,11 @@ func (am *Manager) Lock(addr common.Address) error { // shortens the active unlock timeout. If the address was previously unlocked // indefinitely the timeout is not altered. func (am *Manager) TimedUnlock(a Account, passphrase string, timeout time.Duration) error { - a, key, err := am.getDecryptedKey(a, passphrase) if err != nil { return err } - // sync key to subprotocols (e.g., whisper identity) - if am.sync != nil { - address := fmt.Sprintf("%x", a.Address) - err = am.syncAccounts(address, key) - if err != nil { - return fmt.Errorf("failed to sync accounts: %s", err.Error()) - } - } - am.mu.Lock() defer am.mu.Unlock() u, found := am.unlocked[a.Address] @@ -236,18 +218,6 @@ func (am *Manager) TimedUnlock(a Account, passphrase string, timeout time.Durati return nil } -func (am *Manager) syncAccounts(a string, key *Key) error { - for _, service := range *am.sync { - if whisperInstance, ok := service.(*whisper.Whisper); ok && key.WhisperEnabled { - err := whisperInstance.InjectIdentity(key.PrivateKey) - if err != nil { - return fmt.Errorf("failed to sync accounts with shh: %s", err.Error()) - } - } - } - return nil -} - func (am *Manager) getDecryptedKey(a Account, auth string) (Account, *Key, error) { am.cache.maybeReload() am.cache.mu.Lock() @@ -283,25 +253,13 @@ func (am *Manager) expire(addr common.Address, u *unlocked, timeout time.Duratio // NewAccount generates a new key and stores it into the key directory, // encrypting it with the passphrase. func (am *Manager) NewAccount(passphrase string, w bool) (Account, error) { - - key, account, err := storeNewKey(am.keyStore, crand.Reader, passphrase, w) + _, account, err := storeNewKey(am.keyStore, crand.Reader, passphrase, w) if err != nil { return Account{}, err } - // Add the account to the cache immediately rather // than waiting for file system notifications to pick it up. am.cache.add(account) - - // sync key to subprotocols (e.g., whisper identity) - if am.sync != nil { - address := fmt.Sprintf("%x", account.Address) - err = am.syncAccounts(address, key) - if err != nil { - return account, fmt.Errorf("failed to sync accounts: %s", err.Error()) - } - } - return account, nil } @@ -427,23 +385,3 @@ func zeroKey(k *ecdsa.PrivateKey) { b[i] = 0 } } - -// APIs implements node.Service -func (am *Manager) APIs() []rpc.API { - return nil -} - -// Protocols implements node.Service -func (am *Manager) Protocols() []p2p.Protocol { - return nil -} - -// Start implements node.Service -func (am *Manager) Start(srvr *p2p.Server) error { - return nil -} - -// Stop implements node.Service -func (am *Manager) Stop() error { - return nil -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/addrcache.go b/vendor/github.com/ethereum/go-ethereum/accounts/addrcache.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/addrcache.go rename to vendor/github.com/ethereum/go-ethereum/accounts/addrcache.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/key.go b/vendor/github.com/ethereum/go-ethereum/accounts/key.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/key.go rename to vendor/github.com/ethereum/go-ethereum/accounts/key.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/key_store_passphrase.go b/vendor/github.com/ethereum/go-ethereum/accounts/key_store_passphrase.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/key_store_passphrase.go rename to vendor/github.com/ethereum/go-ethereum/accounts/key_store_passphrase.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/key_store_plain.go b/vendor/github.com/ethereum/go-ethereum/accounts/key_store_plain.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/key_store_plain.go rename to vendor/github.com/ethereum/go-ethereum/accounts/key_store_plain.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/presale.go b/vendor/github.com/ethereum/go-ethereum/accounts/presale.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/presale.go rename to vendor/github.com/ethereum/go-ethereum/accounts/presale.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/watch.go b/vendor/github.com/ethereum/go-ethereum/accounts/watch.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/watch.go rename to vendor/github.com/ethereum/go-ethereum/accounts/watch.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/accounts/watch_fallback.go b/vendor/github.com/ethereum/go-ethereum/accounts/watch_fallback.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/accounts/watch_fallback.go rename to vendor/github.com/ethereum/go-ethereum/accounts/watch_fallback.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/abigen/main.go b/vendor/github.com/ethereum/go-ethereum/cmd/abigen/main.go similarity index 91% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/abigen/main.go rename to vendor/github.com/ethereum/go-ethereum/cmd/abigen/main.go index f36391351..9c9ab6d31 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/cmd/abigen/main.go +++ b/vendor/github.com/ethereum/go-ethereum/cmd/abigen/main.go @@ -68,18 +68,7 @@ func main() { for _, kind := range strings.Split(*excFlag, ",") { exclude[strings.ToLower(kind)] = true } - // Build the Solidity source into bindable components - solc, err := compiler.New(*solcFlag) - if err != nil { - fmt.Printf("Failed to locate Solidity compiler: %v\n", err) - os.Exit(-1) - } - source, err := ioutil.ReadFile(*solFlag) - if err != nil { - fmt.Printf("Failed to read Soldity source code: %v\n", err) - os.Exit(-1) - } - contracts, err := solc.Compile(string(source)) + contracts, err := compiler.CompileSolidity(*solcFlag, *solFlag) if err != nil { fmt.Printf("Failed to build Solidity contract: %v\n", err) os.Exit(-1) diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/bootnode/main.go b/vendor/github.com/ethereum/go-ethereum/cmd/bootnode/main.go similarity index 87% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/bootnode/main.go rename to vendor/github.com/ethereum/go-ethereum/cmd/bootnode/main.go index 7d3f9fdb3..40d3cdc17 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/cmd/bootnode/main.go +++ b/vendor/github.com/ethereum/go-ethereum/cmd/bootnode/main.go @@ -20,6 +20,7 @@ package main import ( "crypto/ecdsa" "flag" + "fmt" "os" "github.com/ethereum/go-ethereum/cmd/utils" @@ -32,7 +33,8 @@ import ( func main() { var ( listenAddr = flag.String("addr", ":30301", "listen address") - genKey = flag.String("genkey", "", "generate a node key and quit") + genKey = flag.String("genkey", "", "generate a node key") + writeAddr = flag.Bool("writeaddress", false, "write out the node's pubkey hash and quit") nodeKeyFile = flag.String("nodekey", "", "private key filename") nodeKeyHex = flag.String("nodekeyhex", "", "private key as hex (for testing)") natdesc = flag.String("nat", "none", "port mapping mechanism (any|none|upnp|pmp|extip:)") @@ -45,22 +47,19 @@ func main() { glog.SetToStderr(true) flag.Parse() - if *genKey != "" { - key, err := crypto.GenerateKey() - if err != nil { - utils.Fatalf("could not generate key: %v", err) - } - if err := crypto.SaveECDSA(*genKey, key); err != nil { - utils.Fatalf("%v", err) - } - os.Exit(0) - } - natm, err := nat.Parse(*natdesc) if err != nil { utils.Fatalf("-nat: %v", err) } switch { + case *genKey != "": + nodeKey, err = crypto.GenerateKey() + if err != nil { + utils.Fatalf("could not generate key: %v", err) + } + if err = crypto.SaveECDSA(*genKey, nodeKey); err != nil { + utils.Fatalf("%v", err) + } case *nodeKeyFile == "" && *nodeKeyHex == "": utils.Fatalf("Use -nodekey or -nodekeyhex to specify a private key") case *nodeKeyFile != "" && *nodeKeyHex != "": @@ -75,6 +74,11 @@ func main() { } } + if *writeAddr { + fmt.Printf("%v\n", discover.PubkeyID(&nodeKey.PublicKey)) + os.Exit(0) + } + if _, err := discover.ListenUDP(nodeKey, *listenAddr, natm, ""); err != nil { utils.Fatalf("%v", err) } diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/disasm/main.go b/vendor/github.com/ethereum/go-ethereum/cmd/disasm/main.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/disasm/main.go rename to vendor/github.com/ethereum/go-ethereum/cmd/disasm/main.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/evm/code.txt b/vendor/github.com/ethereum/go-ethereum/cmd/evm/code.txt similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/evm/code.txt rename to vendor/github.com/ethereum/go-ethereum/cmd/evm/code.txt diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/evm/input.txt b/vendor/github.com/ethereum/go-ethereum/cmd/evm/input.txt similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/evm/input.txt rename to vendor/github.com/ethereum/go-ethereum/cmd/evm/input.txt diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/evm/main.go b/vendor/github.com/ethereum/go-ethereum/cmd/evm/main.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/evm/main.go rename to vendor/github.com/ethereum/go-ethereum/cmd/evm/main.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go b/vendor/github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go similarity index 93% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go rename to vendor/github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go index 5e2895636..b0a45dd41 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go +++ b/vendor/github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go @@ -27,7 +27,6 @@ import ( "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "gopkg.in/urfave/cli.v1" - "github.com/ethereum/go-ethereum/node" ) var ( @@ -169,9 +168,8 @@ nodes. ) func accountList(ctx *cli.Context) error { - var sync *[]node.Service - accman := utils.MakeAccountManager(ctx, sync) - for i, acct := range accman.Accounts() { + stack := utils.MakeNode(ctx, clientIdentifier, verString) + for i, acct := range stack.AccountManager().Accounts() { fmt.Printf("Account #%d: {%x} %s\n", i, acct.Address, acct.File) } return nil @@ -280,12 +278,11 @@ func ambiguousAddrRecovery(am *accounts.Manager, err *accounts.AmbiguousAddrErro // accountCreate creates a new account into the keystore defined by the CLI flags. func accountCreate(ctx *cli.Context) error { - var sync *[]node.Service - accman := utils.MakeAccountManager(ctx, sync) + stack := utils.MakeNode(ctx, clientIdentifier, verString) password := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx)) whisper := getWhisperYesNo("You can also choose to enable your new account as a Whisper identity.") - account, err := accman.NewAccount(password, whisper) + account, err := stack.AccountManager().NewAccount(password, whisper) if err != nil { utils.Fatalf("Failed to create account: %v", err) } @@ -300,12 +297,10 @@ func accountUpdate(ctx *cli.Context) error { if len(ctx.Args()) == 0 { utils.Fatalf("No accounts specified to update") } - var sync *[]node.Service - accman := utils.MakeAccountManager(ctx, sync) - - account, oldPassword := unlockAccount(ctx, accman, ctx.Args().First(), 0, nil) + stack := utils.MakeNode(ctx, clientIdentifier, verString) + account, oldPassword := unlockAccount(ctx, stack.AccountManager(), ctx.Args().First(), 0, nil) newPassword := getPassPhrase("Please give a new password. Do not forget this password.", true, 0, nil) - if err := accman.Update(account, oldPassword, newPassword); err != nil { + if err := stack.AccountManager().Update(account, oldPassword, newPassword); err != nil { utils.Fatalf("Could not update the account: %v", err) } return nil @@ -321,11 +316,9 @@ func importWallet(ctx *cli.Context) error { utils.Fatalf("Could not read wallet file: %v", err) } - var sync *[]node.Service - accman := utils.MakeAccountManager(ctx, sync) + stack := utils.MakeNode(ctx, clientIdentifier, verString) passphrase := getPassPhrase("", false, 0, utils.MakePasswordList(ctx)) - - acct, err := accman.ImportPreSaleKey(keyJson, passphrase) + acct, err := stack.AccountManager().ImportPreSaleKey(keyJson, passphrase) if err != nil { utils.Fatalf("%v", err) } @@ -342,10 +335,9 @@ func accountImport(ctx *cli.Context) error { if err != nil { utils.Fatalf("Failed to load the private key: %v", err) } - var sync *[]node.Service - accman := utils.MakeAccountManager(ctx, sync) + stack := utils.MakeNode(ctx, clientIdentifier, verString) passphrase := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx)) - acct, err := accman.ImportECDSA(key, passphrase) + acct, err := stack.AccountManager().ImportECDSA(key, passphrase) if err != nil { utils.Fatalf("Could not create the account: %v", err) } diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/chaincmd.go b/vendor/github.com/ethereum/go-ethereum/cmd/geth/chaincmd.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/geth/chaincmd.go rename to vendor/github.com/ethereum/go-ethereum/cmd/geth/chaincmd.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/consolecmd.go b/vendor/github.com/ethereum/go-ethereum/cmd/geth/consolecmd.go similarity index 86% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/geth/consolecmd.go rename to vendor/github.com/ethereum/go-ethereum/cmd/geth/consolecmd.go index f16d0a594..c3becc844 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/consolecmd.go +++ b/vendor/github.com/ethereum/go-ethereum/cmd/geth/consolecmd.go @@ -19,9 +19,11 @@ package main import ( "os" "os/signal" + "strings" "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/console" + "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" "gopkg.in/urfave/cli.v1" ) @@ -63,12 +65,12 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso // same time. func localConsole(ctx *cli.Context) error { // Create and start the node based on the CLI flags - node, _ := utils.MakeSystemNode(clientIdentifier, verString, relConfig, makeDefaultExtra(), ctx) + node := makeFullNode(ctx) startNode(ctx, node) defer node.Stop() // Attach to the newly started node and start the JavaScript console - client := rpc.NewClientRestartWrapper(func() rpc.Client { + client := rpc.NewClientRestartWrapper(func() *rpc.Client { client, err := node.Attach() if err != nil { utils.Fatalf("Failed to attach to the inproc geth: %v", err) @@ -103,8 +105,8 @@ func localConsole(ctx *cli.Context) error { // console to it. func remoteConsole(ctx *cli.Context) error { // Attach to a remotely running geth instance and start the JavaScript console - client := rpc.NewClientRestartWrapper(func() rpc.Client { - client, err := utils.NewRemoteRPCClient(ctx) + client := rpc.NewClientRestartWrapper(func() *rpc.Client { + client, err := dialRPC(ctx.Args().First()) if err != nil { utils.Fatalf("Unable to attach to remote geth: %v", err) } @@ -135,17 +137,31 @@ func remoteConsole(ctx *cli.Context) error { return nil } +// dialRPC returns a RPC client which connects to the given endpoint. +// The check for empty endpoint implements the defaulting logic +// for "geth attach" and "geth monitor" with no argument. +func dialRPC(endpoint string) (*rpc.Client, error) { + if endpoint == "" { + endpoint = node.DefaultIPCEndpoint() + } else if strings.HasPrefix(endpoint, "rpc:") || strings.HasPrefix(endpoint, "ipc:") { + // Backwards compatibility with geth < 1.5 which required + // these prefixes. + endpoint = endpoint[4:] + } + return rpc.Dial(endpoint) +} + // ephemeralConsole starts a new geth node, attaches an ephemeral JavaScript // console to it, and each of the files specified as arguments and tears the // everything down. func ephemeralConsole(ctx *cli.Context) error { // Create and start the node based on the CLI flags - node, _ := utils.MakeSystemNode(clientIdentifier, verString, relConfig, makeDefaultExtra(), ctx) + node := makeFullNode(ctx) startNode(ctx, node) defer node.Stop() // Attach to the newly started node and start the JavaScript console - client := rpc.NewClientRestartWrapper(func() rpc.Client { + client := rpc.NewClientRestartWrapper(func() *rpc.Client { client, err := node.Attach() if err != nil { utils.Fatalf("Failed to attach to the inproc geth: %v", err) diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/info_test.json b/vendor/github.com/ethereum/go-ethereum/cmd/geth/info_test.json similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/geth/info_test.json rename to vendor/github.com/ethereum/go-ethereum/cmd/geth/info_test.json diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/library.c b/vendor/github.com/ethereum/go-ethereum/cmd/geth/library.c similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/geth/library.c rename to vendor/github.com/ethereum/go-ethereum/cmd/geth/library.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/library.go b/vendor/github.com/ethereum/go-ethereum/cmd/geth/library.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/geth/library.go rename to vendor/github.com/ethereum/go-ethereum/cmd/geth/library.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/library_android.go b/vendor/github.com/ethereum/go-ethereum/cmd/geth/library_android.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/geth/library_android.go rename to vendor/github.com/ethereum/go-ethereum/cmd/geth/library_android.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/main.go b/vendor/github.com/ethereum/go-ethereum/cmd/geth/main.go similarity index 82% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/geth/main.go rename to vendor/github.com/ethereum/go-ethereum/cmd/geth/main.go index d35671da9..3ca79915f 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/main.go +++ b/vendor/github.com/ethereum/go-ethereum/cmd/geth/main.go @@ -29,7 +29,6 @@ import ( "time" "github.com/ethereum/ethash" - "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/console" @@ -250,34 +249,13 @@ func main() { } } -func makeDefaultExtra() []byte { - var clientInfo = struct { - Version uint - Name string - GoVersion string - Os string - }{uint(versionMajor<<16 | versionMinor<<8 | versionPatch), clientIdentifier, runtime.Version(), runtime.GOOS} - extra, err := rlp.EncodeToBytes(clientInfo) - if err != nil { - glog.V(logger.Warn).Infoln("error setting canonical miner information:", err) - } - - if uint64(len(extra)) > params.MaximumExtraDataSize.Uint64() { - glog.V(logger.Warn).Infoln("error setting canonical miner information: extra exceeds", params.MaximumExtraDataSize) - glog.V(logger.Debug).Infof("extra: %x\n", extra) - return nil - } - return extra -} - // geth is the main entry point into the system if no special subcommand is ran. // It creates a default node based on the command line arguments and runs it in // blocking mode, waiting for it to be shut down. func geth(ctx *cli.Context) error { - node, _ := utils.MakeSystemNode(clientIdentifier, verString, relConfig, makeDefaultExtra(), ctx) + node := makeFullNode(ctx) startNode(ctx, node) node.Wait() - return nil } @@ -307,6 +285,38 @@ func initGenesis(ctx *cli.Context) error { return nil } +func makeFullNode(ctx *cli.Context) *node.Node { + node := utils.MakeNode(ctx, clientIdentifier, verString) + utils.RegisterEthService(ctx, node, relConfig, makeDefaultExtra()) + // Whisper must be explicitly enabled, but is auto-enabled in --dev mode. + shhEnabled := ctx.GlobalBool(utils.WhisperEnabledFlag.Name) + shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DevModeFlag.Name) + if shhEnabled || shhAutoEnabled { + utils.RegisterShhService(node) + } + return node +} + +func makeDefaultExtra() []byte { + var clientInfo = struct { + Version uint + Name string + GoVersion string + Os string + }{uint(versionMajor<<16 | versionMinor<<8 | versionPatch), clientIdentifier, runtime.Version(), runtime.GOOS} + extra, err := rlp.EncodeToBytes(clientInfo) + if err != nil { + glog.V(logger.Warn).Infoln("error setting canonical miner information:", err) + } + + if uint64(len(extra)) > params.MaximumExtraDataSize.Uint64() { + glog.V(logger.Warn).Infoln("error setting canonical miner information: extra exceeds", params.MaximumExtraDataSize) + glog.V(logger.Debug).Infof("extra: %x\n", extra) + return nil + } + return extra +} + // startNode boots up the system node and all registered protocols, after which // it unlocks any requested accounts, and starts the RPC/IPC interfaces and the // miner. @@ -316,42 +326,47 @@ func startNode(ctx *cli.Context, stack *node.Node) { // Start up the node itself utils.StartNode(stack) - if !ctx.GlobalBool(utils.NoEthFlag.Name) { - if ctx.GlobalBool(utils.LightModeFlag.Name) && !ctx.GlobalBool(utils.NoDefSrvFlag.Name) { - // add default light server; test phase only - url := "enode://201aa667e0b75462c8837708dbc3c91b43f84d233efda2f4e2c5ae0ea237d646db656375b394fb35d841cf8ea2814e3629af4821d3b0204508f7eb8cea8e7f31@40.118.3.223:30303" - if ctx.GlobalBool(utils.TestNetFlag.Name) { - url = "enode://2737bebb1e70cf682553c974d9551b74a917cb4f61292150abc10d2c122c8d369c82cb2b71ff107120ea2547419d2d9e998c637d45a6ff57bb01e83cfc1d5115@40.118.3.223:30304" - //url = "enode://2737bebb1e70cf682553c974d9551b74a917cb4f61292150abc10d2c122c8d369c82cb2b71ff107120ea2547419d2d9e998c637d45a6ff57bb01e83cfc1d5115@[::]:30303" - } + if ctx.GlobalBool(utils.LightModeFlag.Name) && !ctx.GlobalBool(utils.NoDefSrvFlag.Name) { + // add default light server; test phase only + addPeer := func(url string) { node, err := discover.ParseNode(url) if err == nil { stack.Server().AddPeer(node) } } - // Unlock any account specifically requested - var accman *accounts.Manager - if err := stack.Service(&accman); err != nil { + if ctx.GlobalBool(utils.OpposeDAOFork.Name) { + // Classic (Azure) + addPeer("enode://fc3d7b57e5d317946bf421411632ec98d5ffcbf94548cd7bc10088e4fef176670f8ec70280d301a9d0b22fe498203f62b323da15b3acc18b02a1fee2a06b7d3f@40.118.3.223:30305") + } else { + // MainNet (Azure) + addPeer("enode://feaf206a308a669a789be45f4dadcb351246051727f12415ad69e44f8080daf0569c10fe1d9944d245dd1f3e1c89cedda8ce03d7e3d5ed8975a35cad4b4f7ec1@40.118.3.223:30303") + // MainNet (John Gerryts @phonikg) + addPeer("enode://3cbd26f73513af0e789c55ea9efa6d259be2d5f6882bdb52740e21e01379287b652642a87207f1bc07c64aae3ab51ab566dede7588d6064022d40577fe59d5de@50.112.52.169:30300") + } + if ctx.GlobalBool(utils.TestNetFlag.Name) { + // TestNet (John Gerryts @phonikg) + addPeer("enode://7d00e8c27b2328e2008a9fc86e81afba22681fdac675b99805fa62cc29ee8a2a9d83f916f7661da6a6bd78155a430bb2bd7cec733ca9e700e236ec9c71d97e24@50.112.52.169:30301") + } + } + + // Unlock any account specifically requested + accman := stack.AccountManager() + passwords := utils.MakePasswordList(ctx) + accounts := strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") + for i, account := range accounts { + if trimmed := strings.TrimSpace(account); trimmed != "" { + unlockAccount(ctx, accman, trimmed, i, passwords) + } + } + // Start auxiliary services if enabled + if ctx.GlobalBool(utils.MiningEnabledFlag.Name) { + var ethereum *eth.Ethereum + if err := stack.Service(ðereum); err != nil { utils.Fatalf("ethereum service not running: %v", err) } - passwords := utils.MakePasswordList(ctx) - - accounts := strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") - for i, account := range accounts { - if trimmed := strings.TrimSpace(account); trimmed != "" { - unlockAccount(ctx, accman, trimmed, i, passwords) - } - } - // Start auxiliary services if enabled - if ctx.GlobalBool(utils.MiningEnabledFlag.Name) { - var ethereum *eth.Ethereum - if err := stack.Service(ðereum); err != nil { - utils.Fatalf("ethereum service not running: %v", err) - } - if err := ethereum.StartMining(ctx.GlobalInt(utils.MinerThreadsFlag.Name), ctx.GlobalString(utils.MiningGPUFlag.Name)); err != nil { - utils.Fatalf("Failed to start mining: %v", err) - } + if err := ethereum.StartMining(ctx.GlobalInt(utils.MinerThreadsFlag.Name), ctx.GlobalString(utils.MiningGPUFlag.Name)); err != nil { + utils.Fatalf("Failed to start mining: %v", err) } } } diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/monitorcmd.go b/vendor/github.com/ethereum/go-ethereum/cmd/geth/monitorcmd.go similarity index 92% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/geth/monitorcmd.go rename to vendor/github.com/ethereum/go-ethereum/cmd/geth/monitorcmd.go index 11fdca89c..d1490dce2 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/monitorcmd.go +++ b/vendor/github.com/ethereum/go-ethereum/cmd/geth/monitorcmd.go @@ -21,11 +21,10 @@ import ( "math" "reflect" "runtime" + "sort" "strings" "time" - "sort" - "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" @@ -36,7 +35,7 @@ import ( var ( monitorCommandAttachFlag = cli.StringFlag{ Name: "attach", - Value: "ipc:" + node.DefaultIPCEndpoint(), + Value: node.DefaultIPCEndpoint(), Usage: "API endpoint to attach to", } monitorCommandRowsFlag = cli.IntFlag{ @@ -69,12 +68,12 @@ to display multiple metrics simultaneously. // monitor starts a terminal UI based monitoring tool for the requested metrics. func monitor(ctx *cli.Context) error { var ( - client rpc.Client + client *rpc.Client err error ) // Attach to an Ethereum node over IPC or RPC endpoint := ctx.String(monitorCommandAttachFlag.Name) - if client, err = utils.NewRemoteRPCClientFromString(endpoint); err != nil { + if client, err = dialRPC(endpoint); err != nil { utils.Fatalf("Unable to attach to geth node: %v", err) } defer client.Close() @@ -159,30 +158,10 @@ func monitor(ctx *cli.Context) error { // retrieveMetrics contacts the attached geth node and retrieves the entire set // of collected system metrics. -func retrieveMetrics(client rpc.Client) (map[string]interface{}, error) { - req := map[string]interface{}{ - "id": new(int64), - "method": "debug_metrics", - "jsonrpc": "2.0", - "params": []interface{}{true}, - } - - if err := client.Send(req); err != nil { - return nil, err - } - - var res rpc.JSONSuccessResponse - if err := client.Recv(&res); err != nil { - return nil, err - } - - if res.Result != nil { - if mets, ok := res.Result.(map[string]interface{}); ok { - return mets, nil - } - } - - return nil, fmt.Errorf("unable to retrieve metrics") +func retrieveMetrics(client *rpc.Client) (map[string]interface{}, error) { + var metrics map[string]interface{} + err := client.Call(&metrics, "debug_metrics", true) + return metrics, err } // resolveMetrics takes a list of input metric patterns, and resolves each to one @@ -270,7 +249,7 @@ func fetchMetric(metrics map[string]interface{}, metric string) float64 { // refreshCharts retrieves a next batch of metrics, and inserts all the new // values into the active datasets and charts -func refreshCharts(client rpc.Client, metrics []string, data [][]float64, units []int, charts []*termui.LineChart, ctx *cli.Context, footer *termui.Par) (realign bool) { +func refreshCharts(client *rpc.Client, metrics []string, data [][]float64, units []int, charts []*termui.LineChart, ctx *cli.Context, footer *termui.Par) (realign bool) { values, err := retrieveMetrics(client) for i, metric := range metrics { if len(data) < 512 { diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/geth/usage.go b/vendor/github.com/ethereum/go-ethereum/cmd/geth/usage.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/geth/usage.go rename to vendor/github.com/ethereum/go-ethereum/cmd/geth/usage.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/gethrpctest/main.go b/vendor/github.com/ethereum/go-ethereum/cmd/gethrpctest/main.go similarity index 83% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/gethrpctest/main.go rename to vendor/github.com/ethereum/go-ethereum/cmd/gethrpctest/main.go index 2e07e9426..d267dbf58 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/cmd/gethrpctest/main.go +++ b/vendor/github.com/ethereum/go-ethereum/cmd/gethrpctest/main.go @@ -19,12 +19,10 @@ package main import ( "flag" - "io/ioutil" "log" "os" "os/signal" - "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/crypto" @@ -61,14 +59,8 @@ func main() { if !found { log.Fatalf("Requested test (%s) not found within suite", *testName) } - // Create the protocol stack to run the test with - keydir, err := ioutil.TempDir("", "") - if err != nil { - log.Fatalf("Failed to create temporary keystore directory: %v", err) - } - defer os.RemoveAll(keydir) - stack, err := MakeSystemNode(keydir, *testKey, test) + stack, err := MakeSystemNode(*testKey, test) if err != nil { log.Fatalf("Failed to assemble test stack: %v", err) } @@ -92,23 +84,24 @@ func main() { // MakeSystemNode configures a protocol stack for the RPC tests based on a given // keystore path and initial pre-state. -func MakeSystemNode(keydir string, privkey string, test *tests.BlockTest) (*node.Node, error) { +func MakeSystemNode(privkey string, test *tests.BlockTest) (*node.Node, error) { // Create a networkless protocol stack stack, err := node.New(&node.Config{ - IPCPath: node.DefaultIPCEndpoint(), - HTTPHost: common.DefaultHTTPHost, - HTTPPort: common.DefaultHTTPPort, - HTTPModules: []string{"admin", "db", "eth", "debug", "miner", "net", "shh", "txpool", "personal", "web3"}, - WSHost: common.DefaultWSHost, - WSPort: common.DefaultWSPort, - WSModules: []string{"admin", "db", "eth", "debug", "miner", "net", "shh", "txpool", "personal", "web3"}, - NoDiscovery: true, + UseLightweightKDF: true, + IPCPath: node.DefaultIPCEndpoint(), + HTTPHost: common.DefaultHTTPHost, + HTTPPort: common.DefaultHTTPPort, + HTTPModules: []string{"admin", "db", "eth", "debug", "miner", "net", "shh", "txpool", "personal", "web3"}, + WSHost: common.DefaultWSHost, + WSPort: common.DefaultWSPort, + WSModules: []string{"admin", "db", "eth", "debug", "miner", "net", "shh", "txpool", "personal", "web3"}, + NoDiscovery: true, }) if err != nil { return nil, err } // Create the keystore and inject an unlocked account if requested - accman := accounts.NewPlaintextManager(keydir) + accman := stack.AccountManager() if len(privkey) > 0 { key, err := crypto.HexToECDSA(privkey) if err != nil { @@ -131,7 +124,6 @@ func MakeSystemNode(keydir string, privkey string, test *tests.BlockTest) (*node TestGenesisState: db, TestGenesisBlock: test.Genesis, ChainConfig: &core.ChainConfig{HomesteadBlock: params.MainNetHomesteadBlock}, - AccountManager: accman, } if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { return eth.New(ctx, ethConf) }); err != nil { return nil, err diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/rlpdump/main.go b/vendor/github.com/ethereum/go-ethereum/cmd/rlpdump/main.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/rlpdump/main.go rename to vendor/github.com/ethereum/go-ethereum/cmd/rlpdump/main.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/utils/bootnodes.go b/vendor/github.com/ethereum/go-ethereum/cmd/utils/bootnodes.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/utils/bootnodes.go rename to vendor/github.com/ethereum/go-ethereum/cmd/utils/bootnodes.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/utils/cmd.go b/vendor/github.com/ethereum/go-ethereum/cmd/utils/cmd.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/utils/cmd.go rename to vendor/github.com/ethereum/go-ethereum/cmd/utils/cmd.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/utils/customflags.go b/vendor/github.com/ethereum/go-ethereum/cmd/utils/customflags.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/utils/customflags.go rename to vendor/github.com/ethereum/go-ethereum/cmd/utils/customflags.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_freebsd.go b/vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_freebsd.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_freebsd.go rename to vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_freebsd.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_unix.go b/vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_unix.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_unix.go rename to vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_unix.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_windows.go b/vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_windows.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_windows.go rename to vendor/github.com/ethereum/go-ethereum/cmd/utils/fdlimit_windows.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/cmd/utils/flags.go b/vendor/github.com/ethereum/go-ethereum/cmd/utils/flags.go similarity index 86% rename from src/vendor/github.com/ethereum/go-ethereum/cmd/utils/flags.go rename to vendor/github.com/ethereum/go-ethereum/cmd/utils/flags.go index 82a2fceed..9d2a23abf 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/cmd/utils/flags.go +++ b/vendor/github.com/ethereum/go-ethereum/cmd/utils/flags.go @@ -373,7 +373,7 @@ var ( } NoEthFlag = cli.BoolFlag{ Name: "noeth", - Usage: "Disable eth Protocol", + Usage: "Disable Ethereum Protocol", } WhisperEnabledFlag = cli.BoolFlag{ Name: "shh", @@ -445,16 +445,6 @@ func MustMakeDataDir(ctx *cli.Context) string { return "" } -// MakeKeyStoreDir resolves the folder to use for storing the account keys from the -// set command line flags, returning the explicitly requested path, or one inside -// the data directory otherwise. -func MakeKeyStoreDir(datadir string, ctx *cli.Context) string { - if path := ctx.GlobalString(KeyStoreDirFlag.Name); path != "" { - return path - } - return filepath.Join(datadir, "keystore") -} - // MakeIPCPath creates an IPC path configuration from the set command line flags, // returning an empty string if IPC was explicitly disabled, or the set path. func MakeIPCPath(ctx *cli.Context) string { @@ -587,20 +577,6 @@ func MakeDatabaseHandles() int { return limit / 2 // Leave half for networking and other stuff } -// MakeAccountManager creates an account manager from set command line flags. -func MakeAccountManager(ctx *cli.Context, accountSync *[]node.Service) *accounts.Manager { - // Create the keystore crypto primitive, light if requested - scryptN := accounts.StandardScryptN - scryptP := accounts.StandardScryptP - if ctx.GlobalBool(LightKDFFlag.Name) { - scryptN = accounts.LightScryptN - scryptP = accounts.LightScryptP - } - datadir := MustMakeDataDir(ctx) - keydir := MakeKeyStoreDir(datadir, ctx) - return accounts.NewManager(keydir, scryptN, scryptP, accountSync) -} - // MakeAddress converts an account specified directly as a hex encoded string or // a key index in the key store to an internal account representation. func MakeAddress(accman *accounts.Manager, account string) (accounts.Account, error) { @@ -663,9 +639,54 @@ func MakePasswordList(ctx *cli.Context) []string { return lines } -// MakeSystemNode sets up a local node, configures the services to launch and -// assembles the P2P protocol stack. -func MakeSystemNode(name, version string, relconf release.Config, extra []byte, ctx *cli.Context) (*node.Node, *[]node.Service) { +// MakeNode configures a node with no services from command line flags. +func MakeNode(ctx *cli.Context, name, version string) *node.Node { + config := &node.Config{ + DataDir: MustMakeDataDir(ctx), + KeyStoreDir: ctx.GlobalString(KeyStoreDirFlag.Name), + UseLightweightKDF: ctx.GlobalBool(LightKDFFlag.Name), + PrivateKey: MakeNodeKey(ctx), + Name: MakeNodeName(name, version, ctx), + NoDiscovery: ctx.GlobalBool(NoDiscoverFlag.Name), + BootstrapNodes: MakeBootstrapNodes(ctx), + ListenAddr: MakeListenAddress(ctx), + NAT: MakeNAT(ctx), + MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name), + MaxPendingPeers: ctx.GlobalInt(MaxPendingPeersFlag.Name), + IPCPath: MakeIPCPath(ctx), + HTTPHost: MakeHTTPRpcHost(ctx), + HTTPPort: ctx.GlobalInt(RPCPortFlag.Name), + HTTPCors: ctx.GlobalString(RPCCORSDomainFlag.Name), + HTTPModules: MakeRPCModules(ctx.GlobalString(RPCApiFlag.Name)), + WSHost: MakeWSRpcHost(ctx), + WSPort: ctx.GlobalInt(WSPortFlag.Name), + WSOrigins: ctx.GlobalString(WSAllowedOriginsFlag.Name), + WSModules: MakeRPCModules(ctx.GlobalString(WSApiFlag.Name)), + } + if ctx.GlobalBool(DevModeFlag.Name) { + if !ctx.GlobalIsSet(DataDirFlag.Name) { + config.DataDir = filepath.Join(os.TempDir(), "/ethereum_dev_mode") + } + // --dev mode does not need p2p networking. + config.MaxPeers = 0 + config.ListenAddr = ":0" + } + stack, err := node.New(config) + if err != nil { + Fatalf("Failed to create the protocol stack: %v", err) + } + return stack +} + +// RegisterEthService configures eth.Ethereum from command line flags and adds it to the +// given node. +func RegisterEthService(ctx *cli.Context, stack *node.Node, relconf release.Config, extra []byte) { + ethDisabled := ctx.GlobalBool(NoEthFlag.Name) + if ethDisabled { + glog.V(logger.Info).Infof("Ethereum service registration by-passed (--%s flag used)\n", NoEthFlag.Name) + return + } + // Avoid conflicting network flags networks, netFlags := 0, []cli.BoolFlag{DevModeFlag, TestNetFlag, OlympicFlag} for _, flag := range netFlags { @@ -676,30 +697,6 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte, if networks > 1 { Fatalf("The %v flags are mutually exclusive", netFlags) } - // Configure the node's service container - stackConf := &node.Config{ - DataDir: MustMakeDataDir(ctx), - PrivateKey: MakeNodeKey(ctx), - Name: MakeNodeName(name, version, ctx), - NoDiscovery: ctx.GlobalBool(NoDiscoverFlag.Name) || ctx.GlobalBool(LightModeFlag.Name), // light client hack - BootstrapNodes: MakeBootstrapNodes(ctx), - ListenAddr: MakeListenAddress(ctx), - NAT: MakeNAT(ctx), - MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name), - MaxPendingPeers: ctx.GlobalInt(MaxPendingPeersFlag.Name), - IPCPath: MakeIPCPath(ctx), - HTTPHost: MakeHTTPRpcHost(ctx), - HTTPPort: ctx.GlobalInt(RPCPortFlag.Name), - HTTPCors: ctx.GlobalString(RPCCORSDomainFlag.Name), - HTTPModules: MakeRPCModules(ctx.GlobalString(RPCApiFlag.Name)), - WSHost: MakeWSRpcHost(ctx), - WSPort: ctx.GlobalInt(WSPortFlag.Name), - WSOrigins: ctx.GlobalString(WSAllowedOriginsFlag.Name), - WSModules: MakeRPCModules(ctx.GlobalString(WSApiFlag.Name)), - } - // Configure the Ethereum service - var accountSync []node.Service - accman := MakeAccountManager(ctx, &accountSync) // initialise new random number generator rand := rand.New(rand.NewSource(time.Now().UnixNano())) @@ -712,6 +709,7 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte, } ethConf := ð.Config{ + Etherbase: MakeEtherbase(stack.AccountManager(), ctx), ChainConfig: MustMakeChainConfig(ctx), FastSync: ctx.GlobalBool(FastSyncFlag.Name), LightMode: ctx.GlobalBool(LightModeFlag.Name), @@ -722,8 +720,6 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte, DatabaseCache: ctx.GlobalInt(CacheFlag.Name), DatabaseHandles: MakeDatabaseHandles(), NetworkId: ctx.GlobalInt(NetworkIdFlag.Name), - AccountManager: accman, - Etherbase: MakeEtherbase(accman, ctx), MinerThreads: ctx.GlobalInt(MinerThreadsFlag.Name), ExtraData: MakeMinerExtra(extra, ctx), NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name), @@ -741,12 +737,6 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte, AutoDAG: ctx.GlobalBool(AutoDAGFlag.Name) || ctx.GlobalBool(MiningEnabledFlag.Name), } - // Configure the Whisper service - shhEnable := ctx.GlobalBool(WhisperEnabledFlag.Name) - - // Configure the Ethereum service - ethDisable := ctx.GlobalBool(NoEthFlag.Name) - // Override any default configs in dev mode or the test net switch { case ctx.GlobalBool(OlympicFlag.Name): @@ -764,77 +754,43 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte, light.StartingNonce = 1048576 // (2**20) case ctx.GlobalBool(DevModeFlag.Name): - // Override the base network stack configs - if !ctx.GlobalIsSet(DataDirFlag.Name) { - stackConf.DataDir = filepath.Join(os.TempDir(), "/ethereum_dev_mode") - } - if !ctx.GlobalIsSet(MaxPeersFlag.Name) { - stackConf.MaxPeers = 0 - } - if !ctx.GlobalIsSet(ListenPortFlag.Name) { - stackConf.ListenAddr = ":0" - } - // Override the Ethereum protocol configs ethConf.Genesis = core.OlympicGenesisBlock() if !ctx.GlobalIsSet(GasPriceFlag.Name) { ethConf.GasPrice = new(big.Int) } - if !ctx.GlobalIsSet(WhisperEnabledFlag.Name) { - shhEnable = true - } ethConf.PowTest = true } - // Assemble and return the protocol stack - stack, err := node.New(stackConf) - if err != nil { - Fatalf("Failed to create the protocol stack: %v", err) - } - - if shhEnable { - if err := stack.Register(func(*node.ServiceContext) (node.Service, error) { - whisperInstance := whisper.New() - accountSync = append(accountSync, whisperInstance) - return whisperInstance, nil + if ethConf.LightMode { + if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { + return les.New(ctx, ethConf) }); err != nil { - Fatalf("Failed to register the Whisper service: %v", err) + Fatalf("Failed to register the Ethereum light node service: %v", err) + } + } else { + if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { + fullNode, err := eth.New(ctx, ethConf) + if fullNode != nil { + ls, _ := les.NewLesServer(fullNode, ethConf) + fullNode.AddLesServer(ls) + } + return fullNode, err + }); err != nil { + Fatalf("Failed to register the Ethereum full node service: %v", err) } } - if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - return accman, nil + return release.NewReleaseService(ctx, relconf) }); err != nil { - Fatalf("Failed to register the account manager service: %v", err) + Fatalf("Failed to register the Geth release oracle service: %v", err) } +} - if !ethDisable { - if ethConf.LightMode { - if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - return les.New(ctx, ethConf) - }); err != nil { - Fatalf("Failed to register the Ethereum light node service: %v", err) - } - } else { - if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - fullNode, err := eth.New(ctx, ethConf) - if fullNode != nil { - ls, _ := les.NewLesServer(fullNode, ethConf) - fullNode.AddLesServer(ls) - } - return fullNode, err - }); err != nil { - Fatalf("Failed to register the Ethereum full node service: %v", err) - } - if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - return release.NewReleaseService(ctx, relconf) - }); err != nil { - Fatalf("Failed to register the Geth release oracle service: %v", err) - } - - } +// RegisterShhService configures whisper and adds it to the given node. +func RegisterShhService(stack *node.Node) { + if err := stack.Register(func(*node.ServiceContext) (node.Service, error) { return whisper.New(), nil }); err != nil { + Fatalf("Failed to register the Whisper service: %v", err) } - - return stack, &accountSync } // SetupNetwork configures the system for either the main net or some test network. diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/big.go b/vendor/github.com/ethereum/go-ethereum/common/big.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/big.go rename to vendor/github.com/ethereum/go-ethereum/common/big.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/bytes.go b/vendor/github.com/ethereum/go-ethereum/common/bytes.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/bytes.go rename to vendor/github.com/ethereum/go-ethereum/common/bytes.go diff --git a/vendor/github.com/ethereum/go-ethereum/common/compiler/solidity.go b/vendor/github.com/ethereum/go-ethereum/common/compiler/solidity.go new file mode 100644 index 000000000..b682107d9 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/common/compiler/solidity.go @@ -0,0 +1,196 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +// Package compiler wraps the Solidity compiler executable (solc). +package compiler + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + "io/ioutil" + "os" + "os/exec" + "regexp" + "strings" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" +) + +var ( + versionRegexp = regexp.MustCompile("[0-9]+\\.[0-9]+\\.[0-9]+") + solcParams = []string{ + "--combined-json", "bin,abi,userdoc,devdoc", + "--add-std", // include standard lib contracts + "--optimize", // code optimizer switched on + } +) + +type Contract struct { + Code string `json:"code"` + Info ContractInfo `json:"info"` +} + +type ContractInfo struct { + Source string `json:"source"` + Language string `json:"language"` + LanguageVersion string `json:"languageVersion"` + CompilerVersion string `json:"compilerVersion"` + CompilerOptions string `json:"compilerOptions"` + AbiDefinition interface{} `json:"abiDefinition"` + UserDoc interface{} `json:"userDoc"` + DeveloperDoc interface{} `json:"developerDoc"` +} + +// Solidity contains information about the solidity compiler. +type Solidity struct { + Path, Version, FullVersion string +} + +// --combined-output format +type solcOutput struct { + Contracts map[string]struct{ Bin, Abi, Devdoc, Userdoc string } + Version string +} + +// SolidityVersion runs solc and parses its version output. +func SolidityVersion(solc string) (*Solidity, error) { + if solc == "" { + solc = "solc" + } + var out bytes.Buffer + cmd := exec.Command(solc, "--version") + cmd.Stdout = &out + if err := cmd.Run(); err != nil { + return nil, err + } + s := &Solidity{ + Path: cmd.Path, + FullVersion: out.String(), + Version: versionRegexp.FindString(out.String()), + } + return s, nil +} + +// CompileSolidityString builds and returns all the contracts contained within a source string. +func CompileSolidityString(solc, source string) (map[string]*Contract, error) { + if len(source) == 0 { + return nil, errors.New("solc: empty source string") + } + if solc == "" { + solc = "solc" + } + // Write source to a temporary file. Compiling stdin used to be supported + // but seems to produce an exception with solc 0.3.5. + infile, err := ioutil.TempFile("", "geth-compile-solidity") + if err != nil { + return nil, err + } + defer os.Remove(infile.Name()) + if _, err := io.WriteString(infile, source); err != nil { + return nil, err + } + if err := infile.Close(); err != nil { + return nil, err + } + + return CompileSolidity(solc, infile.Name()) +} + +// CompileSolidity compiles all given Solidity source files. +func CompileSolidity(solc string, sourcefiles ...string) (map[string]*Contract, error) { + if len(sourcefiles) == 0 { + return nil, errors.New("solc: no source ") + } + source, err := slurpFiles(sourcefiles) + if err != nil { + return nil, err + } + if solc == "" { + solc = "solc" + } + + var stderr, stdout bytes.Buffer + args := append(solcParams, "--") + cmd := exec.Command(solc, append(args, sourcefiles...)...) + cmd.Stderr = &stderr + cmd.Stdout = &stdout + if err := cmd.Run(); err != nil { + return nil, fmt.Errorf("solc: %v\n%s", err, stderr.Bytes()) + } + var output solcOutput + if err := json.Unmarshal(stdout.Bytes(), &output); err != nil { + return nil, err + } + shortVersion := versionRegexp.FindString(output.Version) + + // Compilation succeeded, assemble and return the contracts. + contracts := make(map[string]*Contract) + for name, info := range output.Contracts { + // Parse the individual compilation results. + var abi interface{} + if err := json.Unmarshal([]byte(info.Abi), &abi); err != nil { + return nil, fmt.Errorf("solc: error reading abi definition (%v)", err) + } + var userdoc interface{} + if err := json.Unmarshal([]byte(info.Userdoc), &userdoc); err != nil { + return nil, fmt.Errorf("solc: error reading user doc: %v", err) + } + var devdoc interface{} + if err := json.Unmarshal([]byte(info.Devdoc), &devdoc); err != nil { + return nil, fmt.Errorf("solc: error reading dev doc: %v", err) + } + contracts[name] = &Contract{ + Code: "0x" + info.Bin, + Info: ContractInfo{ + Source: source, + Language: "Solidity", + LanguageVersion: shortVersion, + CompilerVersion: shortVersion, + CompilerOptions: strings.Join(solcParams, " "), + AbiDefinition: abi, + UserDoc: userdoc, + DeveloperDoc: devdoc, + }, + } + } + return contracts, nil +} + +func slurpFiles(files []string) (string, error) { + var concat bytes.Buffer + for _, file := range files { + content, err := ioutil.ReadFile(file) + if err != nil { + return "", err + } + concat.Write(content) + } + return concat.String(), nil +} + +// SaveInfo serializes info to the given file and returns its Keccak256 hash. +func SaveInfo(info *ContractInfo, filename string) (common.Hash, error) { + infojson, err := json.Marshal(info) + if err != nil { + return common.Hash{}, err + } + contenthash := common.BytesToHash(crypto.Keccak256(infojson)) + return contenthash, ioutil.WriteFile(filename, infojson, 0600) +} diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/debug.go b/vendor/github.com/ethereum/go-ethereum/common/debug.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/debug.go rename to vendor/github.com/ethereum/go-ethereum/common/debug.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/defaults.go b/vendor/github.com/ethereum/go-ethereum/common/defaults.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/defaults.go rename to vendor/github.com/ethereum/go-ethereum/common/defaults.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/httpclient/httpclient.go b/vendor/github.com/ethereum/go-ethereum/common/httpclient/httpclient.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/httpclient/httpclient.go rename to vendor/github.com/ethereum/go-ethereum/common/httpclient/httpclient.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/icap.go b/vendor/github.com/ethereum/go-ethereum/common/icap.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/icap.go rename to vendor/github.com/ethereum/go-ethereum/common/icap.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/list.go b/vendor/github.com/ethereum/go-ethereum/common/list.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/list.go rename to vendor/github.com/ethereum/go-ethereum/common/list.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/math/dist.go b/vendor/github.com/ethereum/go-ethereum/common/math/dist.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/math/dist.go rename to vendor/github.com/ethereum/go-ethereum/common/math/dist.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/mclock/mclock.go b/vendor/github.com/ethereum/go-ethereum/common/mclock/mclock.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/mclock/mclock.go rename to vendor/github.com/ethereum/go-ethereum/common/mclock/mclock.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/natspec/natspec.go b/vendor/github.com/ethereum/go-ethereum/common/natspec/natspec.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/natspec/natspec.go rename to vendor/github.com/ethereum/go-ethereum/common/natspec/natspec.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/natspec/natspec_js.go b/vendor/github.com/ethereum/go-ethereum/common/natspec/natspec_js.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/natspec/natspec_js.go rename to vendor/github.com/ethereum/go-ethereum/common/natspec/natspec_js.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/number/int.go b/vendor/github.com/ethereum/go-ethereum/common/number/int.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/number/int.go rename to vendor/github.com/ethereum/go-ethereum/common/number/int.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/path.go b/vendor/github.com/ethereum/go-ethereum/common/path.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/path.go rename to vendor/github.com/ethereum/go-ethereum/common/path.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/registrar/contracts.go b/vendor/github.com/ethereum/go-ethereum/common/registrar/contracts.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/registrar/contracts.go rename to vendor/github.com/ethereum/go-ethereum/common/registrar/contracts.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/registrar/ethreg/api.go b/vendor/github.com/ethereum/go-ethereum/common/registrar/ethreg/api.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/registrar/ethreg/api.go rename to vendor/github.com/ethereum/go-ethereum/common/registrar/ethreg/api.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/registrar/registrar.go b/vendor/github.com/ethereum/go-ethereum/common/registrar/registrar.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/registrar/registrar.go rename to vendor/github.com/ethereum/go-ethereum/common/registrar/registrar.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/size.go b/vendor/github.com/ethereum/go-ethereum/common/size.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/size.go rename to vendor/github.com/ethereum/go-ethereum/common/size.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/test_utils.go b/vendor/github.com/ethereum/go-ethereum/common/test_utils.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/test_utils.go rename to vendor/github.com/ethereum/go-ethereum/common/test_utils.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/types.go b/vendor/github.com/ethereum/go-ethereum/common/types.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/types.go rename to vendor/github.com/ethereum/go-ethereum/common/types.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/common/types_template.go b/vendor/github.com/ethereum/go-ethereum/common/types_template.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/common/types_template.go rename to vendor/github.com/ethereum/go-ethereum/common/types_template.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/compression/rle/read_write.go b/vendor/github.com/ethereum/go-ethereum/compression/rle/read_write.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/compression/rle/read_write.go rename to vendor/github.com/ethereum/go-ethereum/compression/rle/read_write.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/console/bridge.go b/vendor/github.com/ethereum/go-ethereum/console/bridge.go similarity index 66% rename from src/vendor/github.com/ethereum/go-ethereum/console/bridge.go rename to vendor/github.com/ethereum/go-ethereum/console/bridge.go index 65f2541b0..3009eabc4 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/console/bridge.go +++ b/vendor/github.com/ethereum/go-ethereum/console/bridge.go @@ -194,45 +194,42 @@ func (b *bridge) SleepBlocks(call otto.FunctionCall) (response otto.Value) { return otto.FalseValue() } -// Send will serialize the first argument, send it to the node and returns the response. +type jsonrpcCall struct { + Id int64 + Method string + Params []interface{} +} + +// Send implements the web3 provider "send" method. func (b *bridge) Send(call otto.FunctionCall) (response otto.Value) { - // Ensure that we've got a batch request (array) or a single request (object) - arg := call.Argument(0).Object() - if arg == nil || (arg.Class() != "Array" && arg.Class() != "Object") { - throwJSException("request must be an object or array") - } - // Convert the otto VM arguments to Go values - data, err := call.Otto.Call("JSON.stringify", nil, arg) + // Remarshal the request into a Go value. + JSON, _ := call.Otto.Object("JSON") + reqVal, err := JSON.Call("stringify", call.Argument(0)) if err != nil { throwJSException(err.Error()) } - reqjson, err := data.ToString() - if err != nil { - throwJSException(err.Error()) - } - var ( - reqs []rpc.JSONRequest - batch = true + rawReq = []byte(reqVal.String()) + reqs []jsonrpcCall + batch bool ) - if err = json.Unmarshal([]byte(reqjson), &reqs); err != nil { - // single request? - reqs = make([]rpc.JSONRequest, 1) - if err = json.Unmarshal([]byte(reqjson), &reqs[0]); err != nil { - throwJSException("invalid request") - } + if rawReq[0] == '[' { + batch = true + json.Unmarshal(rawReq, &reqs) + } else { batch = false + reqs = make([]jsonrpcCall, 1) + json.Unmarshal(rawReq, &reqs[0]) } - // Iteratively execute the requests - call.Otto.Set("response_len", len(reqs)) - call.Otto.Run("var ret_response = new Array(response_len);") - for i, req := range reqs { - // Execute the RPC request and parse the reply + // Execute the requests. + resps, _ := call.Otto.Object("new Array()") + for _, req := range reqs { + resp, _ := call.Otto.Object(`({"jsonrpc":"2.0"})`) + resp.Set("id", req.Id) + var result json.RawMessage + client := b.client.Client() - if err = client.Send(&req); err != nil { - return newErrorResponse(call, -32603, err.Error(), req.Id) - } errc := make(chan error, 1) errc2 := make(chan error) go func(){ @@ -248,52 +245,54 @@ func (b *bridge) Send(call otto.FunctionCall) (response otto.Value) { errc2 <- <-errc } }() - result := make(map[string]interface{}) - errc <- client.Recv(&result) - err := <-errc2 - if err != nil { - return newErrorResponse(call, -32603, err.Error(), req.Id) - } - // Feed the reply back into the JavaScript runtime environment - id, _ := result["id"] - jsonver, _ := result["jsonrpc"] + errc <- client.Call(&result, req.Method, req.Params...) + err = <-errc2 - call.Otto.Set("ret_id", id) - call.Otto.Set("ret_jsonrpc", jsonver) - call.Otto.Set("response_idx", i) + switch err := err.(type) { + case nil: + if result == nil { + // Special case null because it is decoded as an empty + // raw message for some reason. + resp.Set("result", otto.NullValue()) + } else { + resultVal, err := JSON.Call("parse", string(result)) + if err != nil { + resp = newErrorResponse(call, -32603, err.Error(), &req.Id).Object() + } else { + resp.Set("result", resultVal) + } + } + case rpc.Error: + resp.Set("error", map[string]interface{}{ + "code": err.ErrorCode(), + "message": err.Error(), + }) + default: + resp = newErrorResponse(call, -32603, err.Error(), &req.Id).Object() + } + resps.Call("push", resp) + } - if res, ok := result["result"]; ok { - payload, _ := json.Marshal(res) - call.Otto.Set("ret_result", string(payload)) - response, err = call.Otto.Run(` - ret_response[response_idx] = { jsonrpc: ret_jsonrpc, id: ret_id, result: JSON.parse(ret_result) }; - `) - continue - } - if res, ok := result["error"]; ok { - payload, _ := json.Marshal(res) - call.Otto.Set("ret_result", string(payload)) - response, err = call.Otto.Run(` - ret_response[response_idx] = { jsonrpc: ret_jsonrpc, id: ret_id, error: JSON.parse(ret_result) }; - `) - continue - } - return newErrorResponse(call, -32603, fmt.Sprintf("Invalid response"), new(int64)) + // Return the responses either to the callback (if supplied) + // or directly as the return value. + if batch { + response = resps.Value() + } else { + response, _ = resps.Get("0") } - // Convert single requests back from batch ones - if !batch { - call.Otto.Run("ret_response = ret_response[0];") + if fn := call.Argument(1); fn.Class() == "Function" { + fn.Call(otto.NullValue(), otto.NullValue(), response) + return otto.UndefinedValue() } - // Execute any registered callbacks - if call.Argument(1).IsObject() { - call.Otto.Set("callback", call.Argument(1)) - call.Otto.Run(` - if (Object.prototype.toString.call(callback) == '[object Function]') { - callback(null, ret_response); - } - `) - } - return + return response +} + +func newErrorResponse(call otto.FunctionCall, code int, msg string, id interface{}) otto.Value { + // Bundle the error into a JSON RPC call response + m := map[string]interface{}{"version": "2.0", "id": id, "error": map[string]interface{}{"code": code, msg: msg}} + res, _ := json.Marshal(m) + val, _ := call.Otto.Run("(" + string(res) + ")") + return val } // throwJSException panics on an otto.Value. The Otto VM will recover from the @@ -305,37 +304,3 @@ func throwJSException(msg interface{}) otto.Value { } panic(val) } - -// newErrorResponse creates a JSON RPC error response for a specific request id, -// containing the specified error code and error message. Beside returning the -// error to the caller, it also sets the ret_error and ret_response JavaScript -// variables. -func newErrorResponse(call otto.FunctionCall, code int, msg string, id interface{}) (response otto.Value) { - // Bundle the error into a JSON RPC call response - res := rpc.JSONErrResponse{ - Version: rpc.JSONRPCVersion, - Id: id, - Error: rpc.JSONError{ - Code: code, - Message: msg, - }, - } - // Serialize the error response into JavaScript variables - errObj, err := json.Marshal(res.Error) - if err != nil { - glog.V(logger.Error).Infof("Failed to serialize JSON RPC error: %v", err) - } - resObj, err := json.Marshal(res) - if err != nil { - glog.V(logger.Error).Infof("Failed to serialize JSON RPC error response: %v", err) - } - - if _, err = call.Otto.Run("ret_error = " + string(errObj)); err != nil { - glog.V(logger.Error).Infof("Failed to set `ret_error` to the occurred error: %v", err) - } - resVal, err := call.Otto.Run("ret_response = " + string(resObj)) - if err != nil { - glog.V(logger.Error).Infof("Failed to set `ret_response` to the JSON RPC response: %v", err) - } - return resVal -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/console/console.go b/vendor/github.com/ethereum/go-ethereum/console/console.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/console/console.go rename to vendor/github.com/ethereum/go-ethereum/console/console.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/console/prompter.go b/vendor/github.com/ethereum/go-ethereum/console/prompter.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/console/prompter.go rename to vendor/github.com/ethereum/go-ethereum/console/prompter.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/asm.go b/vendor/github.com/ethereum/go-ethereum/core/asm.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/asm.go rename to vendor/github.com/ethereum/go-ethereum/core/asm.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/block_validator.go b/vendor/github.com/ethereum/go-ethereum/core/block_validator.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/block_validator.go rename to vendor/github.com/ethereum/go-ethereum/core/block_validator.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/blockchain.go b/vendor/github.com/ethereum/go-ethereum/core/blockchain.go similarity index 99% rename from src/vendor/github.com/ethereum/go-ethereum/core/blockchain.go rename to vendor/github.com/ethereum/go-ethereum/core/blockchain.go index fb77106cd..edb12b1f4 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/core/blockchain.go +++ b/vendor/github.com/ethereum/go-ethereum/core/blockchain.go @@ -784,6 +784,14 @@ func (self *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err localTd := self.GetTd(self.currentBlock.Hash(), self.currentBlock.NumberU64()) externTd := new(big.Int).Add(block.Difficulty(), ptd) + // Irrelevant of the canonical status, write the block itself to the database + if err := self.hc.WriteTd(block.Hash(), block.NumberU64(), externTd); err != nil { + glog.Fatalf("failed to write block total difficulty: %v", err) + } + if err := WriteBlock(self.chainDb, block); err != nil { + glog.Fatalf("failed to write block contents: %v", err) + } + // If the total difficulty is higher than our known, add it to the canonical chain // Second clause in the if statement reduces the vulnerability to selfish mining. // Please refer to http://www.cs.cornell.edu/~ie53/publications/btcProcFC.pdf @@ -794,19 +802,11 @@ func (self *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err return NonStatTy, err } } - // Insert the block as the new head of the chain - self.insert(block) + self.insert(block) // Insert the block as the new head of the chain status = CanonStatTy } else { status = SideStatTy } - // Irrelevant of the canonical status, write the block itself to the database - if err := self.hc.WriteTd(block.Hash(), block.NumberU64(), externTd); err != nil { - glog.Fatalf("failed to write block total difficulty: %v", err) - } - if err := WriteBlock(self.chainDb, block); err != nil { - glog.Fatalf("failed to write block contents: %v", err) - } self.futureBlocks.Remove(block.Hash()) diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/blocks.go b/vendor/github.com/ethereum/go-ethereum/core/blocks.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/blocks.go rename to vendor/github.com/ethereum/go-ethereum/core/blocks.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/chain_makers.go b/vendor/github.com/ethereum/go-ethereum/core/chain_makers.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/chain_makers.go rename to vendor/github.com/ethereum/go-ethereum/core/chain_makers.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/chain_pow.go b/vendor/github.com/ethereum/go-ethereum/core/chain_pow.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/chain_pow.go rename to vendor/github.com/ethereum/go-ethereum/core/chain_pow.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/config.go b/vendor/github.com/ethereum/go-ethereum/core/config.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/config.go rename to vendor/github.com/ethereum/go-ethereum/core/config.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/dao.go b/vendor/github.com/ethereum/go-ethereum/core/dao.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/dao.go rename to vendor/github.com/ethereum/go-ethereum/core/dao.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/database_util.go b/vendor/github.com/ethereum/go-ethereum/core/database_util.go similarity index 98% rename from src/vendor/github.com/ethereum/go-ethereum/core/database_util.go rename to vendor/github.com/ethereum/go-ethereum/core/database_util.go index bbb99d10c..73fac20aa 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/core/database_util.go +++ b/vendor/github.com/ethereum/go-ethereum/core/database_util.go @@ -204,7 +204,11 @@ func GetTd(db ethdb.Database, hash common.Hash, number uint64) *big.Int { } // GetBlock retrieves an entire block corresponding to the hash, assembling it -// back from the stored header and body. +// back from the stored header and body. If either the header or body could not +// be retrieved nil is returned. +// +// Note, due to concurrent download of header and block body the header and thus +// canonical hash can be stored in the database but the body data not (yet). func GetBlock(db ethdb.Database, hash common.Hash, number uint64) *types.Block { // Retrieve the block header and body contents header := GetHeader(db, hash, number) diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/default_genesis.go b/vendor/github.com/ethereum/go-ethereum/core/default_genesis.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/default_genesis.go rename to vendor/github.com/ethereum/go-ethereum/core/default_genesis.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/error.go b/vendor/github.com/ethereum/go-ethereum/core/error.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/error.go rename to vendor/github.com/ethereum/go-ethereum/core/error.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/events.go b/vendor/github.com/ethereum/go-ethereum/core/events.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/events.go rename to vendor/github.com/ethereum/go-ethereum/core/events.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/execution.go b/vendor/github.com/ethereum/go-ethereum/core/execution.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/execution.go rename to vendor/github.com/ethereum/go-ethereum/core/execution.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/fees.go b/vendor/github.com/ethereum/go-ethereum/core/fees.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/fees.go rename to vendor/github.com/ethereum/go-ethereum/core/fees.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/gaspool.go b/vendor/github.com/ethereum/go-ethereum/core/gaspool.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/gaspool.go rename to vendor/github.com/ethereum/go-ethereum/core/gaspool.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/genesis.go b/vendor/github.com/ethereum/go-ethereum/core/genesis.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/genesis.go rename to vendor/github.com/ethereum/go-ethereum/core/genesis.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/headerchain.go b/vendor/github.com/ethereum/go-ethereum/core/headerchain.go similarity index 99% rename from src/vendor/github.com/ethereum/go-ethereum/core/headerchain.go rename to vendor/github.com/ethereum/go-ethereum/core/headerchain.go index f856333a0..0f9dd7208 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/core/headerchain.go +++ b/vendor/github.com/ethereum/go-ethereum/core/headerchain.go @@ -151,6 +151,14 @@ func (hc *HeaderChain) WriteHeader(header *types.Header) (status WriteStatus, er localTd := hc.GetTd(hc.currentHeaderHash, hc.currentHeader.Number.Uint64()) externTd := new(big.Int).Add(header.Difficulty, ptd) + // Irrelevant of the canonical status, write the td and header to the database + if err := hc.WriteTd(hash, number, externTd); err != nil { + glog.Fatalf("failed to write header total difficulty: %v", err) + } + if err := WriteHeader(hc.chainDb, header); err != nil { + glog.Fatalf("failed to write header contents: %v", err) + } + // If the total difficulty is higher than our known, add it to the canonical chain // Second clause in the if statement reduces the vulnerability to selfish mining. // Please refer to http://www.cs.cornell.edu/~ie53/publications/btcProcFC.pdf @@ -176,6 +184,7 @@ func (hc *HeaderChain) WriteHeader(header *types.Header) (status WriteStatus, er headNumber = headHeader.Number.Uint64() - 1 headHeader = hc.GetHeader(headHash, headNumber) } + // Extend the canonical chain with the new header if err := WriteCanonicalHash(hc.chainDb, hash, number); err != nil { glog.Fatalf("failed to insert header number: %v", err) @@ -183,19 +192,14 @@ func (hc *HeaderChain) WriteHeader(header *types.Header) (status WriteStatus, er if err := WriteHeadHeaderHash(hc.chainDb, hash); err != nil { glog.Fatalf("failed to insert head header hash: %v", err) } + hc.currentHeaderHash, hc.currentHeader = hash, types.CopyHeader(header) status = CanonStatTy } else { status = SideStatTy } - // Irrelevant of the canonical status, write the header itself to the database - if err := hc.WriteTd(hash, number, externTd); err != nil { - glog.Fatalf("failed to write header total difficulty: %v", err) - } - if err := WriteHeader(hc.chainDb, header); err != nil { - glog.Fatalf("failed to write header contents: %v", err) - } + hc.headerCache.Add(hash, header) hc.numberCache.Add(hash, number) diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/state/dump.go b/vendor/github.com/ethereum/go-ethereum/core/state/dump.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/state/dump.go rename to vendor/github.com/ethereum/go-ethereum/core/state/dump.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/state/iterator.go b/vendor/github.com/ethereum/go-ethereum/core/state/iterator.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/state/iterator.go rename to vendor/github.com/ethereum/go-ethereum/core/state/iterator.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/state/managed_state.go b/vendor/github.com/ethereum/go-ethereum/core/state/managed_state.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/state/managed_state.go rename to vendor/github.com/ethereum/go-ethereum/core/state/managed_state.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/state/state_object.go b/vendor/github.com/ethereum/go-ethereum/core/state/state_object.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/state/state_object.go rename to vendor/github.com/ethereum/go-ethereum/core/state/state_object.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/state/statedb.go b/vendor/github.com/ethereum/go-ethereum/core/state/statedb.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/state/statedb.go rename to vendor/github.com/ethereum/go-ethereum/core/state/statedb.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/state/sync.go b/vendor/github.com/ethereum/go-ethereum/core/state/sync.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/state/sync.go rename to vendor/github.com/ethereum/go-ethereum/core/state/sync.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/state_processor.go b/vendor/github.com/ethereum/go-ethereum/core/state_processor.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/state_processor.go rename to vendor/github.com/ethereum/go-ethereum/core/state_processor.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/state_transition.go b/vendor/github.com/ethereum/go-ethereum/core/state_transition.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/state_transition.go rename to vendor/github.com/ethereum/go-ethereum/core/state_transition.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/tx_pool.go b/vendor/github.com/ethereum/go-ethereum/core/tx_pool.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/tx_pool.go rename to vendor/github.com/ethereum/go-ethereum/core/tx_pool.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/types.go b/vendor/github.com/ethereum/go-ethereum/core/types.go similarity index 83% rename from src/vendor/github.com/ethereum/go-ethereum/core/types.go rename to vendor/github.com/ethereum/go-ethereum/core/types.go index 20f33a153..d84d0987f 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/core/types.go +++ b/vendor/github.com/ethereum/go-ethereum/core/types.go @@ -19,12 +19,9 @@ package core import ( "math/big" - "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/event" ) // Validator is an interface which defines the standard for block validation. @@ -63,16 +60,3 @@ type HeaderValidator interface { type Processor interface { Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, vm.Logs, *big.Int, error) } - -// Backend is an interface defining the basic functionality for an operable node -// with all the functionality to be a functional, valid Ethereum operator. -// -// TODO Remove this -type Backend interface { - AccountManager() *accounts.Manager - BlockChain() *BlockChain - TxPool() *TxPool - ChainDb() ethdb.Database - DappDb() ethdb.Database - EventMux() *event.TypeMux -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/types/block.go b/vendor/github.com/ethereum/go-ethereum/core/types/block.go similarity index 94% rename from src/vendor/github.com/ethereum/go-ethereum/core/types/block.go rename to vendor/github.com/ethereum/go-ethereum/core/types/block.go index 203f64c65..12fcb6cdc 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/core/types/block.go +++ b/vendor/github.com/ethereum/go-ethereum/core/types/block.go @@ -123,6 +123,28 @@ func (h *Header) UnmarshalJSON(data []byte) error { return nil } +func (h *Header) MarshalJSON() ([]byte, error) { + fields := map[string]interface{}{ + "hash": h.Hash(), + "parentHash": h.ParentHash, + "number": fmt.Sprintf("%#x", h.Number), + "nonce": h.Nonce, + "receiptRoot": h.ReceiptHash, + "logsBloom": h.Bloom, + "sha3Uncles": h.UncleHash, + "stateRoot": h.Root, + "miner": h.Coinbase, + "difficulty": fmt.Sprintf("%#x", h.Difficulty), + "extraData": fmt.Sprintf("0x%x", h.Extra), + "gasLimit": fmt.Sprintf("%#x", h.GasLimit), + "gasUsed": fmt.Sprintf("%#x", h.GasUsed), + "timestamp": fmt.Sprintf("%#x", h.Time), + "transactionsRoot": h.TxHash, + } + + return json.Marshal(fields) +} + func rlpHash(x interface{}) (h common.Hash) { hw := sha3.NewKeccak256() rlp.Encode(hw, x) diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/types/bloom9.go b/vendor/github.com/ethereum/go-ethereum/core/types/bloom9.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/types/bloom9.go rename to vendor/github.com/ethereum/go-ethereum/core/types/bloom9.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/types/derive_sha.go b/vendor/github.com/ethereum/go-ethereum/core/types/derive_sha.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/types/derive_sha.go rename to vendor/github.com/ethereum/go-ethereum/core/types/derive_sha.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/types/receipt.go b/vendor/github.com/ethereum/go-ethereum/core/types/receipt.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/types/receipt.go rename to vendor/github.com/ethereum/go-ethereum/core/types/receipt.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/types/transaction.go b/vendor/github.com/ethereum/go-ethereum/core/types/transaction.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/types/transaction.go rename to vendor/github.com/ethereum/go-ethereum/core/types/transaction.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/analysis.go b/vendor/github.com/ethereum/go-ethereum/core/vm/analysis.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/analysis.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/analysis.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/asm.go b/vendor/github.com/ethereum/go-ethereum/core/vm/asm.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/asm.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/asm.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/common.go b/vendor/github.com/ethereum/go-ethereum/core/vm/common.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/common.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/common.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/contract.go b/vendor/github.com/ethereum/go-ethereum/core/vm/contract.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/contract.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/contract.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/contracts.go b/vendor/github.com/ethereum/go-ethereum/core/vm/contracts.go similarity index 96% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/contracts.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/contracts.go index 5cc9f903b..b45f14724 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/core/vm/contracts.go +++ b/vendor/github.com/ethereum/go-ethereum/core/vm/contracts.go @@ -95,7 +95,7 @@ func ecrecoverFunc(in []byte) []byte { // tighter sig s values in homestead only apply to tx sigs if !crypto.ValidateSignatureValues(v, r, s, false) { - glog.V(logger.Debug).Infof("EC RECOVER FAIL: v, r or s value invalid") + glog.V(logger.Detail).Infof("ECRECOVER error: v, r or s value invalid") return nil } @@ -106,7 +106,7 @@ func ecrecoverFunc(in []byte) []byte { pubKey, err := crypto.Ecrecover(in[:32], rsv) // make sure the public key is a valid one if err != nil { - glog.V(logger.Error).Infof("EC RECOVER FAIL: ", err) + glog.V(logger.Detail).Infoln("ECRECOVER error: ", err) return nil } diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/disasm.go b/vendor/github.com/ethereum/go-ethereum/core/vm/disasm.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/disasm.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/disasm.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/doc.go b/vendor/github.com/ethereum/go-ethereum/core/vm/doc.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/doc.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/doc.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/environment.go b/vendor/github.com/ethereum/go-ethereum/core/vm/environment.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/environment.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/environment.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/errors.go b/vendor/github.com/ethereum/go-ethereum/core/vm/errors.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/errors.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/errors.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/gas.go b/vendor/github.com/ethereum/go-ethereum/core/vm/gas.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/gas.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/gas.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/instructions.go b/vendor/github.com/ethereum/go-ethereum/core/vm/instructions.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/instructions.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/instructions.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/jit.go b/vendor/github.com/ethereum/go-ethereum/core/vm/jit.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/jit.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/jit.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/jit_optimiser.go b/vendor/github.com/ethereum/go-ethereum/core/vm/jit_optimiser.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/jit_optimiser.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/jit_optimiser.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/jit_util.go b/vendor/github.com/ethereum/go-ethereum/core/vm/jit_util.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/jit_util.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/jit_util.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/jump_table.go b/vendor/github.com/ethereum/go-ethereum/core/vm/jump_table.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/jump_table.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/jump_table.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/log.go b/vendor/github.com/ethereum/go-ethereum/core/vm/log.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/log.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/log.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/logger.go b/vendor/github.com/ethereum/go-ethereum/core/vm/logger.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/logger.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/logger.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/memory.go b/vendor/github.com/ethereum/go-ethereum/core/vm/memory.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/memory.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/memory.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/opcodes.go b/vendor/github.com/ethereum/go-ethereum/core/vm/opcodes.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/opcodes.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/opcodes.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/runtime/doc.go b/vendor/github.com/ethereum/go-ethereum/core/vm/runtime/doc.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/runtime/doc.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/runtime/doc.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/runtime/env.go b/vendor/github.com/ethereum/go-ethereum/core/vm/runtime/env.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/runtime/env.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/runtime/env.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/runtime/runtime.go b/vendor/github.com/ethereum/go-ethereum/core/vm/runtime/runtime.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/runtime/runtime.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/runtime/runtime.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/segments.go b/vendor/github.com/ethereum/go-ethereum/core/vm/segments.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/segments.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/segments.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/stack.go b/vendor/github.com/ethereum/go-ethereum/core/vm/stack.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/stack.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/stack.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/virtual_machine.go b/vendor/github.com/ethereum/go-ethereum/core/vm/virtual_machine.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/virtual_machine.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/virtual_machine.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/vm.go b/vendor/github.com/ethereum/go-ethereum/core/vm/vm.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/vm.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/vm.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/vm_jit.go b/vendor/github.com/ethereum/go-ethereum/core/vm/vm_jit.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/vm_jit.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/vm_jit.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm/vm_jit_fake.go b/vendor/github.com/ethereum/go-ethereum/core/vm/vm_jit_fake.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm/vm_jit_fake.go rename to vendor/github.com/ethereum/go-ethereum/core/vm/vm_jit_fake.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/core/vm_env.go b/vendor/github.com/ethereum/go-ethereum/core/vm_env.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/core/vm_env.go rename to vendor/github.com/ethereum/go-ethereum/core/vm_env.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/crypto.go b/vendor/github.com/ethereum/go-ethereum/crypto/crypto.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/crypto.go rename to vendor/github.com/ethereum/go-ethereum/crypto/crypto.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/ecies/LICENSE b/vendor/github.com/ethereum/go-ethereum/crypto/ecies/LICENSE similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/ecies/LICENSE rename to vendor/github.com/ethereum/go-ethereum/crypto/ecies/LICENSE diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/ecies/README b/vendor/github.com/ethereum/go-ethereum/crypto/ecies/README similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/ecies/README rename to vendor/github.com/ethereum/go-ethereum/crypto/ecies/README diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/ecies/asn1.go b/vendor/github.com/ethereum/go-ethereum/crypto/ecies/asn1.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/ecies/asn1.go rename to vendor/github.com/ethereum/go-ethereum/crypto/ecies/asn1.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/ecies/ecies.go b/vendor/github.com/ethereum/go-ethereum/crypto/ecies/ecies.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/ecies/ecies.go rename to vendor/github.com/ethereum/go-ethereum/crypto/ecies/ecies.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/ecies/params.go b/vendor/github.com/ethereum/go-ethereum/crypto/ecies/params.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/ecies/params.go rename to vendor/github.com/ethereum/go-ethereum/crypto/ecies/params.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/randentropy/rand_entropy.go b/vendor/github.com/ethereum/go-ethereum/crypto/randentropy/rand_entropy.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/randentropy/rand_entropy.go rename to vendor/github.com/ethereum/go-ethereum/crypto/randentropy/rand_entropy.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/curve.go b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/curve.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/curve.go rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/curve.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/COPYING b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/COPYING similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/COPYING rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/COPYING diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/Makefile.am b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/Makefile.am similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/Makefile.am rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/Makefile.am diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/TODO b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/TODO similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/TODO rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/TODO diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/autogen.sh b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/autogen.sh similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/autogen.sh rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/autogen.sh diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/configure.ac b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/configure.ac similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/configure.ac rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/configure.ac diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_ecdh.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_ecdh.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_ecdh.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_ecdh.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_recovery.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_recovery.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_recovery.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_recovery.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_schnorr.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_schnorr.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_schnorr.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_schnorr.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/libsecp256k1.pc.in b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/libsecp256k1.pc.in similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/libsecp256k1.pc.in rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/libsecp256k1.pc.in diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/basic-config.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/basic-config.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/basic-config.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/basic-config.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_ecdh.c b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_ecdh.c similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_ecdh.c rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_ecdh.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_internal.c b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_internal.c similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_internal.c rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_internal.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_recover.c b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_recover.c similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_recover.c rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_recover.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_schnorr_verify.c b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_schnorr_verify.c similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_schnorr_verify.c rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_schnorr_verify.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_sign.c b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_sign.c similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_sign.c rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_sign.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_verify.c b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_verify.c similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_verify.c rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_verify.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecdsa.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecdsa.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecdsa.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecdsa.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecdsa_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecdsa_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecdsa_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecdsa_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/eckey.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/eckey.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/eckey.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/eckey.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/eckey_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/eckey_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/eckey_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/eckey_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_const.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_const.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_const.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_const.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_const_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_const_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_const_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_const_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_gen.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_gen.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_gen.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_gen.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_gen_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_gen_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_gen_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_gen_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_asm_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_asm_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_asm_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_asm_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_int128_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_int128_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_int128_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52_int128_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/gen_context.c b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/gen_context.c similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/gen_context.c rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/gen_context.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/group.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/group.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/group.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/group.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/group_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/group_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/group_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/group_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/hash.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/hash.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/hash.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/hash.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/hash_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/hash_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/hash_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/hash_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org/bitcoin/NativeSecp256k1.java b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org/bitcoin/NativeSecp256k1.java similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org/bitcoin/NativeSecp256k1.java rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org/bitcoin/NativeSecp256k1.java diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.c b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.c similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.c rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/Makefile.am.include b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/Makefile.am.include similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/Makefile.am.include rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/Makefile.am.include diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/main_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/main_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/main_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/main_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/tests_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/tests_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/tests_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/tests_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/Makefile.am.include b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/Makefile.am.include similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/Makefile.am.include rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/Makefile.am.include diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/tests_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/tests_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/tests_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/tests_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/Makefile.am.include b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/Makefile.am.include similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/Makefile.am.include rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/Makefile.am.include diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/main_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/main_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/main_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/main_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/schnorr.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/schnorr.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/schnorr.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/schnorr.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/schnorr_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/schnorr_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/schnorr_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/schnorr_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/tests_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/tests_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/tests_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/schnorr/tests_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_gmp.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_gmp.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_gmp.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_gmp.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_gmp_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_gmp_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_gmp_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_gmp_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_4x64.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_4x64.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_4x64.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_4x64.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_4x64_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_4x64_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_4x64_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_4x64_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_8x32.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_8x32.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_8x32.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_8x32.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_8x32_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_8x32_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_8x32_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_8x32_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/testrand.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/testrand.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/testrand.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/testrand.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/testrand_impl.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/testrand_impl.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/testrand_impl.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/testrand_impl.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/tests.c b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/tests.c similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/tests.c rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/tests.c diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/util.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/util.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/util.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/util.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/notes.go b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/notes.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/notes.go rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/notes.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/panic_cb.go b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/panic_cb.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/panic_cb.go rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/panic_cb.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/pubkey_scalar_mul.h b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/pubkey_scalar_mul.h similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/pubkey_scalar_mul.h rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/pubkey_scalar_mul.h diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/secp256.go b/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/secp256.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/secp256.go rename to vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/secp256.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/LICENSE b/vendor/github.com/ethereum/go-ethereum/crypto/sha3/LICENSE similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/LICENSE rename to vendor/github.com/ethereum/go-ethereum/crypto/sha3/LICENSE diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/PATENTS b/vendor/github.com/ethereum/go-ethereum/crypto/sha3/PATENTS similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/PATENTS rename to vendor/github.com/ethereum/go-ethereum/crypto/sha3/PATENTS diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/doc.go b/vendor/github.com/ethereum/go-ethereum/crypto/sha3/doc.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/doc.go rename to vendor/github.com/ethereum/go-ethereum/crypto/sha3/doc.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/hashes.go b/vendor/github.com/ethereum/go-ethereum/crypto/sha3/hashes.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/hashes.go rename to vendor/github.com/ethereum/go-ethereum/crypto/sha3/hashes.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/keccakf.go b/vendor/github.com/ethereum/go-ethereum/crypto/sha3/keccakf.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/keccakf.go rename to vendor/github.com/ethereum/go-ethereum/crypto/sha3/keccakf.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/register.go b/vendor/github.com/ethereum/go-ethereum/crypto/sha3/register.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/register.go rename to vendor/github.com/ethereum/go-ethereum/crypto/sha3/register.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/sha3.go b/vendor/github.com/ethereum/go-ethereum/crypto/sha3/sha3.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/sha3.go rename to vendor/github.com/ethereum/go-ethereum/crypto/sha3/sha3.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/shake.go b/vendor/github.com/ethereum/go-ethereum/crypto/sha3/shake.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/shake.go rename to vendor/github.com/ethereum/go-ethereum/crypto/sha3/shake.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor.go b/vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor.go rename to vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor_generic.go b/vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor_generic.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor_generic.go rename to vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor_generic.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor_unaligned.go b/vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor_unaligned.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor_unaligned.go rename to vendor/github.com/ethereum/go-ethereum/crypto/sha3/xor_unaligned.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/errs/errors.go b/vendor/github.com/ethereum/go-ethereum/errs/errors.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/errs/errors.go rename to vendor/github.com/ethereum/go-ethereum/errs/errors.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/api.go b/vendor/github.com/ethereum/go-ethereum/eth/api.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/eth/api.go rename to vendor/github.com/ethereum/go-ethereum/eth/api.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/api_backend.go b/vendor/github.com/ethereum/go-ethereum/eth/api_backend.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/eth/api_backend.go rename to vendor/github.com/ethereum/go-ethereum/eth/api_backend.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/backend.go b/vendor/github.com/ethereum/go-ethereum/eth/backend.go similarity index 93% rename from src/vendor/github.com/ethereum/go-ethereum/eth/backend.go rename to vendor/github.com/ethereum/go-ethereum/eth/backend.go index ea8cc4a0d..38b4eb60e 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/backend.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/backend.go @@ -31,7 +31,6 @@ import ( "github.com/ethereum/ethash" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/compiler" "github.com/ethereum/go-ethereum/common/httpclient" "github.com/ethereum/go-ethereum/common/registrar/ethreg" "github.com/ethereum/go-ethereum/core" @@ -87,11 +86,10 @@ type Config struct { PowShared bool ExtraData []byte - AccountManager *accounts.Manager - Etherbase common.Address - GasPrice *big.Int - MinerThreads int - SolcPath string + Etherbase common.Address + GasPrice *big.Int + MinerThreads int + SolcPath string GpoMinGasPrice *big.Int GpoMaxGasPrice *big.Int @@ -127,7 +125,6 @@ type Ethereum struct { ls LesServer // DB interfaces chainDb ethdb.Database // Block chain database - dappDb ethdb.Database // Dapp database eventMux *event.TypeMux pow *ethash.Ethash @@ -143,7 +140,6 @@ type Ethereum struct { autodagquit chan bool etherbase common.Address solcPath string - solc *compiler.Solidity NatSpec bool PowTest bool @@ -158,7 +154,7 @@ func (s *Ethereum) AddLesServer(ls LesServer) { // New creates a new Ethereum object (including the // initialisation of the common Ethereum object) func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { - chainDb, dappDb, err := CreateDBs(ctx, config, "chaindata") + chainDb, err := CreateDB(ctx, config, "chaindata") if err != nil { return nil, err } @@ -173,9 +169,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { eth := &Ethereum{ chainDb: chainDb, - dappDb: dappDb, eventMux: ctx.EventMux, - accountManager: config.AccountManager, + accountManager: ctx.AccountManager, pow: pow, shutdownChan: make(chan bool), stopDbUpgrade: stopDbUpgrade, @@ -259,25 +254,13 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { return eth, nil } -// CreateDBs creates the chain and dapp databases for an Ethereum service -func CreateDBs(ctx *node.ServiceContext, config *Config, name string) (chainDb, dappDb ethdb.Database, err error) { - // Open the chain database and perform any upgrades needed - chainDb, err = ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles) - if err != nil { - return nil, nil, err - } - if db, ok := chainDb.(*ethdb.LDBDatabase); ok { +// CreateDB creates the chain database. +func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Database, error) { + db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles) + if db, ok := db.(*ethdb.LDBDatabase); ok { db.Meter("eth/db/chaindata/") } - - dappDb, err = ctx.OpenDatabase("dapp", config.DatabaseCache, config.DatabaseHandles) - if err != nil { - return nil, nil, err - } - if db, ok := dappDb.(*ethdb.LDBDatabase); ok { - db.Meter("eth/db/dapp/") - } - return + return db, err } // SetupGenesisBlock initializes the genesis block for an Ethereum service @@ -321,7 +304,7 @@ func CreatePoW(config *Config) (*ethash.Ethash, error) { // APIs returns the collection of RPC services the ethereum package offers. // NOTE, some of these services probably need to be moved to somewhere else. func (s *Ethereum) APIs() []rpc.API { - return append(ethapi.GetAPIs(s.ApiBackend, &s.solcPath, &s.solc), []rpc.API{ + return append(ethapi.GetAPIs(s.ApiBackend, s.solcPath), []rpc.API{ { Namespace: "eth", Version: "1.0", @@ -405,7 +388,6 @@ func (s *Ethereum) TxPool() *core.TxPool { return s.txPool } func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux } func (s *Ethereum) Pow() *ethash.Ethash { return s.pow } func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb } -func (s *Ethereum) DappDb() ethdb.Database { return s.dappDb } func (s *Ethereum) IsListening() bool { return true } // Always listening func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) } func (s *Ethereum) NetVersion() int { return s.netVersionId } @@ -453,7 +435,6 @@ func (s *Ethereum) Stop() error { s.StopAutoDAG() s.chainDb.Close() - s.dappDb.Close() close(s.shutdownChan) return nil diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/bad_block.go b/vendor/github.com/ethereum/go-ethereum/eth/bad_block.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/eth/bad_block.go rename to vendor/github.com/ethereum/go-ethereum/eth/bad_block.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/bind.go b/vendor/github.com/ethereum/go-ethereum/eth/bind.go similarity index 98% rename from src/vendor/github.com/ethereum/go-ethereum/eth/bind.go rename to vendor/github.com/ethereum/go-ethereum/eth/bind.go index 040797190..26fc02860 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/bind.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/bind.go @@ -44,7 +44,7 @@ type ContractBackend struct { // Etheruem object. func NewContractBackend(apiBackend ethapi.Backend) *ContractBackend { return &ContractBackend{ - eapi: ethapi.NewPublicEthereumAPI(apiBackend, nil, nil), + eapi: ethapi.NewPublicEthereumAPI(apiBackend), bcapi: ethapi.NewPublicBlockChainAPI(apiBackend), txapi: ethapi.NewPublicTransactionPoolAPI(apiBackend), } diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/cpu_mining.go b/vendor/github.com/ethereum/go-ethereum/eth/cpu_mining.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/eth/cpu_mining.go rename to vendor/github.com/ethereum/go-ethereum/eth/cpu_mining.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/db_upgrade.go b/vendor/github.com/ethereum/go-ethereum/eth/db_upgrade.go similarity index 97% rename from src/vendor/github.com/ethereum/go-ethereum/eth/db_upgrade.go rename to vendor/github.com/ethereum/go-ethereum/eth/db_upgrade.go index 7b7b08a74..a0bce7f92 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/db_upgrade.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/db_upgrade.go @@ -91,6 +91,9 @@ func upgradeSequentialKeys(db ethdb.Database) (stopFn func()) { func upgradeSequentialCanonicalNumbers(db ethdb.Database, stopFn func() bool) (error, bool) { prefix := []byte("block-num-") it := db.(*ethdb.LDBDatabase).NewIterator() + defer func() { + it.Release() + }() it.Seek(prefix) cnt := 0 for bytes.HasPrefix(it.Key(), prefix) { @@ -98,6 +101,9 @@ func upgradeSequentialCanonicalNumbers(db ethdb.Database, stopFn func() bool) (e if len(keyPtr) < 20 { cnt++ if cnt%100000 == 0 { + it.Release() + it = db.(*ethdb.LDBDatabase).NewIterator() + it.Seek(keyPtr) glog.V(logger.Info).Infof("converting %d canonical numbers...", cnt) } number := big.NewInt(0).SetBytes(keyPtr[10:]).Uint64() @@ -128,6 +134,9 @@ func upgradeSequentialCanonicalNumbers(db ethdb.Database, stopFn func() bool) (e func upgradeSequentialBlocks(db ethdb.Database, stopFn func() bool) (error, bool) { prefix := []byte("block-") it := db.(*ethdb.LDBDatabase).NewIterator() + defer func() { + it.Release() + }() it.Seek(prefix) cnt := 0 for bytes.HasPrefix(it.Key(), prefix) { @@ -135,6 +144,9 @@ func upgradeSequentialBlocks(db ethdb.Database, stopFn func() bool) (error, bool if len(keyPtr) >= 38 { cnt++ if cnt%10000 == 0 { + it.Release() + it = db.(*ethdb.LDBDatabase).NewIterator() + it.Seek(keyPtr) glog.V(logger.Info).Infof("converting %d blocks...", cnt) } // convert header, body, td and block receipts @@ -173,6 +185,7 @@ func upgradeSequentialBlocks(db ethdb.Database, stopFn func() bool) (error, bool func upgradeSequentialOrphanedReceipts(db ethdb.Database, stopFn func() bool) (error, bool) { prefix := []byte("receipts-block-") it := db.(*ethdb.LDBDatabase).NewIterator() + defer it.Release() it.Seek(prefix) cnt := 0 for bytes.HasPrefix(it.Key(), prefix) { diff --git a/vendor/github.com/ethereum/go-ethereum/eth/downloader/api.go b/vendor/github.com/ethereum/go-ethereum/eth/downloader/api.go new file mode 100644 index 000000000..c36dfb7e0 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/eth/downloader/api.go @@ -0,0 +1,173 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package downloader + +import ( + "sync" + + "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/rpc" + "golang.org/x/net/context" +) + +// PublicDownloaderAPI provides an API which gives information about the current synchronisation status. +// It offers only methods that operates on data that can be available to anyone without security risks. +type PublicDownloaderAPI struct { + d *Downloader + mux *event.TypeMux + installSyncSubscription chan chan interface{} + uninstallSyncSubscription chan *uninstallSyncSubscriptionRequest +} + +// NewPublicDownloaderAPI create a new PublicDownloaderAPI. The API has an internal event loop that +// listens for events from the downloader through the global event mux. In case it receives one of +// these events it broadcasts it to all syncing subscriptions that are installed through the +// installSyncSubscription channel. +func NewPublicDownloaderAPI(d *Downloader, m *event.TypeMux) *PublicDownloaderAPI { + api := &PublicDownloaderAPI{ + d: d, + mux: m, + installSyncSubscription: make(chan chan interface{}), + uninstallSyncSubscription: make(chan *uninstallSyncSubscriptionRequest), + } + + go api.eventLoop() + + return api +} + +// eventLoop runs an loop until the event mux closes. It will install and uninstall new +// sync subscriptions and broadcasts sync status updates to the installed sync subscriptions. +func (api *PublicDownloaderAPI) eventLoop() { + var ( + sub = api.mux.Subscribe(StartEvent{}, DoneEvent{}, FailedEvent{}) + syncSubscriptions = make(map[chan interface{}]struct{}) + ) + + for { + select { + case i := <-api.installSyncSubscription: + syncSubscriptions[i] = struct{}{} + case u := <-api.uninstallSyncSubscription: + delete(syncSubscriptions, u.c) + close(u.uninstalled) + case event := <-sub.Chan(): + if event == nil { + return + } + + var notification interface{} + switch event.Data.(type) { + case StartEvent: + result := &SyncingResult{Syncing: true} + result.Status.Origin, result.Status.Current, result.Status.Height, result.Status.Pulled, result.Status.Known = api.d.Progress() + notification = result + case DoneEvent, FailedEvent: + notification = false + } + // broadcast + for c := range syncSubscriptions { + c <- notification + } + } + } +} + +// Syncing provides information when this nodes starts synchronising with the Ethereum network and when it's finished. +func (api *PublicDownloaderAPI) Syncing(ctx context.Context) (*rpc.Subscription, error) { + notifier, supported := rpc.NotifierFromContext(ctx) + if !supported { + return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported + } + + rpcSub := notifier.CreateSubscription() + + go func() { + statuses := make(chan interface{}) + sub := api.SubscribeSyncStatus(statuses) + + for { + select { + case status := <-statuses: + notifier.Notify(rpcSub.ID, status) + case <-rpcSub.Err(): + sub.Unsubscribe() + return + case <-notifier.Closed(): + sub.Unsubscribe() + return + } + } + }() + + return rpcSub, nil +} + +// Progress gives progress indications when the node is synchronising with the Ethereum network. +type Progress struct { + Origin uint64 `json:"startingBlock"` + Current uint64 `json:"currentBlock"` + Height uint64 `json:"highestBlock"` + Pulled uint64 `json:"pulledStates"` + Known uint64 `json:"knownStates"` +} + +// SyncingResult provides information about the current synchronisation status for this node. +type SyncingResult struct { + Syncing bool `json:"syncing"` + Status Progress `json:"status"` +} + +// uninstallSyncSubscriptionRequest uninstalles a syncing subscription in the API event loop. +type uninstallSyncSubscriptionRequest struct { + c chan interface{} + uninstalled chan interface{} +} + +// SyncStatusSubscription represents a syncing subscription. +type SyncStatusSubscription struct { + api *PublicDownloaderAPI // register subscription in event loop of this api instance + c chan interface{} // channel where events are broadcasted to + unsubOnce sync.Once // make sure unsubscribe logic is executed once +} + +// Unsubscribe uninstalls the subscription from the DownloadAPI event loop. +// The status channel that was passed to subscribeSyncStatus isn't used anymore +// after this method returns. +func (s *SyncStatusSubscription) Unsubscribe() { + s.unsubOnce.Do(func() { + req := uninstallSyncSubscriptionRequest{s.c, make(chan interface{})} + s.api.uninstallSyncSubscription <- &req + + for { + select { + case <-s.c: + // drop new status events until uninstall confirmation + continue + case <-req.uninstalled: + return + } + } + }) +} + +// SubscribeSyncStatus creates a subscription that will broadcast new synchronisation updates. +// The given channel must receive interface values, the result can either +func (api *PublicDownloaderAPI) SubscribeSyncStatus(status chan interface{}) *SyncStatusSubscription { + api.installSyncSubscription <- status + return &SyncStatusSubscription{api: api, c: status} +} diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/downloader.go b/vendor/github.com/ethereum/go-ethereum/eth/downloader/downloader.go similarity index 71% rename from src/vendor/github.com/ethereum/go-ethereum/eth/downloader/downloader.go rename to vendor/github.com/ethereum/go-ethereum/eth/downloader/downloader.go index baf6688a6..d9a344da7 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/downloader.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/downloader/downloader.go @@ -48,23 +48,17 @@ var ( MaxReceiptFetch = 256 // Amount of transaction receipts to allow fetching per request MaxStateFetch = 384 // Amount of node state values to allow fetching per request - MaxForkAncestry = 3 * params.EpochDuration.Uint64() // Maximum chain reorganisation - - hashTTL = 3 * time.Second // [eth/61] Time it takes for a hash request to time out - blockTargetRTT = 3 * time.Second / 2 // [eth/61] Target time for completing a block retrieval request - blockTTL = 3 * blockTargetRTT // [eth/61] Maximum time allowance before a block request is considered expired - - rttMinEstimate = 2 * time.Second // Minimum round-trip time to target for download requests - rttMaxEstimate = 20 * time.Second // Maximum rount-trip time to target for download requests - rttMinConfidence = 0.1 // Worse confidence factor in our estimated RTT value - ttlScaling = 3 // Constant scaling factor for RTT -> TTL conversion - ttlLimit = time.Minute // Maximum TTL allowance to prevent reaching crazy timeouts + MaxForkAncestry = 3 * params.EpochDuration.Uint64() // Maximum chain reorganisation + rttMinEstimate = 2 * time.Second // Minimum round-trip time to target for download requests + rttMaxEstimate = 20 * time.Second // Maximum rount-trip time to target for download requests + rttMinConfidence = 0.1 // Worse confidence factor in our estimated RTT value + ttlScaling = 3 // Constant scaling factor for RTT -> TTL conversion + ttlLimit = time.Minute // Maximum TTL allowance to prevent reaching crazy timeouts qosTuningPeers = 5 // Number of peers to tune based on (best peers) qosConfidenceCap = 10 // Number of peers above which not to modify RTT confidence qosTuningImpact = 0.25 // Impact that a new tuning target has on the previous value - maxQueuedHashes = 32 * 1024 // [eth/61] Maximum number of hashes to queue for import (DOS protection) maxQueuedHeaders = 32 * 1024 // [eth/62] Maximum number of headers to queue for import (DOS protection) maxHeadersProcess = 2048 // Number of header download results to import at once into the chain maxResultsProcess = 2048 // Number of content download results to import at once into the chain @@ -84,16 +78,13 @@ var ( errStallingPeer = errors.New("peer is stalling") errNoPeers = errors.New("no peers to keep download active") errTimeout = errors.New("timeout") - errEmptyHashSet = errors.New("empty hash set by peer") errEmptyHeaderSet = errors.New("empty header set by peer") errPeersUnavailable = errors.New("no peers available or all tried for download") - errAlreadyInPool = errors.New("hash already in pool") errInvalidAncestor = errors.New("retrieved ancestor is invalid") errInvalidChain = errors.New("retrieved hash chain is invalid") errInvalidBlock = errors.New("retrieved block is invalid") errInvalidBody = errors.New("retrieved block body is invalid") errInvalidReceipt = errors.New("retrieved receipt is invalid") - errCancelHashFetch = errors.New("hash download canceled (requested)") errCancelBlockFetch = errors.New("block download canceled (requested)") errCancelHeaderFetch = errors.New("block header download canceled (requested)") errCancelBodyFetch = errors.New("block body download canceled (requested)") @@ -102,6 +93,7 @@ var ( errCancelHeaderProcessing = errors.New("header processing canceled (requested)") errCancelContentProcessing = errors.New("content processing canceled (requested)") errNoSyncActive = errors.New("no sync active") + errTooOld = errors.New("peer doesn't speak recent enough protocol version (need version >= 62)") ) type Downloader struct { @@ -146,20 +138,19 @@ type Downloader struct { // Channels newPeerCh chan *peer - hashCh chan dataPack // [eth/61] Channel receiving inbound hashes - blockCh chan dataPack // [eth/61] Channel receiving inbound blocks headerCh chan dataPack // [eth/62] Channel receiving inbound block headers bodyCh chan dataPack // [eth/62] Channel receiving inbound block bodies receiptCh chan dataPack // [eth/63] Channel receiving inbound receipts stateCh chan dataPack // [eth/63] Channel receiving inbound node state data - blockWakeCh chan bool // [eth/61] Channel to signal the block fetcher of new tasks bodyWakeCh chan bool // [eth/62] Channel to signal the block body fetcher of new tasks receiptWakeCh chan bool // [eth/63] Channel to signal the receipt fetcher of new tasks stateWakeCh chan bool // [eth/63] Channel to signal the state fetcher of new tasks headerProcCh chan []*types.Header // [eth/62] Channel to feed the header processor new tasks + // Cancellation and termination + cancelPeer string // Identifier of the peer currently being used as the master (cancel on drop) cancelCh chan struct{} // Channel to cancel mid-flight syncs - cancelLock sync.RWMutex // Lock to protect the cancel channel in delivers + cancelLock sync.RWMutex // Lock to protect the cancel channel and peer in delivers quitCh chan struct{} // Quit channel to signal termination quitLock sync.RWMutex // Lock to prevent double closes @@ -199,13 +190,10 @@ func New(mode SyncMode, stateDb ethdb.Database, mux *event.TypeMux, hasHeader he rollback: rollback, dropPeer: dropPeer, newPeerCh: make(chan *peer, 1), - hashCh: make(chan dataPack, 1), - blockCh: make(chan dataPack, 1), headerCh: make(chan dataPack, 1), bodyCh: make(chan dataPack, 1), receiptCh: make(chan dataPack, 1), stateCh: make(chan dataPack, 1), - blockWakeCh: make(chan bool, 1), bodyWakeCh: make(chan bool, 1), receiptWakeCh: make(chan bool, 1), stateWakeCh: make(chan bool, 1), @@ -250,13 +238,12 @@ func (d *Downloader) Synchronising() bool { // RegisterPeer injects a new download peer into the set of block source to be // used for fetching hashes and blocks from. -func (d *Downloader) RegisterPeer(id string, version int, head common.Hash, - getRelHashes relativeHashFetcherFn, getAbsHashes absoluteHashFetcherFn, getBlocks blockFetcherFn, // eth/61 callbacks, remove when upgrading +func (d *Downloader) RegisterPeer(id string, version int, currentHead currentHeadRetrievalFn, getRelHeaders relativeHeaderFetcherFn, getAbsHeaders absoluteHeaderFetcherFn, getBlockBodies blockBodyFetcherFn, getReceipts receiptFetcherFn, getNodeData stateFetcherFn) error { glog.V(logger.Detail).Infoln("Registering peer", id) - if err := d.peers.Register(newPeer(id, version, head, getRelHashes, getAbsHashes, getBlocks, getRelHeaders, getAbsHeaders, getBlockBodies, getReceipts, getNodeData)); err != nil { + if err := d.peers.Register(newPeer(id, version, currentHead, getRelHeaders, getAbsHeaders, getBlockBodies, getReceipts, getNodeData)); err != nil { glog.V(logger.Error).Infoln("Register failed:", err) return err } @@ -269,12 +256,22 @@ func (d *Downloader) RegisterPeer(id string, version int, head common.Hash, // the specified peer. An effort is also made to return any pending fetches into // the queue. func (d *Downloader) UnregisterPeer(id string) error { + // Unregister the peer from the active peer set and revoke any fetch tasks glog.V(logger.Detail).Infoln("Unregistering peer", id) if err := d.peers.Unregister(id); err != nil { glog.V(logger.Error).Infoln("Unregister failed:", err) return err } d.queue.Revoke(id) + + // If this peer was the master peer, abort sync immediately + d.cancelLock.RLock() + master := id == d.cancelPeer + d.cancelLock.RUnlock() + + if master { + d.cancel() + } return nil } @@ -291,7 +288,9 @@ func (d *Downloader) Synchronise(id string, head common.Hash, td *big.Int, mode case errBusy: glog.V(logger.Detail).Infof("Synchronisation already in progress") - case errTimeout, errBadPeer, errStallingPeer, errEmptyHashSet, errEmptyHeaderSet, errPeersUnavailable, errInvalidAncestor, errInvalidChain: + case errTimeout, errBadPeer, errStallingPeer, + errEmptyHeaderSet, errPeersUnavailable, errTooOld, + errInvalidAncestor, errInvalidChain: glog.V(logger.Debug).Infof("Removing peer %v: %v", id, err) d.dropPeer(id) @@ -323,13 +322,13 @@ func (d *Downloader) synchronise(id string, hash common.Hash, td *big.Int, mode d.queue.Reset() d.peers.Reset() - for _, ch := range []chan bool{d.blockWakeCh, d.bodyWakeCh, d.receiptWakeCh, d.stateWakeCh} { + for _, ch := range []chan bool{d.bodyWakeCh, d.receiptWakeCh, d.stateWakeCh} { select { case <-ch: default: } } - for _, ch := range []chan dataPack{d.hashCh, d.blockCh, d.headerCh, d.bodyCh, d.receiptCh, d.stateCh} { + for _, ch := range []chan dataPack{d.headerCh, d.bodyCh, d.receiptCh, d.stateCh} { for empty := false; !empty; { select { case <-ch: @@ -345,9 +344,10 @@ func (d *Downloader) synchronise(id string, hash common.Hash, td *big.Int, mode empty = true } } - // Create cancel channel for aborting mid-flight + // Create cancel channel for aborting mid-flight and mark the master peer d.cancelLock.Lock() d.cancelCh = make(chan struct{}) + d.cancelPeer = id d.cancelLock.Unlock() defer d.cancel() // No matter what, we can't leave the cancel channel open @@ -377,105 +377,73 @@ func (d *Downloader) syncWithPeer(p *peer, hash common.Hash, td *big.Int) (err e d.mux.Post(DoneEvent{}) } }() + if p.version < 62 { + return errTooOld + } glog.V(logger.Debug).Infof("Synchronising with the network using: %s [eth/%d]", p.id, p.version) defer func(start time.Time) { glog.V(logger.Debug).Infof("Synchronisation terminated after %v", time.Since(start)) }(time.Now()) - switch { - case p.version == 61: - // Look up the sync boundaries: the common ancestor and the target block - latest, err := d.fetchHeight61(p) - if err != nil { - return err - } - origin, err := d.findAncestor61(p, latest) - if err != nil { - return err - } - d.syncStatsLock.Lock() - if d.syncStatsChainHeight <= origin || d.syncStatsChainOrigin > origin { - d.syncStatsChainOrigin = origin - } - d.syncStatsChainHeight = latest - d.syncStatsLock.Unlock() - - // Initiate the sync using a concurrent hash and block retrieval algorithm - d.queue.Prepare(origin+1, d.mode, 0, nil) - if d.syncInitHook != nil { - d.syncInitHook(origin, latest) - } - return d.spawnSync(origin+1, - func() error { return d.fetchHashes61(p, td, origin+1) }, - func() error { return d.fetchBlocks61(origin + 1) }, - ) - - case p.version >= 62: - // Look up the sync boundaries: the common ancestor and the target block - latest, err := d.fetchHeight(p) - if err != nil { - return err - } - height := latest.Number.Uint64() - - origin, err := d.findAncestor(p, height) - if err != nil { - return err - } - d.syncStatsLock.Lock() - if d.syncStatsChainHeight <= origin || d.syncStatsChainOrigin > origin { - d.syncStatsChainOrigin = origin - } - d.syncStatsChainHeight = height - d.syncStatsLock.Unlock() - - // Initiate the sync using a concurrent header and content retrieval algorithm - pivot := uint64(0) - switch d.mode { - case LightSync: - pivot = height - case FastSync: - // Calculate the new fast/slow sync pivot point - if d.fsPivotLock == nil { - pivotOffset, err := rand.Int(rand.Reader, big.NewInt(int64(fsPivotInterval))) - if err != nil { - panic(fmt.Sprintf("Failed to access crypto random source: %v", err)) - } - if height > uint64(fsMinFullBlocks)+pivotOffset.Uint64() { - pivot = height - uint64(fsMinFullBlocks) - pivotOffset.Uint64() - } - } else { - // Pivot point locked in, use this and do not pick a new one! - pivot = d.fsPivotLock.Number.Uint64() - } - // If the point is below the origin, move origin back to ensure state download - if pivot < origin { - if pivot > 0 { - origin = pivot - 1 - } else { - origin = 0 - } - } - glog.V(logger.Debug).Infof("Fast syncing until pivot block #%d", pivot) - } - d.queue.Prepare(origin+1, d.mode, pivot, latest) - if d.syncInitHook != nil { - d.syncInitHook(origin, height) - } - return d.spawnSync(origin+1, - func() error { return d.fetchHeaders(p, origin+1) }, // Headers are always retrieved - func() error { return d.processHeaders(origin+1, td) }, // Headers are always retrieved - func() error { return d.fetchBodies(origin + 1) }, // Bodies are retrieved during normal and fast sync - func() error { return d.fetchReceipts(origin + 1) }, // Receipts are retrieved during fast sync - func() error { return d.fetchNodeData() }, // Node state data is retrieved during fast sync - ) - - default: - // Something very wrong, stop right here - glog.V(logger.Error).Infof("Unsupported eth protocol: %d", p.version) - return errBadPeer + // Look up the sync boundaries: the common ancestor and the target block + latest, err := d.fetchHeight(p) + if err != nil { + return err } + height := latest.Number.Uint64() + + origin, err := d.findAncestor(p, height) + if err != nil { + return err + } + d.syncStatsLock.Lock() + if d.syncStatsChainHeight <= origin || d.syncStatsChainOrigin > origin { + d.syncStatsChainOrigin = origin + } + d.syncStatsChainHeight = height + d.syncStatsLock.Unlock() + + // Initiate the sync using a concurrent header and content retrieval algorithm + pivot := uint64(0) + switch d.mode { + case LightSync: + pivot = height + case FastSync: + // Calculate the new fast/slow sync pivot point + if d.fsPivotLock == nil { + pivotOffset, err := rand.Int(rand.Reader, big.NewInt(int64(fsPivotInterval))) + if err != nil { + panic(fmt.Sprintf("Failed to access crypto random source: %v", err)) + } + if height > uint64(fsMinFullBlocks)+pivotOffset.Uint64() { + pivot = height - uint64(fsMinFullBlocks) - pivotOffset.Uint64() + } + } else { + // Pivot point locked in, use this and do not pick a new one! + pivot = d.fsPivotLock.Number.Uint64() + } + // If the point is below the origin, move origin back to ensure state download + if pivot < origin { + if pivot > 0 { + origin = pivot - 1 + } else { + origin = 0 + } + } + glog.V(logger.Debug).Infof("Fast syncing until pivot block #%d", pivot) + } + d.queue.Prepare(origin+1, d.mode, pivot, latest) + if d.syncInitHook != nil { + d.syncInitHook(origin, height) + } + return d.spawnSync(origin+1, + func() error { return d.fetchHeaders(p, origin+1) }, // Headers are always retrieved + func() error { return d.processHeaders(origin+1, td) }, // Headers are always retrieved + func() error { return d.fetchBodies(origin + 1) }, // Bodies are retrieved during normal and fast sync + func() error { return d.fetchReceipts(origin + 1) }, // Receipts are retrieved during fast sync + func() error { return d.fetchNodeData() }, // Node state data is retrieved during fast sync + ) } // spawnSync runs d.process and all given fetcher functions to completion in @@ -540,459 +508,14 @@ func (d *Downloader) Terminate() { d.cancel() } -// fetchHeight61 retrieves the head block of the remote peer to aid in estimating -// the total time a pending synchronisation would take. -func (d *Downloader) fetchHeight61(p *peer) (uint64, error) { - glog.V(logger.Debug).Infof("%v: retrieving remote chain height", p) - - // Request the advertised remote head block and wait for the response - go p.getBlocks([]common.Hash{p.head}) - - timeout := time.After(hashTTL) - for { - select { - case <-d.cancelCh: - return 0, errCancelBlockFetch - - case packet := <-d.blockCh: - // Discard anything not from the origin peer - if packet.PeerId() != p.id { - glog.V(logger.Debug).Infof("Received blocks from incorrect peer(%s)", packet.PeerId()) - break - } - // Make sure the peer actually gave something valid - blocks := packet.(*blockPack).blocks - if len(blocks) != 1 { - glog.V(logger.Debug).Infof("%v: invalid number of head blocks: %d != 1", p, len(blocks)) - return 0, errBadPeer - } - return blocks[0].NumberU64(), nil - - case <-timeout: - glog.V(logger.Debug).Infof("%v: head block timeout", p) - return 0, errTimeout - - case <-d.hashCh: - // Out of bounds hashes received, ignore them - - case <-d.headerCh: - case <-d.bodyCh: - case <-d.stateCh: - case <-d.receiptCh: - // Ignore eth/{62,63} packets because this is eth/61. - // These can arrive as a late delivery from a previous sync. - } - } -} - -// findAncestor61 tries to locate the common ancestor block of the local chain and -// a remote peers blockchain. In the general case when our node was in sync and -// on the correct chain, checking the top N blocks should already get us a match. -// In the rare scenario when we ended up on a long reorganisation (i.e. none of -// the head blocks match), we do a binary search to find the common ancestor. -func (d *Downloader) findAncestor61(p *peer, height uint64) (uint64, error) { - glog.V(logger.Debug).Infof("%v: looking for common ancestor", p) - - // Figure out the valid ancestor range to prevent rewrite attacks - floor, ceil := int64(-1), d.headBlock().NumberU64() - if ceil >= MaxForkAncestry { - floor = int64(ceil - MaxForkAncestry) - } - // Request the topmost blocks to short circuit binary ancestor lookup - head := ceil - if head > height { - head = height - } - from := int64(head) - int64(MaxHashFetch) + 1 - if from < 0 { - from = 0 - } - go p.getAbsHashes(uint64(from), MaxHashFetch) - - // Wait for the remote response to the head fetch - number, hash := uint64(0), common.Hash{} - timeout := time.After(hashTTL) - - for finished := false; !finished; { - select { - case <-d.cancelCh: - return 0, errCancelHashFetch - - case packet := <-d.hashCh: - // Discard anything not from the origin peer - if packet.PeerId() != p.id { - glog.V(logger.Debug).Infof("Received hashes from incorrect peer(%s)", packet.PeerId()) - break - } - // Make sure the peer actually gave something valid - hashes := packet.(*hashPack).hashes - if len(hashes) == 0 { - glog.V(logger.Debug).Infof("%v: empty head hash set", p) - return 0, errEmptyHashSet - } - // Check if a common ancestor was found - finished = true - for i := len(hashes) - 1; i >= 0; i-- { - // Skip any headers that underflow/overflow our requested set - header := d.getHeader(hashes[i]) - if header == nil || header.Number.Int64() < from || header.Number.Uint64() > head { - continue - } - // Otherwise check if we already know the header or not - if d.hasBlockAndState(hashes[i]) { - number, hash = header.Number.Uint64(), header.Hash() - break - } - } - - case <-timeout: - glog.V(logger.Debug).Infof("%v: head hash timeout", p) - return 0, errTimeout - - case <-d.blockCh: - // Out of bounds blocks received, ignore them - - case <-d.headerCh: - case <-d.bodyCh: - case <-d.stateCh: - case <-d.receiptCh: - // Ignore eth/{62,63} packets because this is eth/61. - // These can arrive as a late delivery from a previous sync. - } - } - // If the head fetch already found an ancestor, return - if !common.EmptyHash(hash) { - if int64(number) <= floor { - glog.V(logger.Warn).Infof("%v: potential rewrite attack: #%d [%x…] <= #%d limit", p, number, hash[:4], floor) - return 0, errInvalidAncestor - } - glog.V(logger.Debug).Infof("%v: common ancestor: #%d [%x…]", p, number, hash[:4]) - return number, nil - } - // Ancestor not found, we need to binary search over our chain - start, end := uint64(0), head - if floor > 0 { - start = uint64(floor) - } - for start+1 < end { - // Split our chain interval in two, and request the hash to cross check - check := (start + end) / 2 - - timeout := time.After(hashTTL) - go p.getAbsHashes(uint64(check), 1) - - // Wait until a reply arrives to this request - for arrived := false; !arrived; { - select { - case <-d.cancelCh: - return 0, errCancelHashFetch - - case packet := <-d.hashCh: - // Discard anything not from the origin peer - if packet.PeerId() != p.id { - glog.V(logger.Debug).Infof("Received hashes from incorrect peer(%s)", packet.PeerId()) - break - } - // Make sure the peer actually gave something valid - hashes := packet.(*hashPack).hashes - if len(hashes) != 1 { - glog.V(logger.Debug).Infof("%v: invalid search hash set (%d)", p, len(hashes)) - return 0, errBadPeer - } - arrived = true - - // Modify the search interval based on the response - if !d.hasBlockAndState(hashes[0]) { - end = check - break - } - block := d.getBlock(hashes[0]) // this doesn't check state, hence the above explicit check - if block.NumberU64() != check { - glog.V(logger.Debug).Infof("%v: non requested hash #%d [%x…], instead of #%d", p, block.NumberU64(), block.Hash().Bytes()[:4], check) - return 0, errBadPeer - } - start = check - - case <-timeout: - glog.V(logger.Debug).Infof("%v: search hash timeout", p) - return 0, errTimeout - - case <-d.blockCh: - // Out of bounds blocks received, ignore them - - case <-d.headerCh: - case <-d.bodyCh: - case <-d.stateCh: - case <-d.receiptCh: - // Ignore eth/{62,63} packets because this is eth/61. - // These can arrive as a late delivery from a previous sync. - } - } - } - // Ensure valid ancestry and return - if int64(start) <= floor { - glog.V(logger.Warn).Infof("%v: potential rewrite attack: #%d [%x…] <= #%d limit", p, start, hash[:4], floor) - return 0, errInvalidAncestor - } - glog.V(logger.Debug).Infof("%v: common ancestor: #%d [%x…]", p, start, hash[:4]) - return start, nil -} - -// fetchHashes61 keeps retrieving hashes from the requested number, until no more -// are returned, potentially throttling on the way. -func (d *Downloader) fetchHashes61(p *peer, td *big.Int, from uint64) error { - glog.V(logger.Debug).Infof("%v: downloading hashes from #%d", p, from) - - // Create a timeout timer, and the associated hash fetcher - request := time.Now() // time of the last fetch request - timeout := time.NewTimer(0) // timer to dump a non-responsive active peer - <-timeout.C // timeout channel should be initially empty - defer timeout.Stop() - - getHashes := func(from uint64) { - glog.V(logger.Detail).Infof("%v: fetching %d hashes from #%d", p, MaxHashFetch, from) - - request = time.Now() - timeout.Reset(hashTTL) - go p.getAbsHashes(from, MaxHashFetch) - } - // Start pulling hashes, until all are exhausted - getHashes(from) - gotHashes := false - - for { - select { - case <-d.cancelCh: - return errCancelHashFetch - - case packet := <-d.hashCh: - // Make sure the active peer is giving us the hashes - if packet.PeerId() != p.id { - glog.V(logger.Debug).Infof("Received hashes from incorrect peer(%s)", packet.PeerId()) - break - } - hashReqTimer.UpdateSince(request) - timeout.Stop() - - // If no more hashes are inbound, notify the block fetcher and return - if packet.Items() == 0 { - glog.V(logger.Debug).Infof("%v: no available hashes", p) - - select { - case d.blockWakeCh <- false: - case <-d.cancelCh: - } - // If no hashes were retrieved at all, the peer violated it's TD promise that it had a - // better chain compared to ours. The only exception is if it's promised blocks were - // already imported by other means (e.g. fetcher): - // - // R , L : Both at block 10 - // R: Mine block 11, and propagate it to L - // L: Queue block 11 for import - // L: Notice that R's head and TD increased compared to ours, start sync - // L: Import of block 11 finishes - // L: Sync begins, and finds common ancestor at 11 - // L: Request new hashes up from 11 (R's TD was higher, it must have something) - // R: Nothing to give - if !gotHashes && td.Cmp(d.getTd(d.headBlock().Hash())) > 0 { - return errStallingPeer - } - return nil - } - gotHashes = true - hashes := packet.(*hashPack).hashes - - // Otherwise insert all the new hashes, aborting in case of junk - glog.V(logger.Detail).Infof("%v: scheduling %d hashes from #%d", p, len(hashes), from) - - inserts := d.queue.Schedule61(hashes, true) - if len(inserts) != len(hashes) { - glog.V(logger.Debug).Infof("%v: stale hashes", p) - return errBadPeer - } - // Notify the block fetcher of new hashes, but stop if queue is full - if d.queue.PendingBlocks() < maxQueuedHashes { - // We still have hashes to fetch, send continuation wake signal (potential) - select { - case d.blockWakeCh <- true: - default: - } - } else { - // Hash limit reached, send a termination wake signal (enforced) - select { - case d.blockWakeCh <- false: - case <-d.cancelCh: - } - return nil - } - // Queue not yet full, fetch the next batch - from += uint64(len(hashes)) - getHashes(from) - - case <-timeout.C: - glog.V(logger.Debug).Infof("%v: hash request timed out", p) - hashTimeoutMeter.Mark(1) - return errTimeout - - case <-d.headerCh: - case <-d.bodyCh: - case <-d.stateCh: - case <-d.receiptCh: - // Ignore eth/{62,63} packets because this is eth/61. - // These can arrive as a late delivery from a previous sync. - } - } -} - -// fetchBlocks61 iteratively downloads the scheduled hashes, taking any available -// peers, reserving a chunk of blocks for each, waiting for delivery and also -// periodically checking for timeouts. -func (d *Downloader) fetchBlocks61(from uint64) error { - glog.V(logger.Debug).Infof("Downloading blocks from #%d", from) - defer glog.V(logger.Debug).Infof("Block download terminated") - - // Create a timeout timer for scheduling expiration tasks - ticker := time.NewTicker(100 * time.Millisecond) - defer ticker.Stop() - - update := make(chan struct{}, 1) - - // Fetch blocks until the hash fetcher's done - finished := false - for { - select { - case <-d.cancelCh: - return errCancelBlockFetch - - case packet := <-d.blockCh: - // If the peer was previously banned and failed to deliver it's pack - // in a reasonable time frame, ignore it's message. - if peer := d.peers.Peer(packet.PeerId()); peer != nil { - blocks := packet.(*blockPack).blocks - - // Deliver the received chunk of blocks and check chain validity - accepted, err := d.queue.DeliverBlocks(peer.id, blocks) - if err == errInvalidChain { - return err - } - // Unless a peer delivered something completely else than requested (usually - // caused by a timed out request which came through in the end), set it to - // idle. If the delivery's stale, the peer should have already been idled. - if err != errStaleDelivery { - peer.SetBlocksIdle(accepted) - } - // Issue a log to the user to see what's going on - switch { - case err == nil && len(blocks) == 0: - glog.V(logger.Detail).Infof("%s: no blocks delivered", peer) - case err == nil: - glog.V(logger.Detail).Infof("%s: delivered %d blocks", peer, len(blocks)) - default: - glog.V(logger.Detail).Infof("%s: delivery failed: %v", peer, err) - } - } - // Blocks arrived, try to update the progress - select { - case update <- struct{}{}: - default: - } - - case cont := <-d.blockWakeCh: - // The hash fetcher sent a continuation flag, check if it's done - if !cont { - finished = true - } - // Hashes arrive, try to update the progress - select { - case update <- struct{}{}: - default: - } - - case <-ticker.C: - // Sanity check update the progress - select { - case update <- struct{}{}: - default: - } - - case <-update: - // Short circuit if we lost all our peers - if d.peers.Len() == 0 { - return errNoPeers - } - // Check for block request timeouts and demote the responsible peers - for pid, fails := range d.queue.ExpireBlocks(blockTTL) { - if peer := d.peers.Peer(pid); peer != nil { - if fails > 1 { - glog.V(logger.Detail).Infof("%s: block delivery timeout", peer) - peer.SetBlocksIdle(0) - } else { - glog.V(logger.Debug).Infof("%s: stalling block delivery, dropping", peer) - d.dropPeer(pid) - } - } - } - // If there's nothing more to fetch, wait or terminate - if d.queue.PendingBlocks() == 0 { - if !d.queue.InFlightBlocks() && finished { - glog.V(logger.Debug).Infof("Block fetching completed") - return nil - } - break - } - // Send a download request to all idle peers, until throttled - throttled := false - idles, total := d.peers.BlockIdlePeers() - - for _, peer := range idles { - // Short circuit if throttling activated - if d.queue.ShouldThrottleBlocks() { - throttled = true - break - } - // Reserve a chunk of hashes for a peer. A nil can mean either that - // no more hashes are available, or that the peer is known not to - // have them. - request := d.queue.ReserveBlocks(peer, peer.BlockCapacity(blockTargetRTT)) - if request == nil { - continue - } - if glog.V(logger.Detail) { - glog.Infof("%s: requesting %d blocks", peer, len(request.Hashes)) - } - // Fetch the chunk and make sure any errors return the hashes to the queue - if err := peer.Fetch61(request); err != nil { - // Although we could try and make an attempt to fix this, this error really - // means that we've double allocated a fetch task to a peer. If that is the - // case, the internal state of the downloader and the queue is very wrong so - // better hard crash and note the error instead of silently accumulating into - // a much bigger issue. - panic(fmt.Sprintf("%v: fetch assignment failed", peer)) - } - } - // Make sure that we have peers available for fetching. If all peers have been tried - // and all failed throw an error - if !throttled && !d.queue.InFlightBlocks() && len(idles) == total { - return errPeersUnavailable - } - - case <-d.headerCh: - case <-d.bodyCh: - case <-d.stateCh: - case <-d.receiptCh: - // Ignore eth/{62,63} packets because this is eth/61. - // These can arrive as a late delivery from a previous sync. - } - } -} - // fetchHeight retrieves the head header of the remote peer to aid in estimating // the total time a pending synchronisation would take. func (d *Downloader) fetchHeight(p *peer) (*types.Header, error) { glog.V(logger.Debug).Infof("%v: retrieving remote chain height", p) // Request the advertised remote head block and wait for the response - go p.getRelHeaders(p.head, 1, 0, false) + head, _ := p.currentHead() + go p.getRelHeaders(head, 1, 0, false) timeout := time.After(d.requestTTL()) for { @@ -1022,11 +545,6 @@ func (d *Downloader) fetchHeight(p *peer) (*types.Header, error) { case <-d.stateCh: case <-d.receiptCh: // Out of bounds delivery, ignore - - case <-d.hashCh: - case <-d.blockCh: - // Ignore eth/61 packets because this is eth/62+. - // These can arrive as a late delivery from a previous sync. } } } @@ -1037,7 +555,7 @@ func (d *Downloader) fetchHeight(p *peer) (*types.Header, error) { // In the rare scenario when we ended up on a long reorganisation (i.e. none of // the head links match), we do a binary search to find the common ancestor. func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) { - glog.V(logger.Debug).Infof("%v: looking for common ancestor", p) + glog.V(logger.Debug).Infof("%v: looking for common ancestor (remote height %d)", p, height) // Figure out the valid ancestor range to prevent rewrite attacks floor, ceil := int64(-1), d.headHeader().Number.Uint64() @@ -1054,11 +572,17 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) { if head > height { head = height } - from := int64(head) - int64(MaxHeaderFetch) + 1 + from := int64(head) - int64(MaxHeaderFetch) if from < 0 { from = 0 } - go p.getAbsHeaders(uint64(from), MaxHeaderFetch, 0, false) + // Span out with 15 block gaps into the future to catch bad head reports + limit := 2 * MaxHeaderFetch / 16 + count := 1 + int((int64(ceil)-from)/16) + if count > limit { + count = limit + } + go p.getAbsHeaders(uint64(from), count, 15, false) // Wait for the remote response to the head fetch number, hash := uint64(0), common.Hash{} @@ -1067,7 +591,7 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) { for finished := false; !finished; { select { case <-d.cancelCh: - return 0, errCancelHashFetch + return 0, errCancelHeaderFetch case packet := <-d.headerCh: // Discard anything not from the origin peer @@ -1083,12 +607,8 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) { } // Make sure the peer's reply conforms to the request for i := 0; i < len(headers); i++ { - if number := headers[i].Number.Int64(); number != from+int64(i) { - glog.V(logger.Warn).Infof("%v: head header set (item %d) broke chain ordering: requested %d, got %d", p, i, from+int64(i), number) - return 0, errInvalidChain - } - if i > 0 && headers[i-1].Hash() != headers[i].ParentHash { - glog.V(logger.Warn).Infof("%v: head header set (item %d) broke chain ancestry: expected [%x], got [%x]", p, i, headers[i-1].Hash().Bytes()[:4], headers[i].ParentHash[:4]) + if number := headers[i].Number.Int64(); number != from+int64(i)*16 { + glog.V(logger.Warn).Infof("%v: head header set (item %d) broke chain ordering: requested %d, got %d", p, i, from+int64(i)*16, number) return 0, errInvalidChain } } @@ -1096,12 +616,18 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) { finished = true for i := len(headers) - 1; i >= 0; i-- { // Skip any headers that underflow/overflow our requested set - if headers[i].Number.Int64() < from || headers[i].Number.Uint64() > head { + if headers[i].Number.Int64() < from || headers[i].Number.Uint64() > ceil { continue } // Otherwise check if we already know the header or not if (d.mode == FullSync && d.hasBlockAndState(headers[i].Hash())) || (d.mode != FullSync && d.hasHeader(headers[i].Hash())) { number, hash = headers[i].Number.Uint64(), headers[i].Hash() + + // If every header is known, even future ones, the peer straight out lied about its head + if number > height && i == limit-1 { + glog.V(logger.Warn).Infof("%v: lied about chain head: reported %d, found above %d", p, height, number) + return 0, errStallingPeer + } break } } @@ -1114,11 +640,6 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) { case <-d.stateCh: case <-d.receiptCh: // Out of bounds delivery, ignore - - case <-d.hashCh: - case <-d.blockCh: - // Ignore eth/61 packets because this is eth/62+. - // These can arrive as a late delivery from a previous sync. } } // If the head fetch already found an ancestor, return @@ -1146,7 +667,7 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) { for arrived := false; !arrived; { select { case <-d.cancelCh: - return 0, errCancelHashFetch + return 0, errCancelHeaderFetch case packer := <-d.headerCh: // Discard anything not from the origin peer @@ -1182,11 +703,6 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) { case <-d.stateCh: case <-d.receiptCh: // Out of bounds delivery, ignore - - case <-d.hashCh: - case <-d.blockCh: - // Ignore eth/61 packets because this is eth/62+. - // These can arrive as a late delivery from a previous sync. } } } @@ -1305,11 +821,6 @@ func (d *Downloader) fetchHeaders(p *peer, from uint64) error { case <-d.cancelCh: } return errBadPeer - - case <-d.hashCh: - case <-d.blockCh: - // Ignore eth/61 packets because this is eth/62+. - // These can arrive as a late delivery from a previous sync. } } } @@ -1555,7 +1066,14 @@ func (d *Downloader) fetchParts(errCancel error, deliveryCh chan dataPack, deliv // Check for fetch request timeouts and demote the responsible peers for pid, fails := range expire() { if peer := d.peers.Peer(pid); peer != nil { - if fails > 1 { + // If a lot of retrieval elements expired, we might have overestimated the remote peer or perhaps + // ourselves. Only reset to minimal throughput but don't drop just yet. If even the minimal times + // out that sync wise we need to get rid of the peer. + // + // The reason the minimum threshold is 2 is because the downloader tries to estimate the bandwidth + // and latency of a peer separately, which requires pushing the measures capacity a bit and seeing + // how response times reacts, to it always requests one more than the minimum (i.e. min 2). + if fails > 2 { glog.V(logger.Detail).Infof("%s: %s delivery timeout", peer, strings.ToLower(kind)) setIdle(peer, 0) } else { @@ -1623,11 +1141,6 @@ func (d *Downloader) fetchParts(errCancel error, deliveryCh chan dataPack, deliv if !progressed && !throttled && !running && len(idles) == total && pending() > 0 { return errPeersUnavailable } - - case <-d.hashCh: - case <-d.blockCh: - // Ignore eth/61 packets because this is eth/62+. - // These can arrive as a late delivery from a previous sync. } } } @@ -1882,19 +1395,6 @@ func (d *Downloader) processContent() error { } } -// DeliverHashes injects a new batch of hashes received from a remote node into -// the download schedule. This is usually invoked through the BlockHashesMsg by -// the protocol handler. -func (d *Downloader) DeliverHashes(id string, hashes []common.Hash) (err error) { - return d.deliver(id, d.hashCh, &hashPack{id, hashes}, hashInMeter, hashDropMeter) -} - -// DeliverBlocks injects a new batch of blocks received from a remote node. -// This is usually invoked through the BlocksMsg by the protocol handler. -func (d *Downloader) DeliverBlocks(id string, blocks []*types.Block) (err error) { - return d.deliver(id, d.blockCh, &blockPack{id, blocks}, blockInMeter, blockDropMeter) -} - // DeliverHeaders injects a new batch of block headers received from a remote // node into the download schedule. func (d *Downloader) DeliverHeaders(id string, headers []*types.Header) (err error) { diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/events.go b/vendor/github.com/ethereum/go-ethereum/eth/downloader/events.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/eth/downloader/events.go rename to vendor/github.com/ethereum/go-ethereum/eth/downloader/events.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/metrics.go b/vendor/github.com/ethereum/go-ethereum/eth/downloader/metrics.go similarity index 79% rename from src/vendor/github.com/ethereum/go-ethereum/eth/downloader/metrics.go rename to vendor/github.com/ethereum/go-ethereum/eth/downloader/metrics.go index d6fcfa25c..0d76c7dfd 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/metrics.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/downloader/metrics.go @@ -23,16 +23,6 @@ import ( ) var ( - hashInMeter = metrics.NewMeter("eth/downloader/hashes/in") - hashReqTimer = metrics.NewTimer("eth/downloader/hashes/req") - hashDropMeter = metrics.NewMeter("eth/downloader/hashes/drop") - hashTimeoutMeter = metrics.NewMeter("eth/downloader/hashes/timeout") - - blockInMeter = metrics.NewMeter("eth/downloader/blocks/in") - blockReqTimer = metrics.NewTimer("eth/downloader/blocks/req") - blockDropMeter = metrics.NewMeter("eth/downloader/blocks/drop") - blockTimeoutMeter = metrics.NewMeter("eth/downloader/blocks/timeout") - headerInMeter = metrics.NewMeter("eth/downloader/headers/in") headerReqTimer = metrics.NewTimer("eth/downloader/headers/req") headerDropMeter = metrics.NewMeter("eth/downloader/headers/drop") diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/modes.go b/vendor/github.com/ethereum/go-ethereum/eth/downloader/modes.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/eth/downloader/modes.go rename to vendor/github.com/ethereum/go-ethereum/eth/downloader/modes.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/peer.go b/vendor/github.com/ethereum/go-ethereum/eth/downloader/peer.go similarity index 90% rename from src/vendor/github.com/ethereum/go-ethereum/eth/downloader/peer.go rename to vendor/github.com/ethereum/go-ethereum/eth/downloader/peer.go index 94d44fca4..b0bfc66c8 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/peer.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/downloader/peer.go @@ -23,6 +23,7 @@ import ( "errors" "fmt" "math" + "math/big" "sort" "strings" "sync" @@ -37,10 +38,8 @@ const ( measurementImpact = 0.1 // The impact a single measurement has on a peer's final throughput value. ) -// Hash and block fetchers belonging to eth/61 and below -type relativeHashFetcherFn func(common.Hash) error -type absoluteHashFetcherFn func(uint64, int) error -type blockFetcherFn func([]common.Hash) error +// Head hash and total difficulty retriever for +type currentHeadRetrievalFn func() (common.Hash, *big.Int) // Block header and body fetchers belonging to eth/62 and above type relativeHeaderFetcherFn func(common.Hash, int, int, bool) error @@ -57,8 +56,7 @@ var ( // peer represents an active peer from which hashes and blocks are retrieved. type peer struct { - id string // Unique identifier of the peer - head common.Hash // Hash of the peers latest known block + id string // Unique identifier of the peer headerIdle int32 // Current header activity state of the peer (idle = 0, active = 1) blockIdle int32 // Current block activity state of the peer (idle = 0, active = 1) @@ -79,9 +77,7 @@ type peer struct { lacking map[common.Hash]struct{} // Set of hashes not to request (didn't have previously) - getRelHashes relativeHashFetcherFn // [eth/61] Method to retrieve a batch of hashes from an origin hash - getAbsHashes absoluteHashFetcherFn // [eth/61] Method to retrieve a batch of hashes from an absolute position - getBlocks blockFetcherFn // [eth/61] Method to retrieve a batch of blocks + currentHead currentHeadRetrievalFn // Method to fetch the currently known head of the peer getRelHeaders relativeHeaderFetcherFn // [eth/62] Method to retrieve a batch of headers from an origin hash getAbsHeaders absoluteHeaderFetcherFn // [eth/62] Method to retrieve a batch of headers from an absolute position @@ -96,19 +92,14 @@ type peer struct { // newPeer create a new downloader peer, with specific hash and block retrieval // mechanisms. -func newPeer(id string, version int, head common.Hash, - getRelHashes relativeHashFetcherFn, getAbsHashes absoluteHashFetcherFn, getBlocks blockFetcherFn, // eth/61 callbacks, remove when upgrading +func newPeer(id string, version int, currentHead currentHeadRetrievalFn, getRelHeaders relativeHeaderFetcherFn, getAbsHeaders absoluteHeaderFetcherFn, getBlockBodies blockBodyFetcherFn, getReceipts receiptFetcherFn, getNodeData stateFetcherFn) *peer { return &peer{ id: id, - head: head, lacking: make(map[common.Hash]struct{}), - getRelHashes: getRelHashes, - getAbsHashes: getAbsHashes, - getBlocks: getBlocks, - + currentHead: currentHead, getRelHeaders: getRelHeaders, getAbsHeaders: getAbsHeaders, getBlockBodies: getBlockBodies, @@ -138,28 +129,6 @@ func (p *peer) Reset() { p.lacking = make(map[common.Hash]struct{}) } -// Fetch61 sends a block retrieval request to the remote peer. -func (p *peer) Fetch61(request *fetchRequest) error { - // Sanity check the protocol version - if p.version != 61 { - panic(fmt.Sprintf("block fetch [eth/61] requested on eth/%d", p.version)) - } - // Short circuit if the peer is already fetching - if !atomic.CompareAndSwapInt32(&p.blockIdle, 0, 1) { - return errAlreadyFetching - } - p.blockStarted = time.Now() - - // Convert the hash set to a retrievable slice - hashes := make([]common.Hash, 0, len(request.Hashes)) - for hash, _ := range request.Hashes { - hashes = append(hashes, hash) - } - go p.getBlocks(hashes) - - return nil -} - // FetchHeaders sends a header retrieval request to the remote peer. func (p *peer) FetchHeaders(from uint64, count int) error { // Sanity check the protocol version @@ -481,20 +450,6 @@ func (ps *peerSet) AllPeers() []*peer { return list } -// BlockIdlePeers retrieves a flat list of all the currently idle peers within the -// active peer set, ordered by their reputation. -func (ps *peerSet) BlockIdlePeers() ([]*peer, int) { - idle := func(p *peer) bool { - return atomic.LoadInt32(&p.blockIdle) == 0 - } - throughput := func(p *peer) float64 { - p.lock.RLock() - defer p.lock.RUnlock() - return p.blockThroughput - } - return ps.idlePeers(61, 61, idle, throughput) -} - // HeaderIdlePeers retrieves a flat list of all the currently header-idle peers // within the active peer set, ordered by their reputation. func (ps *peerSet) HeaderIdlePeers() ([]*peer, int) { diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/queue.go b/vendor/github.com/ethereum/go-ethereum/eth/downloader/queue.go similarity index 89% rename from src/vendor/github.com/ethereum/go-ethereum/eth/downloader/queue.go rename to vendor/github.com/ethereum/go-ethereum/eth/downloader/queue.go index 01897af6d..fd239f7e4 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/queue.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/downloader/queue.go @@ -45,7 +45,6 @@ var ( var ( errNoFetchesPending = errors.New("no fetches pending") - errStateSyncPending = errors.New("state trie sync already scheduled") errStaleDelivery = errors.New("stale delivery") ) @@ -74,10 +73,6 @@ type queue struct { mode SyncMode // Synchronisation mode to decide on the block parts to schedule for fetching fastSyncPivot uint64 // Block number where the fast sync pivots into archive synchronisation mode - hashPool map[common.Hash]int // [eth/61] Pending hashes, mapping to their insertion index (priority) - hashQueue *prque.Prque // [eth/61] Priority queue of the block hashes to fetch - hashCounter int // [eth/61] Counter indexing the added hashes to ensure retrieval order - headerHead common.Hash // [eth/62] Hash of the last queued header to verify order // Headers are "special", they download in batches, supported by a skeleton chain @@ -85,7 +80,6 @@ type queue struct { headerTaskQueue *prque.Prque // [eth/62] Priority queue of the skeleton indexes to fetch the filling headers for headerPeerMiss map[string]map[uint64]struct{} // [eth/62] Set of per-peer header batches known to be unavailable headerPendPool map[string]*fetchRequest // [eth/62] Currently pending header retrieval operations - headerDonePool map[uint64]struct{} // [eth/62] Set of the completed header fetches headerResults []*types.Header // [eth/62] Result cache accumulating the completed headers headerProced int // [eth/62] Number of headers already processed from the results headerOffset uint64 // [eth/62] Number of the first header in the result cache @@ -124,8 +118,6 @@ type queue struct { func newQueue(stateDb ethdb.Database) *queue { lock := new(sync.Mutex) return &queue{ - hashPool: make(map[common.Hash]int), - hashQueue: prque.New(), headerPendPool: make(map[string]*fetchRequest), headerContCh: make(chan bool), blockTaskPool: make(map[common.Hash]*types.Header), @@ -158,10 +150,6 @@ func (q *queue) Reset() { q.mode = FullSync q.fastSyncPivot = 0 - q.hashPool = make(map[common.Hash]int) - q.hashQueue.Reset() - q.hashCounter = 0 - q.headerHead = common.Hash{} q.headerPendPool = make(map[string]*fetchRequest) @@ -208,7 +196,7 @@ func (q *queue) PendingBlocks() int { q.lock.Lock() defer q.lock.Unlock() - return q.hashQueue.Size() + q.blockTaskQueue.Size() + return q.blockTaskQueue.Size() } // PendingReceipts retrieves the number of block receipts pending for retrieval. @@ -272,7 +260,7 @@ func (q *queue) Idle() bool { q.lock.Lock() defer q.lock.Unlock() - queued := q.hashQueue.Size() + q.blockTaskQueue.Size() + q.receiptTaskQueue.Size() + q.stateTaskQueue.Size() + queued := q.blockTaskQueue.Size() + q.receiptTaskQueue.Size() + q.stateTaskQueue.Size() pending := len(q.blockPendPool) + len(q.receiptPendPool) + len(q.statePendPool) cached := len(q.blockDonePool) + len(q.receiptDonePool) @@ -323,34 +311,6 @@ func (q *queue) ShouldThrottleReceipts() bool { return pending >= len(q.resultCache)-len(q.receiptDonePool) } -// Schedule61 adds a set of hashes for the download queue for scheduling, returning -// the new hashes encountered. -func (q *queue) Schedule61(hashes []common.Hash, fifo bool) []common.Hash { - q.lock.Lock() - defer q.lock.Unlock() - - // Insert all the hashes prioritised in the arrival order - inserts := make([]common.Hash, 0, len(hashes)) - for _, hash := range hashes { - // Skip anything we already have - if old, ok := q.hashPool[hash]; ok { - glog.V(logger.Warn).Infof("Hash %x already scheduled at index %v", hash, old) - continue - } - // Update the counters and insert the hash - q.hashCounter = q.hashCounter + 1 - inserts = append(inserts, hash) - - q.hashPool[hash] = q.hashCounter - if fifo { - q.hashQueue.Push(hash, -float32(q.hashCounter)) // Lowest gets schedules first - } else { - q.hashQueue.Push(hash, float32(q.hashCounter)) // Highest gets schedules first - } - } - return inserts -} - // ScheduleSkeleton adds a batch of header retrieval tasks to the queue to fill // up an already retrieved header skeleton. func (q *queue) ScheduleSkeleton(from uint64, skeleton []*types.Header) { @@ -550,15 +510,6 @@ func (q *queue) ReserveHeaders(p *peer, count int) *fetchRequest { return request } -// ReserveBlocks reserves a set of block hashes for the given peer, skipping any -// previously failed download. -func (q *queue) ReserveBlocks(p *peer, count int) *fetchRequest { - q.lock.Lock() - defer q.lock.Unlock() - - return q.reserveHashes(p, count, q.hashQueue, nil, q.blockPendPool, len(q.resultCache)-len(q.blockDonePool)) -} - // ReserveNodeData reserves a set of node data hashes for the given peer, skipping // any previously failed download. func (q *queue) ReserveNodeData(p *peer, count int) *fetchRequest { @@ -753,11 +704,6 @@ func (q *queue) CancelHeaders(request *fetchRequest) { q.cancel(request, q.headerTaskQueue, q.headerPendPool) } -// CancelBlocks aborts a fetch request, returning all pending hashes to the queue. -func (q *queue) CancelBlocks(request *fetchRequest) { - q.cancel(request, q.hashQueue, q.blockPendPool) -} - // CancelBodies aborts a body fetch request, returning all pending headers to the // task queue. func (q *queue) CancelBodies(request *fetchRequest) { @@ -801,9 +747,6 @@ func (q *queue) Revoke(peerId string) { defer q.lock.Unlock() if request, ok := q.blockPendPool[peerId]; ok { - for hash, index := range request.Hashes { - q.hashQueue.Push(hash, float32(index)) - } for _, header := range request.Headers { q.blockTaskQueue.Push(header, -float32(header.Number.Uint64())) } @@ -832,15 +775,6 @@ func (q *queue) ExpireHeaders(timeout time.Duration) map[string]int { return q.expire(timeout, q.headerPendPool, q.headerTaskQueue, headerTimeoutMeter) } -// ExpireBlocks checks for in flight requests that exceeded a timeout allowance, -// canceling them and returning the responsible peers for penalisation. -func (q *queue) ExpireBlocks(timeout time.Duration) map[string]int { - q.lock.Lock() - defer q.lock.Unlock() - - return q.expire(timeout, q.blockPendPool, q.hashQueue, blockTimeoutMeter) -} - // ExpireBodies checks for in flight block body requests that exceeded a timeout // allowance, canceling them and returning the responsible peers for penalisation. func (q *queue) ExpireBodies(timeout time.Duration) map[string]int { @@ -907,74 +841,6 @@ func (q *queue) expire(timeout time.Duration, pendPool map[string]*fetchRequest, return expiries } -// DeliverBlocks injects a block retrieval response into the download queue. The -// method returns the number of blocks accepted from the delivery and also wakes -// any threads waiting for data delivery. -func (q *queue) DeliverBlocks(id string, blocks []*types.Block) (int, error) { - q.lock.Lock() - defer q.lock.Unlock() - - // Short circuit if the blocks were never requested - request := q.blockPendPool[id] - if request == nil { - return 0, errNoFetchesPending - } - blockReqTimer.UpdateSince(request.Time) - delete(q.blockPendPool, id) - - // If no blocks were retrieved, mark them as unavailable for the origin peer - if len(blocks) == 0 { - for hash, _ := range request.Hashes { - request.Peer.MarkLacking(hash) - } - } - // Iterate over the downloaded blocks and add each of them - accepted, errs := 0, make([]error, 0) - for _, block := range blocks { - // Skip any blocks that were not requested - hash := block.Hash() - if _, ok := request.Hashes[hash]; !ok { - errs = append(errs, fmt.Errorf("non-requested block %x", hash)) - continue - } - // Reconstruct the next result if contents match up - index := int(block.Number().Int64() - int64(q.resultOffset)) - if index >= len(q.resultCache) || index < 0 { - errs = []error{errInvalidChain} - break - } - q.resultCache[index] = &fetchResult{ - Header: block.Header(), - Transactions: block.Transactions(), - Uncles: block.Uncles(), - } - q.blockDonePool[block.Hash()] = struct{}{} - - delete(request.Hashes, hash) - delete(q.hashPool, hash) - accepted++ - } - // Return all failed or missing fetches to the queue - for hash, index := range request.Hashes { - q.hashQueue.Push(hash, float32(index)) - } - // Wake up WaitResults - if accepted > 0 { - q.active.Signal() - } - // If none of the blocks were good, it's a stale delivery - switch { - case len(errs) == 0: - return accepted, nil - case len(errs) == 1 && (errs[0] == errInvalidChain || errs[0] == errInvalidBlock): - return accepted, errs[0] - case len(errs) == len(blocks): - return accepted, errStaleDelivery - default: - return accepted, fmt.Errorf("multiple failures: %v", errs) - } -} - // DeliverHeaders injects a header retrieval response into the header results // cache. This method either accepts all headers it received, or none of them // if they do not map correctly to the skeleton. diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/types.go b/vendor/github.com/ethereum/go-ethereum/eth/downloader/types.go similarity index 87% rename from src/vendor/github.com/ethereum/go-ethereum/eth/downloader/types.go rename to vendor/github.com/ethereum/go-ethereum/eth/downloader/types.go index b67fff1f8..e10510486 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/downloader/types.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/downloader/types.go @@ -73,26 +73,6 @@ type dataPack interface { Stats() string } -// hashPack is a batch of block hashes returned by a peer (eth/61). -type hashPack struct { - peerId string - hashes []common.Hash -} - -func (p *hashPack) PeerId() string { return p.peerId } -func (p *hashPack) Items() int { return len(p.hashes) } -func (p *hashPack) Stats() string { return fmt.Sprintf("%d", len(p.hashes)) } - -// blockPack is a batch of blocks returned by a peer (eth/61). -type blockPack struct { - peerId string - blocks []*types.Block -} - -func (p *blockPack) PeerId() string { return p.peerId } -func (p *blockPack) Items() int { return len(p.blocks) } -func (p *blockPack) Stats() string { return fmt.Sprintf("%d", len(p.blocks)) } - // headerPack is a batch of block headers returned by a peer. type headerPack struct { peerId string diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/fetcher/fetcher.go b/vendor/github.com/ethereum/go-ethereum/eth/fetcher/fetcher.go similarity index 90% rename from src/vendor/github.com/ethereum/go-ethereum/eth/fetcher/fetcher.go rename to vendor/github.com/ethereum/go-ethereum/eth/fetcher/fetcher.go index 9300717c3..bd235bb9e 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/fetcher/fetcher.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/fetcher/fetcher.go @@ -48,9 +48,6 @@ var ( // blockRetrievalFn is a callback type for retrieving a block from the local chain. type blockRetrievalFn func(common.Hash) *types.Block -// blockRequesterFn is a callback type for sending a block retrieval request. -type blockRequesterFn func([]common.Hash) error - // headerRequesterFn is a callback type for sending a header retrieval request. type headerRequesterFn func(common.Hash) error @@ -82,7 +79,6 @@ type announce struct { origin string // Identifier of the peer originating the notification - fetch61 blockRequesterFn // [eth/61] Fetcher function to retrieve an announced block fetchHeader headerRequesterFn // [eth/62] Fetcher function to retrieve the header of an announced block fetchBodies bodyRequesterFn // [eth/62] Fetcher function to retrieve the body of an announced block } @@ -191,14 +187,12 @@ func (f *Fetcher) Stop() { // Notify announces the fetcher of the potential availability of a new block in // the network. func (f *Fetcher) Notify(peer string, hash common.Hash, number uint64, time time.Time, - blockFetcher blockRequesterFn, // eth/61 specific whole block fetcher headerFetcher headerRequesterFn, bodyFetcher bodyRequesterFn) error { block := &announce{ hash: hash, number: number, time: time, origin: peer, - fetch61: blockFetcher, fetchHeader: headerFetcher, fetchBodies: bodyFetcher, } @@ -224,34 +218,6 @@ func (f *Fetcher) Enqueue(peer string, block *types.Block) error { } } -// FilterBlocks extracts all the blocks that were explicitly requested by the fetcher, -// returning those that should be handled differently. -func (f *Fetcher) FilterBlocks(blocks types.Blocks) types.Blocks { - glog.V(logger.Detail).Infof("[eth/61] filtering %d blocks", len(blocks)) - - // Send the filter channel to the fetcher - filter := make(chan []*types.Block) - - select { - case f.blockFilter <- filter: - case <-f.quit: - return nil - } - // Request the filtering of the block list - select { - case filter <- blocks: - case <-f.quit: - return nil - } - // Retrieve the blocks remaining after filtering - select { - case blocks := <-filter: - return blocks - case <-f.quit: - return nil - } -} - // FilterHeaders extracts all the headers that were explicitly requested by the fetcher, // returning those that should be handled differently. func (f *Fetcher) FilterHeaders(headers []*types.Header, time time.Time) []*types.Header { @@ -413,7 +379,7 @@ func (f *Fetcher) loop() { } } } - // Send out all block (eth/61) or header (eth/62) requests + // Send out all block header requests for peer, hashes := range request { if glog.V(logger.Detail) && len(hashes) > 0 { list := "[" @@ -421,29 +387,17 @@ func (f *Fetcher) loop() { list += fmt.Sprintf("%x…, ", hash[:4]) } list = list[:len(list)-2] + "]" - - if f.fetching[hashes[0]].fetch61 != nil { - glog.V(logger.Detail).Infof("[eth/61] Peer %s: fetching blocks %s", peer, list) - } else { - glog.V(logger.Detail).Infof("[eth/62] Peer %s: fetching headers %s", peer, list) - } + glog.V(logger.Detail).Infof("[eth/62] Peer %s: fetching headers %s", peer, list) } // Create a closure of the fetch and schedule in on a new thread - fetchBlocks, fetchHeader, hashes := f.fetching[hashes[0]].fetch61, f.fetching[hashes[0]].fetchHeader, hashes + fetchHeader, hashes := f.fetching[hashes[0]].fetchHeader, hashes go func() { if f.fetchingHook != nil { f.fetchingHook(hashes) } - if fetchBlocks != nil { - // Use old eth/61 protocol to retrieve whole blocks - blockFetchMeter.Mark(int64(len(hashes))) - fetchBlocks(hashes) - } else { - // Use new eth/62 protocol to retrieve headers first - for _, hash := range hashes { - headerFetchMeter.Mark(1) - fetchHeader(hash) // Suboptimal, but protocol doesn't allow batch header retrievals - } + for _, hash := range hashes { + headerFetchMeter.Mark(1) + fetchHeader(hash) // Suboptimal, but protocol doesn't allow batch header retrievals } }() } @@ -486,46 +440,6 @@ func (f *Fetcher) loop() { // Schedule the next fetch if blocks are still pending f.rescheduleComplete(completeTimer) - case filter := <-f.blockFilter: - // Blocks arrived, extract any explicit fetches, return all else - var blocks types.Blocks - select { - case blocks = <-filter: - case <-f.quit: - return - } - blockFilterInMeter.Mark(int64(len(blocks))) - - explicit, download := []*types.Block{}, []*types.Block{} - for _, block := range blocks { - hash := block.Hash() - - // Filter explicitly requested blocks from hash announcements - if f.fetching[hash] != nil && f.queued[hash] == nil { - // Discard if already imported by other means - if f.getBlock(hash) == nil { - explicit = append(explicit, block) - } else { - f.forgetHash(hash) - } - } else { - download = append(download, block) - } - } - - blockFilterOutMeter.Mark(int64(len(download))) - select { - case filter <- download: - case <-f.quit: - return - } - // Schedule the retrieved blocks for ordered import - for _, block := range explicit { - if announce := f.fetching[block.Hash()]; announce != nil { - f.enqueue(announce.origin, block) - } - } - case filter := <-f.headerFilter: // Headers arrived from a remote peer. Extract those that were explicitly // requested by the fetcher, and return everything else so it's delivered diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/fetcher/metrics.go b/vendor/github.com/ethereum/go-ethereum/eth/fetcher/metrics.go similarity index 90% rename from src/vendor/github.com/ethereum/go-ethereum/eth/fetcher/metrics.go rename to vendor/github.com/ethereum/go-ethereum/eth/fetcher/metrics.go index b82d3ca01..1ed8075bf 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/fetcher/metrics.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/fetcher/metrics.go @@ -33,12 +33,9 @@ var ( propBroadcastDropMeter = metrics.NewMeter("eth/fetcher/prop/broadcasts/drop") propBroadcastDOSMeter = metrics.NewMeter("eth/fetcher/prop/broadcasts/dos") - blockFetchMeter = metrics.NewMeter("eth/fetcher/fetch/blocks") headerFetchMeter = metrics.NewMeter("eth/fetcher/fetch/headers") bodyFetchMeter = metrics.NewMeter("eth/fetcher/fetch/bodies") - blockFilterInMeter = metrics.NewMeter("eth/fetcher/filter/blocks/in") - blockFilterOutMeter = metrics.NewMeter("eth/fetcher/filter/blocks/out") headerFilterInMeter = metrics.NewMeter("eth/fetcher/filter/headers/in") headerFilterOutMeter = metrics.NewMeter("eth/fetcher/filter/headers/out") bodyFilterInMeter = metrics.NewMeter("eth/fetcher/filter/bodies/in") diff --git a/vendor/github.com/ethereum/go-ethereum/eth/filters/api.go b/vendor/github.com/ethereum/go-ethereum/eth/filters/api.go new file mode 100644 index 000000000..4ba3fb1f2 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/eth/filters/api.go @@ -0,0 +1,544 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package filters + +import ( + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "math/big" + "sync" + "time" + + "golang.org/x/net/context" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/internal/ethapi" + "github.com/ethereum/go-ethereum/rpc" +) + +var ( + deadline = 5 * time.Minute // consider a filter inactive if it has not been polled for within deadline +) + +// filter is a helper struct that holds meta information over the filter type +// and associated subscription in the event system. +type filter struct { + typ Type + deadline *time.Timer // filter is inactiv when deadline triggers + hashes []common.Hash + crit FilterCriteria + logs []Log + s *Subscription // associated subscription in event system +} + +// PublicFilterAPI offers support to create and manage filters. This will allow external clients to retrieve various +// information related to the Ethereum protocol such als blocks, transactions and logs. +type PublicFilterAPI struct { + apiBackend ethapi.Backend + mux *event.TypeMux + quit chan struct{} + chainDb ethdb.Database + events *EventSystem + filtersMu sync.Mutex + filters map[rpc.ID]*filter +} + +// NewPublicFilterAPI returns a new PublicFilterAPI instance. +func NewPublicFilterAPI(apiBackend ethapi.Backend) *PublicFilterAPI { + api := &PublicFilterAPI{ + apiBackend: apiBackend, + mux: apiBackend.EventMux(), + chainDb: apiBackend.ChainDb(), + events: NewEventSystem(apiBackend.EventMux()), + filters: make(map[rpc.ID]*filter), + } + + go api.timeoutLoop() + + return api +} + +// timeoutLoop runs every 5 minutes and deletes filters that have not been recently used. +// Tt is started when the api is created. +func (api *PublicFilterAPI) timeoutLoop() { + ticker := time.NewTicker(5 * time.Minute) + for { + <-ticker.C + api.filtersMu.Lock() + for id, f := range api.filters { + select { + case <-f.deadline.C: + f.s.Unsubscribe() + delete(api.filters, id) + default: + continue + } + } + api.filtersMu.Unlock() + } +} + +// NewPendingTransactionFilter creates a filter that fetches pending transaction hashes +// as transactions enter the pending state. +// +// It is part of the filter package because this filter can be used throug the +// `eth_getFilterChanges` polling method that is also used for log filters. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newpendingtransactionfilter +func (api *PublicFilterAPI) NewPendingTransactionFilter() rpc.ID { + var ( + pendingTxs = make(chan common.Hash) + pendingTxSub = api.events.SubscribePendingTxEvents(pendingTxs) + ) + + api.filtersMu.Lock() + api.filters[pendingTxSub.ID] = &filter{typ: PendingTransactionsSubscription, deadline: time.NewTimer(deadline), hashes: make([]common.Hash, 0), s: pendingTxSub} + api.filtersMu.Unlock() + + go func() { + for { + select { + case ph := <-pendingTxs: + api.filtersMu.Lock() + if f, found := api.filters[pendingTxSub.ID]; found { + f.hashes = append(f.hashes, ph) + } + api.filtersMu.Unlock() + case <-pendingTxSub.Err(): + api.filtersMu.Lock() + delete(api.filters, pendingTxSub.ID) + api.filtersMu.Unlock() + return + } + } + }() + + return pendingTxSub.ID +} + +// NewPendingTransactions creates a subscription that is triggered each time a transaction +// enters the transaction pool and was signed from one of the transactions this nodes manages. +func (api *PublicFilterAPI) NewPendingTransactions(ctx context.Context) (*rpc.Subscription, error) { + notifier, supported := rpc.NotifierFromContext(ctx) + if !supported { + return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported + } + + rpcSub := notifier.CreateSubscription() + + go func() { + txHashes := make(chan common.Hash) + pendingTxSub := api.events.SubscribePendingTxEvents(txHashes) + + for { + select { + case h := <-txHashes: + notifier.Notify(rpcSub.ID, h) + case <-rpcSub.Err(): + pendingTxSub.Unsubscribe() + return + case <-notifier.Closed(): + pendingTxSub.Unsubscribe() + return + } + } + }() + + return rpcSub, nil +} + +// NewBlockFilter creates a filter that fetches blocks that are imported into the chain. +// It is part of the filter package since polling goes with eth_getFilterChanges. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newblockfilter +func (api *PublicFilterAPI) NewBlockFilter() rpc.ID { + var ( + headers = make(chan *types.Header) + headerSub = api.events.SubscribeNewHeads(headers) + ) + + api.filtersMu.Lock() + api.filters[headerSub.ID] = &filter{typ: BlocksSubscription, deadline: time.NewTimer(deadline), hashes: make([]common.Hash, 0), s: headerSub} + api.filtersMu.Unlock() + + go func() { + for { + select { + case h := <-headers: + api.filtersMu.Lock() + if f, found := api.filters[headerSub.ID]; found { + f.hashes = append(f.hashes, h.Hash()) + } + api.filtersMu.Unlock() + case <-headerSub.Err(): + api.filtersMu.Lock() + delete(api.filters, headerSub.ID) + api.filtersMu.Unlock() + return + } + } + }() + + return headerSub.ID +} + +// NewHeads send a notification each time a new (header) block is appended to the chain. +func (api *PublicFilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error) { + notifier, supported := rpc.NotifierFromContext(ctx) + if !supported { + return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported + } + + rpcSub := notifier.CreateSubscription() + + go func() { + headers := make(chan *types.Header) + headersSub := api.events.SubscribeNewHeads(headers) + + for { + select { + case h := <-headers: + notifier.Notify(rpcSub.ID, h) + case <-rpcSub.Err(): + headersSub.Unsubscribe() + return + case <-notifier.Closed(): + headersSub.Unsubscribe() + return + } + } + }() + + return rpcSub, nil +} + +// Logs creates a subscription that fires for all new log that match the given filter criteria. +func (api *PublicFilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subscription, error) { + notifier, supported := rpc.NotifierFromContext(ctx) + if !supported { + return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported + } + + rpcSub := notifier.CreateSubscription() + + go func() { + matchedLogs := make(chan []Log) + logsSub := api.events.SubscribeLogs(crit, matchedLogs) + + for { + select { + case logs := <-matchedLogs: + for _, log := range logs { + notifier.Notify(rpcSub.ID, &log) + } + case <-rpcSub.Err(): // client send an unsubscribe request + logsSub.Unsubscribe() + return + case <-notifier.Closed(): // connection dropped + logsSub.Unsubscribe() + return + } + } + }() + + return rpcSub, nil +} + +// FilterCriteria represents a request to create a new filter. +type FilterCriteria struct { + FromBlock *big.Int + ToBlock *big.Int + Addresses []common.Address + Topics [][]common.Hash +} + +// NewFilter creates a new filter and returns the filter id. It can be +// used to retrieve logs when the state changes. This method cannot be +// used to fetch logs that are already stored in the state. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter +func (api *PublicFilterAPI) NewFilter(crit FilterCriteria) rpc.ID { + var ( + logs = make(chan []Log) + logsSub = api.events.SubscribeLogs(crit, logs) + ) + + if crit.FromBlock == nil { + crit.FromBlock = big.NewInt(rpc.LatestBlockNumber.Int64()) + } + if crit.ToBlock == nil { + crit.ToBlock = big.NewInt(rpc.LatestBlockNumber.Int64()) + } + + api.filtersMu.Lock() + api.filters[logsSub.ID] = &filter{typ: LogsSubscription, crit: crit, deadline: time.NewTimer(deadline), logs: make([]Log, 0), s: logsSub} + api.filtersMu.Unlock() + + go func() { + for { + select { + case l := <-logs: + api.filtersMu.Lock() + if f, found := api.filters[logsSub.ID]; found { + f.logs = append(f.logs, l...) + } + api.filtersMu.Unlock() + case <-logsSub.Err(): + api.filtersMu.Lock() + delete(api.filters, logsSub.ID) + api.filtersMu.Unlock() + return + } + } + }() + + return logsSub.ID +} + +// GetLogs returns logs matching the given argument that are stored within the state. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs +func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]Log, error) { + if crit.FromBlock == nil { + crit.FromBlock = big.NewInt(rpc.LatestBlockNumber.Int64()) + } + if crit.ToBlock == nil { + crit.ToBlock = big.NewInt(rpc.LatestBlockNumber.Int64()) + } + + filter := New(api.apiBackend) + filter.SetBeginBlock(crit.FromBlock.Int64()) + filter.SetEndBlock(crit.ToBlock.Int64()) + filter.SetAddresses(crit.Addresses) + filter.SetTopics(crit.Topics) + + logs, err := filter.Find(ctx) + return returnLogs(logs), err +} + +// UninstallFilter removes the filter with the given filter id. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_uninstallfilter +func (api *PublicFilterAPI) UninstallFilter(id rpc.ID) bool { + api.filtersMu.Lock() + f, found := api.filters[id] + if found { + delete(api.filters, id) + } + api.filtersMu.Unlock() + if found { + f.s.Unsubscribe() + } + + return found +} + +// GetFilterLogs returns the logs for the filter with the given id. +// If the filter could not be found an empty array of logs is returned. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs +func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]Log, error) { + api.filtersMu.Lock() + f, found := api.filters[id] + api.filtersMu.Unlock() + + if !found || f.typ != LogsSubscription { + return []Log{}, nil + } + + filter := New(api.apiBackend) + filter.SetBeginBlock(f.crit.FromBlock.Int64()) + filter.SetEndBlock(f.crit.ToBlock.Int64()) + filter.SetAddresses(f.crit.Addresses) + filter.SetTopics(f.crit.Topics) + + logs, err := filter.Find(ctx) + return returnLogs(logs), err +} + +// GetFilterChanges returns the logs for the filter with the given id since +// last time is was called. This can be used for polling. +// +// For pending transaction and block filters the result is []common.Hash. +// (pending)Log filters return []Log. If the filter could not be found +// []interface{}{} is returned. +// +// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges +func (api *PublicFilterAPI) GetFilterChanges(id rpc.ID) interface{} { + api.filtersMu.Lock() + defer api.filtersMu.Unlock() + + if f, found := api.filters[id]; found { + if !f.deadline.Stop() { + // timer expired but filter is not yet removed in timeout loop + // receive timer value and reset timer + <-f.deadline.C + } + f.deadline.Reset(deadline) + + switch f.typ { + case PendingTransactionsSubscription, BlocksSubscription: + hashes := f.hashes + f.hashes = nil + return returnHashes(hashes) + case PendingLogsSubscription, LogsSubscription: + logs := f.logs + f.logs = nil + return returnLogs(logs) + } + } + + return []interface{}{} +} + +// returnHashes is a helper that will return an empty hash array case the given hash array is nil, +// otherwise the given hashes array is returned. +func returnHashes(hashes []common.Hash) []common.Hash { + if hashes == nil { + return []common.Hash{} + } + return hashes +} + +// returnLogs is a helper that will return an empty log array in case the given logs array is nil, +// otherwise the given logs array is returned. +func returnLogs(logs []Log) []Log { + if logs == nil { + return []Log{} + } + return logs +} + +// UnmarshalJSON sets *args fields with given data. +func (args *FilterCriteria) UnmarshalJSON(data []byte) error { + type input struct { + From *rpc.BlockNumber `json:"fromBlock"` + ToBlock *rpc.BlockNumber `json:"toBlock"` + Addresses interface{} `json:"address"` + Topics []interface{} `json:"topics"` + } + + var raw input + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + + if raw.From == nil || raw.From.Int64() < 0 { + args.FromBlock = big.NewInt(rpc.LatestBlockNumber.Int64()) + } else { + args.FromBlock = big.NewInt(raw.From.Int64()) + } + + if raw.ToBlock == nil || raw.ToBlock.Int64() < 0 { + args.ToBlock = big.NewInt(rpc.LatestBlockNumber.Int64()) + } else { + args.ToBlock = big.NewInt(raw.ToBlock.Int64()) + } + + args.Addresses = []common.Address{} + + if raw.Addresses != nil { + // raw.Address can contain a single address or an array of addresses + var addresses []common.Address + if strAddrs, ok := raw.Addresses.([]interface{}); ok { + for i, addr := range strAddrs { + if strAddr, ok := addr.(string); ok { + if len(strAddr) >= 2 && strAddr[0] == '0' && (strAddr[1] == 'x' || strAddr[1] == 'X') { + strAddr = strAddr[2:] + } + if decAddr, err := hex.DecodeString(strAddr); err == nil { + addresses = append(addresses, common.BytesToAddress(decAddr)) + } else { + return fmt.Errorf("invalid address given") + } + } else { + return fmt.Errorf("invalid address on index %d", i) + } + } + } else if singleAddr, ok := raw.Addresses.(string); ok { + if len(singleAddr) >= 2 && singleAddr[0] == '0' && (singleAddr[1] == 'x' || singleAddr[1] == 'X') { + singleAddr = singleAddr[2:] + } + if decAddr, err := hex.DecodeString(singleAddr); err == nil { + addresses = append(addresses, common.BytesToAddress(decAddr)) + } else { + return fmt.Errorf("invalid address given") + } + } else { + return errors.New("invalid address(es) given") + } + args.Addresses = addresses + } + + // helper function which parses a string to a topic hash + topicConverter := func(raw string) (common.Hash, error) { + if len(raw) == 0 { + return common.Hash{}, nil + } + if len(raw) >= 2 && raw[0] == '0' && (raw[1] == 'x' || raw[1] == 'X') { + raw = raw[2:] + } + if len(raw) != 2*common.HashLength { + return common.Hash{}, errors.New("invalid topic(s)") + } + if decAddr, err := hex.DecodeString(raw); err == nil { + return common.BytesToHash(decAddr), nil + } + return common.Hash{}, errors.New("invalid topic(s)") + } + + // topics is an array consisting of strings and/or arrays of strings. + // JSON null values are converted to common.Hash{} and ignored by the filter manager. + if len(raw.Topics) > 0 { + args.Topics = make([][]common.Hash, len(raw.Topics)) + for i, t := range raw.Topics { + if t == nil { // ignore topic when matching logs + args.Topics[i] = []common.Hash{common.Hash{}} + } else if topic, ok := t.(string); ok { // match specific topic + top, err := topicConverter(topic) + if err != nil { + return err + } + args.Topics[i] = []common.Hash{top} + } else if topics, ok := t.([]interface{}); ok { // or case e.g. [null, "topic0", "topic1"] + for _, rawTopic := range topics { + if rawTopic == nil { + args.Topics[i] = append(args.Topics[i], common.Hash{}) + } else if topic, ok := rawTopic.(string); ok { + parsed, err := topicConverter(topic) + if err != nil { + return err + } + args.Topics[i] = append(args.Topics[i], parsed) + } else { + return fmt.Errorf("invalid topic(s)") + } + } + } else { + return fmt.Errorf("invalid topic(s)") + } + } + } + + return nil +} + diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/filters/filter.go b/vendor/github.com/ethereum/go-ethereum/eth/filters/filter.go similarity index 63% rename from src/vendor/github.com/ethereum/go-ethereum/eth/filters/filter.go rename to vendor/github.com/ethereum/go-ethereum/eth/filters/filter.go index f44484e26..1e6a6f6f9 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/filters/filter.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/filters/filter.go @@ -17,24 +17,19 @@ package filters import ( -// "math" + // "math" "time" "github.com/ethereum/go-ethereum/common" -// "github.com/ethereum/go-ethereum/core" + // "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/rpc" "golang.org/x/net/context" ) -type AccountChange struct { - Address, StateAddress []byte -} - -// Filtering interface +// Filter can be used to retrieve and filter logs type Filter struct { apiBackend ethapi.Backend @@ -44,14 +39,10 @@ type Filter struct { begin, end int64 addresses []common.Address topics [][]common.Hash - - BlockCallback func(*types.Block, vm.Logs) - TransactionCallback func(*types.Transaction) - LogCallback func(*vm.Log, bool) } -// Create a new filter which uses a bloom filter on blocks to figure out whether a particular block -// is interesting or not. +// New creates a new filter which uses a bloom filter on blocks to figure out whether +// a particular block is interesting or not. func New(apiBackend ethapi.Backend) *Filter { return &Filter{ apiBackend: apiBackend, @@ -59,56 +50,61 @@ func New(apiBackend ethapi.Backend) *Filter { } } -// Set the earliest and latest block for filtering. +// SetBeginBlock sets the earliest block for filtering. // -1 = latest block (i.e., the current block) // hash = particular hash from-to -func (self *Filter) SetBeginBlock(begin int64) { - self.begin = begin +func (f *Filter) SetBeginBlock(begin int64) { + f.begin = begin } -func (self *Filter) SetEndBlock(end int64) { - self.end = end +// SetEndBlock sets the latest block for filtering. +func (f *Filter) SetEndBlock(end int64) { + f.end = end } -func (self *Filter) SetAddresses(addr []common.Address) { - self.addresses = addr +// SetAddresses matches only logs that are generated from addresses that are included +// in the given addresses. +func (f *Filter) SetAddresses(addr []common.Address) { + f.addresses = addr } -func (self *Filter) SetTopics(topics [][]common.Hash) { - self.topics = topics +// SetTopics matches only logs that have topics matching the given topics. +func (f *Filter) SetTopics(topics [][]common.Hash) { + f.topics = topics } // Run filters logs with the current parameters set -func (self *Filter) Find(ctx context.Context) (vm.Logs, error) { - head, _ := self.apiBackend.HeaderByNumber(ctx, rpc.LatestBlockNumber) +func (f *Filter) Find(ctx context.Context) ([]Log, error) { + head, _ := f.apiBackend.HeaderByNumber(ctx, rpc.LatestBlockNumber) headBlockNumber := head.Number.Uint64() - - var beginBlockNo uint64 = uint64(self.begin) - if self.begin == -1 { + + var beginBlockNo uint64 = uint64(f.begin) + if f.begin == -1 { beginBlockNo = headBlockNumber } - var endBlockNo uint64 = uint64(self.end) - if self.end == -1 { + var endBlockNo uint64 = uint64(f.end) + if f.end == -1 { endBlockNo = headBlockNumber } // if no addresses are present we can't make use of fast search which // uses the mipmap bloom filters to check for fast inclusion and uses // higher range probability in order to ensure at least a false positive -// if len(self.addresses) == 0 { - return self.getLogs(ctx, beginBlockNo, endBlockNo) -// } -// return self.mipFind(beginBlockNo, endBlockNo, 0) + // if len(self.addresses) == 0 { + return f.getLogs(ctx, beginBlockNo, endBlockNo) + // } + // return self.mipFind(beginBlockNo, endBlockNo, 0) } /*func (self *Filter) mipFind(start, end uint64, depth int) (logs vm.Logs) { +>>>>>>> les: light client protocol and API level := core.MIPMapLevels[depth] // normalise numerator so we can work in level specific batches and // work with the proper range checks for num := start / level * level; num <= end; num += level { // find addresses in bloom filters - bloom := core.GetMipmapBloom(self.db, num, level) - for _, addr := range self.addresses { + bloom := core.GetMipmapBloom(f.db, num, level) + for _, addr := range f.addresses { if bloom.TestBytes(addr[:]) { // range check normalised values and make sure that // we're resolving the correct range instead of the @@ -116,9 +112,9 @@ func (self *Filter) Find(ctx context.Context) (vm.Logs, error) { start := uint64(math.Max(float64(num), float64(start))) end := uint64(math.Min(float64(num+level-1), float64(end))) if depth+1 == len(core.MIPMapLevels) { - logs = append(logs, self.getLogs(start, end)...) + logs = append(logs, f.getLogs(start, end)...) } else { - logs = append(logs, self.mipFind(start, end, depth+1)...) + logs = append(logs, f.mipFind(start, end, depth+1)...) } // break so we don't check the same range for each // possible address. Checks on multiple addresses @@ -131,26 +127,30 @@ func (self *Filter) Find(ctx context.Context) (vm.Logs, error) { return logs }*/ -func (self *Filter) getLogs(ctx context.Context, start, end uint64) (logs vm.Logs, err error) { +func (f *Filter) getLogs(ctx context.Context, start, end uint64) (logs []Log, err error) { for i := start; i <= end; i++ { - header, err := self.apiBackend.HeaderByNumber(ctx, rpc.BlockNumber(i)) + header, err := f.apiBackend.HeaderByNumber(ctx, rpc.BlockNumber(i)) if header == nil || err != nil { return logs, err } // Use bloom filtering to see if this block is interesting given the // current parameters - if self.bloomFilter(header.Bloom) { + if f.bloomFilter(header.Bloom) { // Get the logs of the block - receipts, err := self.apiBackend.GetReceipts(ctx, header.Hash()) + receipts, err := f.apiBackend.GetReceipts(ctx, header.Hash()) if err != nil { return nil, err } - var unfiltered vm.Logs + var unfiltered []Log for _, receipt := range receipts { - unfiltered = append(unfiltered, receipt.Logs...) + rl := make([]Log, len(receipt.Logs)) + for i, l := range receipt.Logs { + rl[i] = Log{l, false} + } + unfiltered = append(unfiltered, rl...) } - logs = append(logs, self.FilterLogs(unfiltered)...) + logs = append(logs, filterLogs(unfiltered, f.addresses, f.topics)...) } } @@ -167,26 +167,25 @@ func includes(addresses []common.Address, a common.Address) bool { return false } -func (self *Filter) FilterLogs(logs vm.Logs) vm.Logs { - var ret vm.Logs +func filterLogs(logs []Log, addresses []common.Address, topics [][]common.Hash) []Log { + var ret []Log // Filter the logs for interesting stuff Logs: for _, log := range logs { - if len(self.addresses) > 0 && !includes(self.addresses, log.Address) { + if len(addresses) > 0 && !includes(addresses, log.Address) { continue } - logTopics := make([]common.Hash, len(self.topics)) + logTopics := make([]common.Hash, len(topics)) copy(logTopics, log.Topics) - // If the to filtered topics is greater than the amount of topics in - // logs, skip. - if len(self.topics) > len(log.Topics) { + // If the to filtered topics is greater than the amount of topics in logs, skip. + if len(topics) > len(log.Topics) { continue Logs } - for i, topics := range self.topics { + for i, topics := range topics { var match bool for _, topic := range topics { // common.Hash{} is a match all (wildcard) @@ -199,7 +198,6 @@ Logs: if !match { continue Logs } - } ret = append(ret, log) @@ -208,10 +206,10 @@ Logs: return ret } -func (self *Filter) bloomFilter(bloom types.Bloom) bool { - if len(self.addresses) > 0 { +func (f *Filter) bloomFilter(bloom types.Bloom) bool { + if len(f.addresses) > 0 { var included bool - for _, addr := range self.addresses { + for _, addr := range f.addresses { if types.BloomLookup(bloom, addr) { included = true break @@ -223,7 +221,7 @@ func (self *Filter) bloomFilter(bloom types.Bloom) bool { } } - for _, sub := range self.topics { + for _, sub := range f.topics { var included bool for _, topic := range sub { if (topic == common.Hash{}) || types.BloomLookup(bloom, topic) { diff --git a/vendor/github.com/ethereum/go-ethereum/eth/filters/filter_system.go b/vendor/github.com/ethereum/go-ethereum/eth/filters/filter_system.go new file mode 100644 index 000000000..04a55fd09 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/eth/filters/filter_system.go @@ -0,0 +1,318 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +// Package filters implements an ethereum filtering system for block, +// transactions and log events. +package filters + +import ( + "encoding/json" + "errors" + "fmt" + "sync" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/rpc" +) + +// Type determines the kind of filter and is used to put the filter in to +// the correct bucket when added. +type Type byte + +const ( + // UnknownSubscription indicates an unkown subscription type + UnknownSubscription Type = iota + // LogsSubscription queries for new or removed (chain reorg) logs + LogsSubscription + // PendingLogsSubscription queries for logs for the pending block + PendingLogsSubscription + // PendingTransactionsSubscription queries tx hashes for pending + // transactions entering the pending state + PendingTransactionsSubscription + // BlocksSubscription queries hashes for blocks that are imported + BlocksSubscription +) + +var ( + ErrInvalidSubscriptionID = errors.New("invalid id") +) + +// Log is a helper that can hold additional information about vm.Log +// necessary for the RPC interface. +type Log struct { + *vm.Log + Removed bool `json:"removed"` +} + +func (l *Log) MarshalJSON() ([]byte, error) { + fields := map[string]interface{}{ + "address": l.Address, + "data": fmt.Sprintf("0x%x", l.Data), + "blockNumber": fmt.Sprintf("%#x", l.BlockNumber), + "logIndex": fmt.Sprintf("%#x", l.Index), + "blockHash": l.BlockHash, + "transactionHash": l.TxHash, + "transactionIndex": fmt.Sprintf("%#x", l.TxIndex), + "topics": l.Topics, + "removed": l.Removed, + } + + return json.Marshal(fields) +} + +type subscription struct { + id rpc.ID + typ Type + created time.Time + logsCrit FilterCriteria + logs chan []Log + hashes chan common.Hash + headers chan *types.Header + installed chan struct{} // closed when the filter is installed + err chan error // closed when the filter is uninstalled +} + +// EventSystem creates subscriptions, processes events and broadcasts them to the +// subscription which match the subscription criteria. +type EventSystem struct { + mux *event.TypeMux + sub event.Subscription + install chan *subscription // install filter for event notification + uninstall chan *subscription // remove filter for event notification +} + +// NewEventSystem creates a new manager that listens for event on the given mux, +// parses and filters them. It uses the all map to retrieve filter changes. The +// work loop holds its own index that is used to forward events to filters. +// +// The returned manager has a loop that needs to be stopped with the Stop function +// or by stopping the given mux. +func NewEventSystem(mux *event.TypeMux) *EventSystem { + m := &EventSystem{ + mux: mux, + install: make(chan *subscription), + uninstall: make(chan *subscription), + } + + go m.eventLoop() + + return m +} + +// Subscription is created when the client registers itself for a particular event. +type Subscription struct { + ID rpc.ID + f *subscription + es *EventSystem + unsubOnce sync.Once +} + +// Err returns a channel that is closed when unsubscribed. +func (sub *Subscription) Err() <-chan error { + return sub.f.err +} + +// Unsubscribe uninstalls the subscription from the event broadcast loop. +func (sub *Subscription) Unsubscribe() { + sub.unsubOnce.Do(func() { + uninstallLoop: + for { + // write uninstall request and consume logs/hashes. This prevents + // the eventLoop broadcast method to deadlock when writing to the + // filter event channel while the subscription loop is waiting for + // this method to return (and thus not reading these events). + select { + case sub.es.uninstall <- sub.f: + break uninstallLoop + case <-sub.f.logs: + case <-sub.f.hashes: + case <-sub.f.headers: + } + } + + // wait for filter to be uninstalled in work loop before returning + // this ensures that the manager won't use the event channel which + // will probably be closed by the client asap after this method returns. + <-sub.Err() + }) +} + +// subscribe installs the subscription in the event broadcast loop. +func (es *EventSystem) subscribe(sub *subscription) *Subscription { + es.install <- sub + <-sub.installed + return &Subscription{ID: sub.id, f: sub, es: es} +} + +// SubscribeLogs creates a subscription that will write all logs matching the +// given criteria to the given logs channel. +func (es *EventSystem) SubscribeLogs(crit FilterCriteria, logs chan []Log) *Subscription { + sub := &subscription{ + id: rpc.NewID(), + typ: LogsSubscription, + logsCrit: crit, + created: time.Now(), + logs: logs, + hashes: make(chan common.Hash), + headers: make(chan *types.Header), + installed: make(chan struct{}), + err: make(chan error), + } + + return es.subscribe(sub) +} + +// SubscribePendingLogs creates a subscription that will write pending logs matching the +// given criteria to the given channel. +func (es *EventSystem) SubscribePendingLogs(crit FilterCriteria, logs chan []Log) *Subscription { + sub := &subscription{ + id: rpc.NewID(), + typ: PendingLogsSubscription, + logsCrit: crit, + created: time.Now(), + logs: logs, + hashes: make(chan common.Hash), + headers: make(chan *types.Header), + installed: make(chan struct{}), + err: make(chan error), + } + + return es.subscribe(sub) +} + +// SubscribePendingTxEvents creates a sbuscription that writes transaction hashes for +// transactions that enter the transaction pool. +func (es *EventSystem) SubscribePendingTxEvents(hashes chan common.Hash) *Subscription { + sub := &subscription{ + id: rpc.NewID(), + typ: PendingTransactionsSubscription, + created: time.Now(), + logs: make(chan []Log), + hashes: hashes, + headers: make(chan *types.Header), + installed: make(chan struct{}), + err: make(chan error), + } + + return es.subscribe(sub) +} + +// SubscribeNewHeads creates a subscription that writes the header of a block that is +// imported in the chain. +func (es *EventSystem) SubscribeNewHeads(headers chan *types.Header) *Subscription { + sub := &subscription{ + id: rpc.NewID(), + typ: BlocksSubscription, + created: time.Now(), + logs: make(chan []Log), + hashes: make(chan common.Hash), + headers: headers, + installed: make(chan struct{}), + err: make(chan error), + } + + return es.subscribe(sub) +} + +type filterIndex map[Type]map[rpc.ID]*subscription + +// broadcast event to filters that match criteria. +func broadcast(filters filterIndex, ev *event.Event) { + if ev == nil { + return + } + + switch e := ev.Data.(type) { + case vm.Logs: + if len(e) > 0 { + for _, f := range filters[LogsSubscription] { + if ev.Time.After(f.created) { + if matchedLogs := filterLogs(convertLogs(e, false), f.logsCrit.Addresses, f.logsCrit.Topics); len(matchedLogs) > 0 { + f.logs <- matchedLogs + } + } + } + } + case core.RemovedLogsEvent: + for _, f := range filters[LogsSubscription] { + if ev.Time.After(f.created) { + if matchedLogs := filterLogs(convertLogs(e.Logs, true), f.logsCrit.Addresses, f.logsCrit.Topics); len(matchedLogs) > 0 { + f.logs <- matchedLogs + } + } + } + case core.PendingLogsEvent: + for _, f := range filters[PendingLogsSubscription] { + if ev.Time.After(f.created) { + if matchedLogs := filterLogs(convertLogs(e.Logs, false), f.logsCrit.Addresses, f.logsCrit.Topics); len(matchedLogs) > 0 { + f.logs <- matchedLogs + } + } + } + case core.TxPreEvent: + for _, f := range filters[PendingTransactionsSubscription] { + if ev.Time.After(f.created) { + f.hashes <- e.Tx.Hash() + } + } + case core.ChainEvent: + for _, f := range filters[BlocksSubscription] { + if ev.Time.After(f.created) { + f.headers <- e.Block.Header() + } + } + } +} + +// eventLoop (un)installs filters and processes mux events. +func (es *EventSystem) eventLoop() { + var ( + index = make(filterIndex) + sub = es.mux.Subscribe(core.PendingLogsEvent{}, core.RemovedLogsEvent{}, vm.Logs{}, core.TxPreEvent{}, core.ChainEvent{}) + ) + for { + select { + case ev, active := <-sub.Chan(): + if !active { // system stopped + return + } + broadcast(index, ev) + case f := <-es.install: + if _, found := index[f.typ]; !found { + index[f.typ] = make(map[rpc.ID]*subscription) + } + index[f.typ][f.id] = f + close(f.installed) + case f := <-es.uninstall: + delete(index[f.typ], f.id) + close(f.err) + } + } +} + +// convertLogs is a helper utility that converts vm.Logs to []filter.Log. +func convertLogs(in vm.Logs, removed bool) []Log { + logs := make([]Log, len(in)) + for i, l := range in { + logs[i] = Log{l, removed} + } + return logs +} diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/gasprice/gasprice.go b/vendor/github.com/ethereum/go-ethereum/eth/gasprice/gasprice.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/eth/gasprice/gasprice.go rename to vendor/github.com/ethereum/go-ethereum/eth/gasprice/gasprice.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/gasprice/lightprice.go b/vendor/github.com/ethereum/go-ethereum/eth/gasprice/lightprice.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/eth/gasprice/lightprice.go rename to vendor/github.com/ethereum/go-ethereum/eth/gasprice/lightprice.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/gpu_mining.go b/vendor/github.com/ethereum/go-ethereum/eth/gpu_mining.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/eth/gpu_mining.go rename to vendor/github.com/ethereum/go-ethereum/eth/gpu_mining.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/handler.go b/vendor/github.com/ethereum/go-ethereum/eth/handler.go similarity index 83% rename from src/vendor/github.com/ethereum/go-ethereum/eth/handler.go rename to vendor/github.com/ethereum/go-ethereum/eth/handler.go index cbc6dd228..751408788 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/handler.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/handler.go @@ -57,9 +57,6 @@ func errResp(code errCode, format string, v ...interface{}) error { return fmt.Errorf("%v - %v", code, fmt.Sprintf(format, v...)) } -type hashFetcherFn func(common.Hash) error -type blockFetcherFn func([]common.Hash) error - type ProtocolManager struct { networkId int @@ -279,9 +276,7 @@ func (pm *ProtocolManager) handle(p *peer) error { defer pm.removePeer(p.id) // Register the peer in the downloader. If the downloader considers it banned, we disconnect - if err := pm.downloader.RegisterPeer(p.id, p.version, p.Head(), - p.RequestHashes, p.RequestHashesFromNumber, p.RequestBlocks, p.RequestHeadersByHash, - p.RequestHeadersByNumber, p.RequestBodies, p.RequestReceipts, p.RequestNodeData); err != nil { + if err := pm.downloader.RegisterPeer(p.id, p.version, p.Head, p.RequestHeadersByHash, p.RequestHeadersByNumber, p.RequestBodies, p.RequestReceipts, p.RequestNodeData); err != nil { return err } // Propagate existing transactions. new transactions appearing @@ -299,6 +294,13 @@ func (pm *ProtocolManager) handle(p *peer) error { glog.V(logger.Warn).Infof("%v: timed out DAO fork-check, dropping", p) pm.removePeer(p.id) }) + // Make sure it's cleaned up if the peer dies off + defer func() { + if p.forkDrop != nil { + p.forkDrop.Stop() + p.forkDrop = nil + } + }() } // main loop. handle incoming messages. for { @@ -328,108 +330,8 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { // Status messages should never arrive after the handshake return errResp(ErrExtraStatusMsg, "uncontrolled status message") - case p.version < eth62 && msg.Code == GetBlockHashesMsg: - // Retrieve the number of hashes to return and from which origin hash - var request getBlockHashesData - if err := msg.Decode(&request); err != nil { - return errResp(ErrDecode, "%v: %v", msg, err) - } - if request.Amount > uint64(downloader.MaxHashFetch) { - request.Amount = uint64(downloader.MaxHashFetch) - } - // Retrieve the hashes from the block chain and return them - hashes := pm.blockchain.GetBlockHashesFromHash(request.Hash, request.Amount) - if len(hashes) == 0 { - glog.V(logger.Debug).Infof("invalid block hash %x", request.Hash.Bytes()[:4]) - } - return p.SendBlockHashes(hashes) - - case p.version < eth62 && msg.Code == GetBlockHashesFromNumberMsg: - // Retrieve and decode the number of hashes to return and from which origin number - var request getBlockHashesFromNumberData - if err := msg.Decode(&request); err != nil { - return errResp(ErrDecode, "%v: %v", msg, err) - } - if request.Amount > uint64(downloader.MaxHashFetch) { - request.Amount = uint64(downloader.MaxHashFetch) - } - // Calculate the last block that should be retrieved, and short circuit if unavailable - last := pm.blockchain.GetBlockByNumber(request.Number + request.Amount - 1) - if last == nil { - last = pm.blockchain.CurrentBlock() - request.Amount = last.NumberU64() - request.Number + 1 - } - if last.NumberU64() < request.Number { - return p.SendBlockHashes(nil) - } - // Retrieve the hashes from the last block backwards, reverse and return - hashes := []common.Hash{last.Hash()} - hashes = append(hashes, pm.blockchain.GetBlockHashesFromHash(last.Hash(), request.Amount-1)...) - - for i := 0; i < len(hashes)/2; i++ { - hashes[i], hashes[len(hashes)-1-i] = hashes[len(hashes)-1-i], hashes[i] - } - return p.SendBlockHashes(hashes) - - case p.version < eth62 && msg.Code == BlockHashesMsg: - // A batch of hashes arrived to one of our previous requests - var hashes []common.Hash - if err := msg.Decode(&hashes); err != nil { - break - } - // Deliver them all to the downloader for queuing - err := pm.downloader.DeliverHashes(p.id, hashes) - if err != nil { - glog.V(logger.Debug).Infoln(err) - } - - case p.version < eth62 && msg.Code == GetBlocksMsg: - // Decode the retrieval message - msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size)) - if _, err := msgStream.List(); err != nil { - return err - } - // Gather blocks until the fetch or network limits is reached - var ( - hash common.Hash - bytes common.StorageSize - blocks []*types.Block - ) - for len(blocks) < downloader.MaxBlockFetch && bytes < softResponseLimit { - //Retrieve the hash of the next block - err := msgStream.Decode(&hash) - if err == rlp.EOL { - break - } else if err != nil { - return errResp(ErrDecode, "msg %v: %v", msg, err) - } - // Retrieve the requested block, stopping if enough was found - if block := pm.blockchain.GetBlockByHash(hash); block != nil { - blocks = append(blocks, block) - bytes += block.Size() - } - } - return p.SendBlocks(blocks) - - case p.version < eth62 && msg.Code == BlocksMsg: - // Decode the arrived block message - var blocks []*types.Block - if err := msg.Decode(&blocks); err != nil { - glog.V(logger.Detail).Infoln("Decode error", err) - blocks = nil - } - // Update the receive timestamp of each block - for _, block := range blocks { - block.ReceivedAt = msg.ReceivedAt - block.ReceivedFrom = p - } - // Filter out any explicitly requested blocks, deliver the rest to the downloader - if blocks := pm.fetcher.FilterBlocks(blocks); len(blocks) > 0 { - pm.downloader.DeliverBlocks(p.id, blocks) - } - // Block header query, collect the requested headers and reply - case p.version >= eth62 && msg.Code == GetBlockHeadersMsg: + case msg.Code == GetBlockHeadersMsg: // Decode the complex header query var query getBlockHeadersData if err := msg.Decode(&query); err != nil { @@ -497,7 +399,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { } return p.SendBlockHeaders(headers) - case p.version >= eth62 && msg.Code == BlockHeadersMsg: + case msg.Code == BlockHeadersMsg: // A batch of headers arrived to one of our previous requests var headers []*types.Header if err := msg.Decode(&headers); err != nil { @@ -511,7 +413,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { // If we already have a DAO header, we can check the peer's TD against it. If // the peer's ahead of this, it too must have a reply to the DAO check if daoHeader := pm.blockchain.GetHeaderByNumber(pm.chainconfig.DAOForkBlock.Uint64()); daoHeader != nil { - if p.Td().Cmp(pm.blockchain.GetTd(daoHeader.Hash(), daoHeader.Number.Uint64())) >= 0 { + if _, td := p.Head(); td.Cmp(pm.blockchain.GetTd(daoHeader.Hash(), daoHeader.Number.Uint64())) >= 0 { verifyDAO = false } } @@ -538,6 +440,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { return err } glog.V(logger.Debug).Infof("%v: verified to be on the same side of the DAO fork", p) + return nil } // Irrelevant of the fork checks, send the header to the fetcher just in case headers = pm.fetcher.FilterHeaders(headers, time.Now()) @@ -549,7 +452,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { } } - case p.version >= eth62 && msg.Code == GetBlockBodiesMsg: + case msg.Code == GetBlockBodiesMsg: // Decode the retrieval message msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size)) if _, err := msgStream.List(); err != nil { @@ -576,7 +479,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { } return p.SendBlockBodiesRLP(bodies) - case p.version >= eth62 && msg.Code == BlockBodiesMsg: + case msg.Code == BlockBodiesMsg: // A batch of block bodies arrived to one of our previous requests var request blockBodiesData if err := msg.Decode(&request); err != nil { @@ -717,7 +620,6 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { // Mark the hashes as present at the remote node for _, block := range announces { p.MarkBlock(block.Hash) - p.SetHead(block.Hash) } // Schedule all the unknown hashes for retrieval unknown := make([]announce, 0, len(announces)) @@ -727,11 +629,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { } } for _, block := range unknown { - if p.version < eth62 { - pm.fetcher.Notify(p.id, block.Hash, block.Number, time.Now(), p.RequestBlocks, nil, nil) - } else { - pm.fetcher.Notify(p.id, block.Hash, block.Number, time.Now(), nil, p.RequestOneHeader, p.RequestBodies) - } + pm.fetcher.Notify(p.id, block.Hash, block.Number, time.Now(), p.RequestOneHeader, p.RequestBodies) } case msg.Code == NewBlockMsg: @@ -748,16 +646,23 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { // Mark the peer as owning the block and schedule it for import p.MarkBlock(request.Block.Hash()) - p.SetHead(request.Block.Hash()) - pm.fetcher.Enqueue(p.id, request.Block) - // Update the peers total difficulty if needed, schedule a download if gapped - if request.TD.Cmp(p.Td()) > 0 { - p.SetTd(request.TD) + // Assuming the block is importable by the peer, but possibly not yet done so, + // calculate the head hash and TD that the peer truly must have. + var ( + trueHead = request.Block.ParentHash() + trueTD = new(big.Int).Sub(request.TD, request.Block.Difficulty()) + ) + // Update the peers total difficulty if better than the previous + if _, td := p.Head(); trueTD.Cmp(td) > 0 { + p.SetHead(trueHead, trueTD) + + // Schedule a sync if above ours. Note, this will not fire a sync for a gap of + // a singe block (as the true TD is below the propagated block), however this + // scenario should easily be covered by the fetcher. currentBlock := pm.blockchain.CurrentBlock() - td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()) - if request.TD.Cmp(new(big.Int).Add(td, request.Block.Difficulty())) > 0 { + if trueTD.Cmp(pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64())) > 0 { go pm.synchronise(p) } } @@ -813,11 +718,7 @@ func (pm *ProtocolManager) BroadcastBlock(block *types.Block, propagate bool) { // Otherwise if the block is indeed in out own chain, announce it if pm.blockchain.HasBlock(hash) { for _, peer := range peers { - if peer.version < eth62 { - peer.SendNewBlockHashes61([]common.Hash{hash}) - } else { - peer.SendNewBlockHashes([]common.Hash{hash}, []uint64{block.NumberU64()}) - } + peer.SendNewBlockHashes([]common.Hash{hash}, []uint64{block.NumberU64()}) } glog.V(logger.Detail).Infof("announced block %x to %d peers in %v", hash[:4], len(peers), time.Since(block.ReceivedAt)) } diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/metrics.go b/vendor/github.com/ethereum/go-ethereum/eth/metrics.go similarity index 82% rename from src/vendor/github.com/ethereum/go-ethereum/eth/metrics.go rename to vendor/github.com/ethereum/go-ethereum/eth/metrics.go index e1a89d3a9..5fa2597d4 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/metrics.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/metrics.go @@ -34,14 +34,6 @@ var ( propBlockInTrafficMeter = metrics.NewMeter("eth/prop/blocks/in/traffic") propBlockOutPacketsMeter = metrics.NewMeter("eth/prop/blocks/out/packets") propBlockOutTrafficMeter = metrics.NewMeter("eth/prop/blocks/out/traffic") - reqHashInPacketsMeter = metrics.NewMeter("eth/req/hashes/in/packets") - reqHashInTrafficMeter = metrics.NewMeter("eth/req/hashes/in/traffic") - reqHashOutPacketsMeter = metrics.NewMeter("eth/req/hashes/out/packets") - reqHashOutTrafficMeter = metrics.NewMeter("eth/req/hashes/out/traffic") - reqBlockInPacketsMeter = metrics.NewMeter("eth/req/blocks/in/packets") - reqBlockInTrafficMeter = metrics.NewMeter("eth/req/blocks/in/traffic") - reqBlockOutPacketsMeter = metrics.NewMeter("eth/req/blocks/out/packets") - reqBlockOutTrafficMeter = metrics.NewMeter("eth/req/blocks/out/traffic") reqHeaderInPacketsMeter = metrics.NewMeter("eth/req/headers/in/packets") reqHeaderInTrafficMeter = metrics.NewMeter("eth/req/headers/in/traffic") reqHeaderOutPacketsMeter = metrics.NewMeter("eth/req/headers/out/packets") @@ -95,14 +87,9 @@ func (rw *meteredMsgReadWriter) ReadMsg() (p2p.Msg, error) { // Account for the data traffic packets, traffic := miscInPacketsMeter, miscInTrafficMeter switch { - case rw.version < eth62 && msg.Code == BlockHashesMsg: - packets, traffic = reqHashInPacketsMeter, reqHashInTrafficMeter - case rw.version < eth62 && msg.Code == BlocksMsg: - packets, traffic = reqBlockInPacketsMeter, reqBlockInTrafficMeter - - case rw.version >= eth62 && msg.Code == BlockHeadersMsg: + case msg.Code == BlockHeadersMsg: packets, traffic = reqHeaderInPacketsMeter, reqHeaderInTrafficMeter - case rw.version >= eth62 && msg.Code == BlockBodiesMsg: + case msg.Code == BlockBodiesMsg: packets, traffic = reqBodyInPacketsMeter, reqBodyInTrafficMeter case rw.version >= eth63 && msg.Code == NodeDataMsg: @@ -127,14 +114,9 @@ func (rw *meteredMsgReadWriter) WriteMsg(msg p2p.Msg) error { // Account for the data traffic packets, traffic := miscOutPacketsMeter, miscOutTrafficMeter switch { - case rw.version < eth62 && msg.Code == BlockHashesMsg: - packets, traffic = reqHashOutPacketsMeter, reqHashOutTrafficMeter - case rw.version < eth62 && msg.Code == BlocksMsg: - packets, traffic = reqBlockOutPacketsMeter, reqBlockOutTrafficMeter - - case rw.version >= eth62 && msg.Code == BlockHeadersMsg: + case msg.Code == BlockHeadersMsg: packets, traffic = reqHeaderOutPacketsMeter, reqHeaderOutTrafficMeter - case rw.version >= eth62 && msg.Code == BlockBodiesMsg: + case msg.Code == BlockBodiesMsg: packets, traffic = reqBodyOutPacketsMeter, reqBodyOutTrafficMeter case rw.version >= eth63 && msg.Code == NodeDataMsg: diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/peer.go b/vendor/github.com/ethereum/go-ethereum/eth/peer.go similarity index 84% rename from src/vendor/github.com/ethereum/go-ethereum/eth/peer.go rename to vendor/github.com/ethereum/go-ethereum/eth/peer.go index b97825c69..aa85631ea 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/peer.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/peer.go @@ -25,7 +25,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/p2p" @@ -85,43 +84,31 @@ func newPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter) *peer { // Info gathers and returns a collection of metadata known about a peer. func (p *peer) Info() *PeerInfo { + hash, td := p.Head() + return &PeerInfo{ Version: p.version, - Difficulty: p.Td(), - Head: fmt.Sprintf("%x", p.Head()), + Difficulty: td, + Head: hash.Hex(), } } -// Head retrieves a copy of the current head (most recent) hash of the peer. -func (p *peer) Head() (hash common.Hash) { +// Head retrieves a copy of the current head hash and total difficulty of the +// peer. +func (p *peer) Head() (hash common.Hash, td *big.Int) { p.lock.RLock() defer p.lock.RUnlock() copy(hash[:], p.head[:]) - return hash + return hash, new(big.Int).Set(p.td) } -// SetHead updates the head (most recent) hash of the peer. -func (p *peer) SetHead(hash common.Hash) { +// SetHead updates the head hash and total difficulty of the peer. +func (p *peer) SetHead(hash common.Hash, td *big.Int) { p.lock.Lock() defer p.lock.Unlock() copy(p.head[:], hash[:]) -} - -// Td retrieves the current total difficulty of a peer. -func (p *peer) Td() *big.Int { - p.lock.RLock() - defer p.lock.RUnlock() - - return new(big.Int).Set(p.td) -} - -// SetTd updates the current total difficulty of a peer. -func (p *peer) SetTd(td *big.Int) { - p.lock.Lock() - defer p.lock.Unlock() - p.td.Set(td) } @@ -154,25 +141,6 @@ func (p *peer) SendTransactions(txs types.Transactions) error { return p2p.Send(p.rw, TxMsg, txs) } -// SendBlockHashes sends a batch of known hashes to the remote peer. -func (p *peer) SendBlockHashes(hashes []common.Hash) error { - return p2p.Send(p.rw, BlockHashesMsg, hashes) -} - -// SendBlocks sends a batch of blocks to the remote peer. -func (p *peer) SendBlocks(blocks []*types.Block) error { - return p2p.Send(p.rw, BlocksMsg, blocks) -} - -// SendNewBlockHashes61 announces the availability of a number of blocks through -// a hash notification. -func (p *peer) SendNewBlockHashes61(hashes []common.Hash) error { - for _, hash := range hashes { - p.knownBlocks.Add(hash) - } - return p2p.Send(p.rw, NewBlockHashesMsg, hashes) -} - // SendNewBlockHashes announces the availability of a number of blocks through // a hash notification. func (p *peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error { @@ -221,26 +189,6 @@ func (p *peer) SendReceiptsRLP(receipts []rlp.RawValue) error { return p2p.Send(p.rw, ReceiptsMsg, receipts) } -// RequestHashes fetches a batch of hashes from a peer, starting at from, going -// towards the genesis block. -func (p *peer) RequestHashes(from common.Hash) error { - glog.V(logger.Debug).Infof("%v fetching hashes (%d) from %x...", p, downloader.MaxHashFetch, from[:4]) - return p2p.Send(p.rw, GetBlockHashesMsg, getBlockHashesData{from, uint64(downloader.MaxHashFetch)}) -} - -// RequestHashesFromNumber fetches a batch of hashes from a peer, starting at -// the requested block number, going upwards towards the genesis block. -func (p *peer) RequestHashesFromNumber(from uint64, count int) error { - glog.V(logger.Debug).Infof("%v fetching hashes (%d) from #%d...", p, count, from) - return p2p.Send(p.rw, GetBlockHashesFromNumberMsg, getBlockHashesFromNumberData{from, uint64(count)}) -} - -// RequestBlocks fetches a batch of blocks corresponding to the specified hashes. -func (p *peer) RequestBlocks(hashes []common.Hash) error { - glog.V(logger.Debug).Infof("%v fetching %v blocks", p, len(hashes)) - return p2p.Send(p.rw, GetBlocksMsg, hashes) -} - // RequestHeaders is a wrapper around the header query functions to fetch a // single header. It is used solely by the fetcher. func (p *peer) RequestOneHeader(hash common.Hash) error { @@ -451,7 +399,7 @@ func (ps *peerSet) BestPeer() *peer { bestTd *big.Int ) for _, p := range ps.peers { - if td := p.Td(); bestPeer == nil || td.Cmp(bestTd) > 0 { + if _, td := p.Head(); bestPeer == nil || td.Cmp(bestTd) > 0 { bestPeer, bestTd = p, td } } diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/protocol.go b/vendor/github.com/ethereum/go-ethereum/eth/protocol.go similarity index 79% rename from src/vendor/github.com/ethereum/go-ethereum/eth/protocol.go rename to vendor/github.com/ethereum/go-ethereum/eth/protocol.go index 7de0cb020..69b3be578 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/protocol.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/protocol.go @@ -28,7 +28,6 @@ import ( // Constants to match up protocol versions and messages const ( - eth61 = 61 eth62 = 62 eth63 = 63 ) @@ -49,26 +48,15 @@ const ( // eth protocol message codes const ( - // Protocol messages belonging to eth/61 - StatusMsg = 0x00 - NewBlockHashesMsg = 0x01 - TxMsg = 0x02 - GetBlockHashesMsg = 0x03 - BlockHashesMsg = 0x04 - GetBlocksMsg = 0x05 - BlocksMsg = 0x06 - NewBlockMsg = 0x07 - GetBlockHashesFromNumberMsg = 0x08 - - // Protocol messages belonging to eth/62 (new protocol from scratch) - // StatusMsg = 0x00 (uncomment after eth/61 deprecation) - // NewBlockHashesMsg = 0x01 (uncomment after eth/61 deprecation) - // TxMsg = 0x02 (uncomment after eth/61 deprecation) + // Protocol messages belonging to eth/62 + StatusMsg = 0x00 + NewBlockHashesMsg = 0x01 + TxMsg = 0x02 GetBlockHeadersMsg = 0x03 BlockHeadersMsg = 0x04 GetBlockBodiesMsg = 0x05 BlockBodiesMsg = 0x06 - // NewBlockMsg = 0x07 (uncomment after eth/61 deprecation) + NewBlockMsg = 0x07 // Protocol messages belonging to eth/63 GetNodeDataMsg = 0x0d @@ -117,12 +105,6 @@ type txPool interface { GetTransactions() types.Transactions } -type chainManager interface { - GetBlockHashesFromHash(hash common.Hash, amount uint64) (hashes []common.Hash) - GetBlock(hash common.Hash) (block *types.Block) - Status() (td *big.Int, currentBlock common.Hash, genesisBlock common.Hash) -} - // statusData is the network packet for the status message. type statusData struct { ProtocolVersion uint32 @@ -138,19 +120,6 @@ type newBlockHashesData []struct { Number uint64 // Number of one particular block being announced } -// getBlockHashesData is the network packet for the hash based hash retrieval. -type getBlockHashesData struct { - Hash common.Hash - Amount uint64 -} - -// getBlockHashesFromNumberData is the network packet for the number based hash -// retrieval. -type getBlockHashesFromNumberData struct { - Number uint64 - Amount uint64 -} - // getBlockHeadersData represents a block header query. type getBlockHeadersData struct { Origin hashOrNumber // Block from which to retrieve headers @@ -209,8 +178,3 @@ type blockBody struct { // blockBodiesData is the network packet for block content distribution. type blockBodiesData []*blockBody - -// nodeDataData is the network response packet for a node data retrieval. -type nodeDataData []struct { - Value []byte -} diff --git a/src/vendor/github.com/ethereum/go-ethereum/eth/sync.go b/vendor/github.com/ethereum/go-ethereum/eth/sync.go similarity index 96% rename from src/vendor/github.com/ethereum/go-ethereum/eth/sync.go rename to vendor/github.com/ethereum/go-ethereum/eth/sync.go index 23cf18c8d..e1946edda 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/eth/sync.go +++ b/vendor/github.com/ethereum/go-ethereum/eth/sync.go @@ -161,10 +161,12 @@ func (pm *ProtocolManager) synchronise(peer *peer) { if peer == nil { return } - // Make sure the peer's TD is higher than our own. If not drop. + // Make sure the peer's TD is higher than our own currentBlock := pm.blockchain.CurrentBlock() td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()) - if peer.Td().Cmp(td) <= 0 { + + pHead, pTd := peer.Head() + if pTd.Cmp(td) <= 0 { return } // Otherwise try to sync with the downloader @@ -172,7 +174,7 @@ func (pm *ProtocolManager) synchronise(peer *peer) { if atomic.LoadUint32(&pm.fastSync) == 1 { mode = downloader.FastSync } - if err := pm.downloader.Synchronise(peer.id, peer.Head(), peer.Td(), mode); err != nil { + if err := pm.downloader.Synchronise(peer.id, pHead, pTd, mode); err != nil { return } atomic.StoreUint32(&pm.synced, 1) // Mark initial sync done diff --git a/src/vendor/github.com/ethereum/go-ethereum/ethdb/database.go b/vendor/github.com/ethereum/go-ethereum/ethdb/database.go similarity index 99% rename from src/vendor/github.com/ethereum/go-ethereum/ethdb/database.go rename to vendor/github.com/ethereum/go-ethereum/ethdb/database.go index a8c02b731..a12ec4ceb 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/ethdb/database.go +++ b/vendor/github.com/ethereum/go-ethereum/ethdb/database.go @@ -39,7 +39,6 @@ var OpenFileLimit = 64 // cacheRatio specifies how the total allotted cache is distributed between the // various system databases. var cacheRatio = map[string]float64{ - "dapp": 0.0, "chaindata": 1.0, "lightchaindata": 1.0, } @@ -47,7 +46,6 @@ var cacheRatio = map[string]float64{ // handleRatio specifies how the total allotted file descriptors is distributed // between the various system databases. var handleRatio = map[string]float64{ - "dapp": 0.0, "chaindata": 1.0, "lightchaindata": 1.0, } diff --git a/src/vendor/github.com/ethereum/go-ethereum/ethdb/interface.go b/vendor/github.com/ethereum/go-ethereum/ethdb/interface.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/ethdb/interface.go rename to vendor/github.com/ethereum/go-ethereum/ethdb/interface.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/ethdb/memory_database.go b/vendor/github.com/ethereum/go-ethereum/ethdb/memory_database.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/ethdb/memory_database.go rename to vendor/github.com/ethereum/go-ethereum/ethdb/memory_database.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/event/event.go b/vendor/github.com/ethereum/go-ethereum/event/event.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/event/event.go rename to vendor/github.com/ethereum/go-ethereum/event/event.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/event/filter/filter.go b/vendor/github.com/ethereum/go-ethereum/event/filter/filter.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/event/filter/filter.go rename to vendor/github.com/ethereum/go-ethereum/event/filter/filter.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/event/filter/generic_filter.go b/vendor/github.com/ethereum/go-ethereum/event/filter/generic_filter.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/event/filter/generic_filter.go rename to vendor/github.com/ethereum/go-ethereum/event/filter/generic_filter.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/generators/defaults.go b/vendor/github.com/ethereum/go-ethereum/generators/defaults.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/generators/defaults.go rename to vendor/github.com/ethereum/go-ethereum/generators/defaults.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/debug/api.go b/vendor/github.com/ethereum/go-ethereum/internal/debug/api.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/internal/debug/api.go rename to vendor/github.com/ethereum/go-ethereum/internal/debug/api.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/debug/flags.go b/vendor/github.com/ethereum/go-ethereum/internal/debug/flags.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/internal/debug/flags.go rename to vendor/github.com/ethereum/go-ethereum/internal/debug/flags.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/debug/loudpanic.go b/vendor/github.com/ethereum/go-ethereum/internal/debug/loudpanic.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/internal/debug/loudpanic.go rename to vendor/github.com/ethereum/go-ethereum/internal/debug/loudpanic.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/debug/loudpanic_fallback.go b/vendor/github.com/ethereum/go-ethereum/internal/debug/loudpanic_fallback.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/internal/debug/loudpanic_fallback.go rename to vendor/github.com/ethereum/go-ethereum/internal/debug/loudpanic_fallback.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/debug/trace.go b/vendor/github.com/ethereum/go-ethereum/internal/debug/trace.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/internal/debug/trace.go rename to vendor/github.com/ethereum/go-ethereum/internal/debug/trace.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/debug/trace_fallback.go b/vendor/github.com/ethereum/go-ethereum/internal/debug/trace_fallback.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/internal/debug/trace_fallback.go rename to vendor/github.com/ethereum/go-ethereum/internal/debug/trace_fallback.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/ethapi/api.go b/vendor/github.com/ethereum/go-ethereum/internal/ethapi/api.go similarity index 88% rename from src/vendor/github.com/ethereum/go-ethereum/internal/ethapi/api.go rename to vendor/github.com/ethereum/go-ethereum/internal/ethapi/api.go index e6a429129..5a6a4d697 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/internal/ethapi/api.go +++ b/vendor/github.com/ethereum/go-ethereum/internal/ethapi/api.go @@ -30,7 +30,6 @@ import ( "github.com/ethereum/ethash" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/compiler" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -52,14 +51,12 @@ const defaultGas = uint64(90000) // PublicEthereumAPI provides an API to access Ethereum related information. // It offers only methods that operate on public data that is freely available to anyone. type PublicEthereumAPI struct { - b Backend - solcPath *string - solc **compiler.Solidity + b Backend } // NewPublicEthereumAPI creates a new Etheruem protocol API. -func NewPublicEthereumAPI(b Backend, solcPath *string, solc **compiler.Solidity) *PublicEthereumAPI { - return &PublicEthereumAPI{b, solcPath, solc} +func NewPublicEthereumAPI(b Backend) *PublicEthereumAPI { + return &PublicEthereumAPI{b} } // GasPrice returns a suggestion for a gas price. @@ -67,39 +64,6 @@ func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*big.Int, error) { return s.b.SuggestPrice(ctx) } -func (s *PublicEthereumAPI) getSolc() (*compiler.Solidity, error) { - var err error - solc := *s.solc - if solc == nil { - solc, err = compiler.New(*s.solcPath) - } - return solc, err -} - -// GetCompilers returns the collection of available smart contract compilers -func (s *PublicEthereumAPI) GetCompilers() ([]string, error) { - solc, err := s.getSolc() - if err == nil && solc != nil { - return []string{"Solidity"}, nil - } - - return []string{}, nil -} - -// CompileSolidity compiles the given solidity source -func (s *PublicEthereumAPI) CompileSolidity(source string) (map[string]*compiler.Contract, error) { - solc, err := s.getSolc() - if err != nil { - return nil, err - } - - if solc == nil { - return nil, errors.New("solc (solidity compiler) not found") - } - - return solc.Compile(source) -} - // ProtocolVersion returns the current Ethereum protocol version this node supports func (s *PublicEthereumAPI) ProtocolVersion() *rpc.HexNumber { return rpc.NewHexNumber(s.b.ProtocolVersion()) @@ -305,10 +269,10 @@ func (s *PrivateAccountAPI) LockAccount(addr common.Address) bool { return s.am.Lock(addr) == nil } -// SignAndSendTransaction will create a transaction from the given arguments and +// SendTransaction will create a transaction from the given arguments and // tries to sign it with the key associated with args.To. If the given passwd isn't // able to decrypt the key it fails. -func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error) { +func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error) { var err error args, err = prepareSendTxArgs(ctx, args, s.b) if err != nil { @@ -338,40 +302,21 @@ func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args Sen return submitTransaction(ctx, s.b, tx, signature) } +// SignAndSendTransaction was renamed to SendTransaction. This method is deprecated +// and will be removed in the future. It primary goal is to give clients time to update. +func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error) { + return s.SendTransaction(ctx, args, passwd) +} + // PublicBlockChainAPI provides an API to access the Ethereum blockchain. // It offers only methods that operate on public data that is freely available to anyone. type PublicBlockChainAPI struct { - b Backend - muNewBlockSubscriptions sync.Mutex // protects newBlocksSubscriptions - newBlockSubscriptions map[string]func(core.ChainEvent) error // callbacks for new block subscriptions + b Backend } // NewPublicBlockChainAPI creates a new Etheruem blockchain API. func NewPublicBlockChainAPI(b Backend) *PublicBlockChainAPI { - api := &PublicBlockChainAPI{ - b: b, - newBlockSubscriptions: make(map[string]func(core.ChainEvent) error), - } - - go api.subscriptionLoop() - - return api -} - -// subscriptionLoop reads events from the global event mux and creates notifications for the matched subscriptions. -func (s *PublicBlockChainAPI) subscriptionLoop() { - sub := s.b.EventMux().Subscribe(core.ChainEvent{}) - for event := range sub.Chan() { - if chainEvent, ok := event.Data.(core.ChainEvent); ok { - s.muNewBlockSubscriptions.Lock() - for id, notifyOf := range s.newBlockSubscriptions { - if notifyOf(chainEvent) == rpc.ErrNotificationNotFound { - delete(s.newBlockSubscriptions, id) - } - } - s.muNewBlockSubscriptions.Unlock() - } - } + return &PublicBlockChainAPI{b} } // BlockNumber returns the block number of the chain head. @@ -467,45 +412,6 @@ func (s *PublicBlockChainAPI) GetUncleCountByBlockHash(ctx context.Context, bloc return nil } -// NewBlocksArgs allows the user to specify if the returned block should include transactions and in which format. -type NewBlocksArgs struct { - IncludeTransactions bool `json:"includeTransactions"` - TransactionDetails bool `json:"transactionDetails"` -} - -// NewBlocks triggers a new block event each time a block is appended to the chain. It accepts an argument which allows -// the caller to specify whether the output should contain transactions and in what format. -func (s *PublicBlockChainAPI) NewBlocks(ctx context.Context, args NewBlocksArgs) (rpc.Subscription, error) { - notifier, supported := rpc.NotifierFromContext(ctx) - if !supported { - return nil, rpc.ErrNotificationsUnsupported - } - - // create a subscription that will remove itself when unsubscribed/cancelled - subscription, err := notifier.NewSubscription(func(subId string) { - s.muNewBlockSubscriptions.Lock() - delete(s.newBlockSubscriptions, subId) - s.muNewBlockSubscriptions.Unlock() - }) - - if err != nil { - return nil, err - } - - // add a callback that is called on chain events which will format the block and notify the client - s.muNewBlockSubscriptions.Lock() - s.newBlockSubscriptions[subscription.ID()] = func(e core.ChainEvent) error { - notification, err := s.rpcOutputBlock(e.Block, args.IncludeTransactions, args.TransactionDetails) - if err == nil { - return subscription.Notify(notification) - } - glog.V(logger.Warn).Info("unable to format block %v\n", err) - return nil - } - s.muNewBlockSubscriptions.Unlock() - return subscription, nil -} - // GetCode returns the code stored at the given address in the state for the given block number. func (s *PublicBlockChainAPI) GetCode(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (string, error) { state, _, err := s.b.StateAndHeaderByNumber(ctx, blockNr) @@ -864,10 +770,8 @@ func newRPCTransaction(b *types.Block, txHash common.Hash) (*RPCTransaction, err // PublicTransactionPoolAPI exposes methods for the RPC interface type PublicTransactionPoolAPI struct { - b Backend - muPendingTxSubs sync.Mutex - pendingTxSubs map[string]rpc.Subscription - txQueue chan *status.QueuedTx + b Backend + txQueue chan *status.QueuedTx } var txSingletonQueue chan *status.QueuedTx @@ -882,33 +786,9 @@ func NewPublicTransactionPoolAPI(b Backend) *PublicTransactionPoolAPI { } }) - api := &PublicTransactionPoolAPI{ - b: b, - pendingTxSubs: make(map[string]rpc.Subscription), - txQueue: txSingletonQueue, - } - - go api.subscriptionLoop() - - return api -} - -// subscriptionLoop listens for events on the global event mux and creates notifications for subscriptions. -func (s *PublicTransactionPoolAPI) subscriptionLoop() { - sub := s.b.EventMux().Subscribe(core.TxPreEvent{}) - for event := range sub.Chan() { - tx := event.Data.(core.TxPreEvent) - if from, err := tx.Tx.FromFrontier(); err == nil { - if s.b.AccountManager().HasAddress(from) { - s.muPendingTxSubs.Lock() - for id, sub := range s.pendingTxSubs { - if sub.Notify(tx.Tx.Hash()) == rpc.ErrNotificationNotFound { - delete(s.pendingTxSubs, id) - } - } - s.muPendingTxSubs.Unlock() - } - } + return &PublicTransactionPoolAPI{ + b: b, + txQueue: txSingletonQueue, } } @@ -1399,31 +1279,6 @@ func (s *PublicTransactionPoolAPI) PendingTransactions() []*RPCTransaction { return transactions } -// NewPendingTransactions creates a subscription that is triggered each time a transaction enters the transaction pool -// and is send from one of the transactions this nodes manages. -func (s *PublicTransactionPoolAPI) NewPendingTransactions(ctx context.Context) (rpc.Subscription, error) { - notifier, supported := rpc.NotifierFromContext(ctx) - if !supported { - return nil, rpc.ErrNotificationsUnsupported - } - - subscription, err := notifier.NewSubscription(func(id string) { - s.muPendingTxSubs.Lock() - delete(s.pendingTxSubs, id) - s.muPendingTxSubs.Unlock() - }) - - if err != nil { - return nil, err - } - - s.muPendingTxSubs.Lock() - s.pendingTxSubs[subscription.ID()] = subscription - s.muPendingTxSubs.Unlock() - - return subscription, nil -} - // Resend accepts an existing transaction and a new gas price and limit. It will remove the given transaction from the // pool and reinsert it with the new gas price and limit. func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, tx *Tx, gasPrice, gasLimit *rpc.HexNumber) (common.Hash, error) { @@ -1462,31 +1317,6 @@ func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, tx *Tx, gasPrice, return common.Hash{}, fmt.Errorf("Transaction %#x not found", tx.Hash) } -// PrivateAdminAPI is the collection of Etheruem APIs exposed over the private -// admin endpoint. -type PrivateAdminAPI struct { - b Backend - solcPath *string - solc **compiler.Solidity -} - -// NewPrivateAdminAPI creates a new API definition for the private admin methods -// of the Ethereum service. -func NewPrivateAdminAPI(b Backend, solcPath *string, solc **compiler.Solidity) *PrivateAdminAPI { - return &PrivateAdminAPI{b, solcPath, solc} -} - -// SetSolc sets the Solidity compiler path to be used by the node. -func (api *PrivateAdminAPI) SetSolc(path string) (string, error) { - var err error - *api.solcPath = path - *api.solc, err = compiler.New(path) - if err != nil { - return "", err - } - return (*api.solc).Info(), nil -} - // PublicDebugAPI is the collection of Etheruem APIs exposed over the public // debugging endpoint. type PublicDebugAPI struct { diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/ethapi/backend.go b/vendor/github.com/ethereum/go-ethereum/internal/ethapi/backend.go similarity index 92% rename from src/vendor/github.com/ethereum/go-ethereum/internal/ethapi/backend.go rename to vendor/github.com/ethereum/go-ethereum/internal/ethapi/backend.go index 6060b7a32..8427b3e03 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/internal/ethapi/backend.go +++ b/vendor/github.com/ethereum/go-ethereum/internal/ethapi/backend.go @@ -22,7 +22,6 @@ import ( "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/compiler" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -69,12 +68,13 @@ type State interface { GetNonce(ctx context.Context, addr common.Address) (uint64, error) } -func GetAPIs(apiBackend Backend, solcPath *string, solc **compiler.Solidity) []rpc.API { - return []rpc.API{ +func GetAPIs(apiBackend Backend, solcPath string) []rpc.API { + compiler := makeCompilerAPIs(solcPath) + all := []rpc.API{ { Namespace: "eth", Version: "1.0", - Service: NewPublicEthereumAPI(apiBackend, solcPath, solc), + Service: NewPublicEthereumAPI(apiBackend), Public: true, }, { Namespace: "eth", @@ -91,10 +91,6 @@ func GetAPIs(apiBackend Backend, solcPath *string, solc **compiler.Solidity) []r Version: "1.0", Service: NewPublicTxPoolAPI(apiBackend), Public: true, - }, { - Namespace: "admin", - Version: "1.0", - Service: NewPrivateAdminAPI(apiBackend, solcPath, solc), }, { Namespace: "debug", Version: "1.0", @@ -116,4 +112,5 @@ func GetAPIs(apiBackend Backend, solcPath *string, solc **compiler.Solidity) []r Public: false, }, } + return append(compiler, all...) } diff --git a/vendor/github.com/ethereum/go-ethereum/internal/ethapi/solc.go b/vendor/github.com/ethereum/go-ethereum/internal/ethapi/solc.go new file mode 100644 index 000000000..b9acc518b --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/internal/ethapi/solc.go @@ -0,0 +1,82 @@ +// Copyright 2016 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package ethapi + +import ( + "sync" + + "github.com/ethereum/go-ethereum/common/compiler" + "github.com/ethereum/go-ethereum/rpc" +) + +func makeCompilerAPIs(solcPath string) []rpc.API { + c := &compilerAPI{solc: solcPath} + return []rpc.API{ + { + Namespace: "eth", + Version: "1.0", + Service: (*PublicCompilerAPI)(c), + Public: true, + }, + { + Namespace: "admin", + Version: "1.0", + Service: (*CompilerAdminAPI)(c), + Public: true, + }, + } +} + +type compilerAPI struct { + // This lock guards the solc path set through the API. + // It also ensures that only one solc process is used at + // any time. + mu sync.Mutex + solc string +} + +type CompilerAdminAPI compilerAPI + +// SetSolc sets the Solidity compiler path to be used by the node. +func (api *CompilerAdminAPI) SetSolc(path string) (string, error) { + api.mu.Lock() + defer api.mu.Unlock() + info, err := compiler.SolidityVersion(path) + if err != nil { + return "", err + } + api.solc = path + return info.FullVersion, nil +} + +type PublicCompilerAPI compilerAPI + +// CompileSolidity compiles the given solidity source. +func (api *PublicCompilerAPI) CompileSolidity(source string) (map[string]*compiler.Contract, error) { + api.mu.Lock() + defer api.mu.Unlock() + return compiler.CompileSolidityString(api.solc, source) +} + +func (api *PublicCompilerAPI) GetCompilers() ([]string, error) { + api.mu.Lock() + defer api.mu.Unlock() + if _, err := compiler.SolidityVersion(api.solc); err == nil { + return []string{"Solidity"}, nil + } + return []string{}, nil +} diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/ethapi/status_backend.go b/vendor/github.com/ethereum/go-ethereum/internal/ethapi/status_backend.go similarity index 97% rename from src/vendor/github.com/ethereum/go-ethereum/internal/ethapi/status_backend.go rename to vendor/github.com/ethereum/go-ethereum/internal/ethapi/status_backend.go index 5632b48d8..2ad00d062 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/internal/ethapi/status_backend.go +++ b/vendor/github.com/ethereum/go-ethereum/internal/ethapi/status_backend.go @@ -22,7 +22,7 @@ type StatusBackend struct { func NewStatusBackend(apiBackend Backend) *StatusBackend { glog.V(logger.Info).Infof("Status backend service started") backend := &StatusBackend{ - eapi: NewPublicEthereumAPI(apiBackend, nil, nil), + eapi: NewPublicEthereumAPI(apiBackend), bcapi: NewPublicBlockChainAPI(apiBackend), txapi: NewPublicTransactionPoolAPI(apiBackend), txQueue: status.NewTransactionQueue(), diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/jsre/bignumber_js.go b/vendor/github.com/ethereum/go-ethereum/internal/jsre/bignumber_js.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/internal/jsre/bignumber_js.go rename to vendor/github.com/ethereum/go-ethereum/internal/jsre/bignumber_js.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/jsre/completion.go b/vendor/github.com/ethereum/go-ethereum/internal/jsre/completion.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/internal/jsre/completion.go rename to vendor/github.com/ethereum/go-ethereum/internal/jsre/completion.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/jsre/ethereum_js.go b/vendor/github.com/ethereum/go-ethereum/internal/jsre/ethereum_js.go similarity index 99% rename from src/vendor/github.com/ethereum/go-ethereum/internal/jsre/ethereum_js.go rename to vendor/github.com/ethereum/go-ethereum/internal/jsre/ethereum_js.go index 4ad76b2d6..daa19b6bd 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/internal/jsre/ethereum_js.go +++ b/vendor/github.com/ethereum/go-ethereum/internal/jsre/ethereum_js.go @@ -5651,9 +5651,9 @@ var methods = function () { }); var addIdentity = new Method({ - name: 'addIdentity', - call: 'shh_addIdentity', - params: 1 + name: 'addIdentity', + call: 'shh_addIdentity', + params: 1 }); var newGroup = new Method({ @@ -5673,7 +5673,7 @@ var methods = function () { newIdentity, hasIdentity, addIdentity, - newGroup, + newGroup, addToGroup ]; }; @@ -5784,7 +5784,7 @@ var shh = function () { }); return [ - newFilter, + newFilter, uninstallFilter, getLogs, poll diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/jsre/jsre.go b/vendor/github.com/ethereum/go-ethereum/internal/jsre/jsre.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/internal/jsre/jsre.go rename to vendor/github.com/ethereum/go-ethereum/internal/jsre/jsre.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/jsre/pretty.go b/vendor/github.com/ethereum/go-ethereum/internal/jsre/pretty.go similarity index 99% rename from src/vendor/github.com/ethereum/go-ethereum/internal/jsre/pretty.go rename to vendor/github.com/ethereum/go-ethereum/internal/jsre/pretty.go index 30d8660ff..f32e16243 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/internal/jsre/pretty.go +++ b/vendor/github.com/ethereum/go-ethereum/internal/jsre/pretty.go @@ -116,7 +116,7 @@ func (ctx ppctx) printValue(v otto.Value, level int, inArray bool) { func (ctx ppctx) printObject(obj *otto.Object, level int, inArray bool) { switch obj.Class() { - case "Array": + case "Array", "GoArray": lv, _ := obj.Get("length") len, _ := lv.ToInteger() if len == 0 { diff --git a/src/vendor/github.com/ethereum/go-ethereum/internal/web3ext/web3ext.go b/vendor/github.com/ethereum/go-ethereum/internal/web3ext/web3ext.go similarity index 98% rename from src/vendor/github.com/ethereum/go-ethereum/internal/web3ext/web3ext.go rename to vendor/github.com/ethereum/go-ethereum/internal/web3ext/web3ext.go index 162cf7096..e76e15177 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/internal/web3ext/web3ext.go +++ b/vendor/github.com/ethereum/go-ethereum/internal/web3ext/web3ext.go @@ -39,6 +39,11 @@ web3._extend({ call: 'admin_addPeer', params: 1 }), + new web3._extend.Method({ + name: 'removePeer', + call: 'admin_removePeer', + params: 1 + }), new web3._extend.Method({ name: 'exportChain', call: 'admin_exportChain', @@ -418,8 +423,8 @@ web3._extend({ params: 2 }), new web3._extend.Method({ - name: 'signAndSendTransaction', - call: 'personal_signAndSendTransaction', + name: 'sendTransaction', + call: 'personal_sendTransaction', params: 2, inputFormatter: [web3._extend.formatters.inputTransactionFormatter, null] }) diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/api_backend.go b/vendor/github.com/ethereum/go-ethereum/les/api_backend.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/api_backend.go rename to vendor/github.com/ethereum/go-ethereum/les/api_backend.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/backend.go b/vendor/github.com/ethereum/go-ethereum/les/backend.go similarity index 95% rename from src/vendor/github.com/ethereum/go-ethereum/les/backend.go rename to vendor/github.com/ethereum/go-ethereum/les/backend.go index 4ff21c8ca..efa938c0d 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/les/backend.go +++ b/vendor/github.com/ethereum/go-ethereum/les/backend.go @@ -54,7 +54,6 @@ type LightEthereum struct { protocolManager *ProtocolManager // DB interfaces chainDb ethdb.Database // Block chain database - dappDb ethdb.Database // Dapp database ApiBackend *LesApiBackend @@ -74,7 +73,7 @@ type LightEthereum struct { } func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) { - chainDb, dappDb, err := eth.CreateDBs(ctx, config, "lightchaindata") + chainDb, err := eth.CreateDB(ctx, config, "lightchaindata") if err != nil { return nil, err } @@ -92,9 +91,8 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) { odr: odr, relay: relay, chainDb: chainDb, - dappDb: dappDb, eventMux: ctx.EventMux, - accountManager: config.AccountManager, + accountManager: ctx.AccountManager, pow: pow, shutdownChan: make(chan bool), httpclient: httpclient.New(config.DocRoot), @@ -137,7 +135,7 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) { // APIs returns the collection of RPC services the ethereum package offers. // NOTE, some of these services probably need to be moved to somewhere else. func (s *LightEthereum) APIs() []rpc.API { - return append(ethapi.GetAPIs(s.ApiBackend, &s.solcPath, &s.solc), []rpc.API{ + return append(ethapi.GetAPIs(s.ApiBackend, s.solcPath), []rpc.API{ { Namespace: "eth", Version: "1.0", @@ -192,7 +190,6 @@ func (s *LightEthereum) Stop() error { time.Sleep(time.Millisecond * 200) s.chainDb.Close() - s.dappDb.Close() close(s.shutdownChan) return nil diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/fetcher.go b/vendor/github.com/ethereum/go-ethereum/les/fetcher.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/fetcher.go rename to vendor/github.com/ethereum/go-ethereum/les/fetcher.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/flowcontrol/control.go b/vendor/github.com/ethereum/go-ethereum/les/flowcontrol/control.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/flowcontrol/control.go rename to vendor/github.com/ethereum/go-ethereum/les/flowcontrol/control.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/flowcontrol/manager.go b/vendor/github.com/ethereum/go-ethereum/les/flowcontrol/manager.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/flowcontrol/manager.go rename to vendor/github.com/ethereum/go-ethereum/les/flowcontrol/manager.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/handler.go b/vendor/github.com/ethereum/go-ethereum/les/handler.go similarity index 99% rename from src/vendor/github.com/ethereum/go-ethereum/les/handler.go rename to vendor/github.com/ethereum/go-ethereum/les/handler.go index 300674f4d..ef64e25fb 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/les/handler.go +++ b/vendor/github.com/ethereum/go-ethereum/les/handler.go @@ -311,9 +311,8 @@ func (pm *ProtocolManager) handle(p *peer) error { p.fcServer.SendRequest(reqID, cost) return p.RequestHeadersByNumber(reqID, cost, origin, amount, skip, reverse) } - if err := pm.downloader.RegisterPeer(p.id, ethVersion, p.Head(), - nil, nil, nil, requestHeadersByHash, requestHeadersByNumber, - nil, nil, nil); err != nil { + if err := pm.downloader.RegisterPeer(p.id, ethVersion, p.HeadAndTd, + requestHeadersByHash, requestHeadersByNumber, nil, nil, nil); err != nil { return err } pm.odr.RegisterPeer(p) @@ -330,13 +329,13 @@ func (pm *ProtocolManager) handle(p *peer) error { // new block announce loop for { select { - case announce := <- p.newBlockHashChn: + case announce := <-p.newBlockHashChn: p.SendNewBlockHash(announce) //fmt.Println(" BROADCAST sent") case <-stop: return - } - } + } + } }() // main loop. handle incoming messages. diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/metrics.go b/vendor/github.com/ethereum/go-ethereum/les/metrics.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/metrics.go rename to vendor/github.com/ethereum/go-ethereum/les/metrics.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/odr.go b/vendor/github.com/ethereum/go-ethereum/les/odr.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/odr.go rename to vendor/github.com/ethereum/go-ethereum/les/odr.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/odr_peerset.go b/vendor/github.com/ethereum/go-ethereum/les/odr_peerset.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/odr_peerset.go rename to vendor/github.com/ethereum/go-ethereum/les/odr_peerset.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/odr_requests.go b/vendor/github.com/ethereum/go-ethereum/les/odr_requests.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/odr_requests.go rename to vendor/github.com/ethereum/go-ethereum/les/odr_requests.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/peer.go b/vendor/github.com/ethereum/go-ethereum/les/peer.go similarity index 97% rename from src/vendor/github.com/ethereum/go-ethereum/les/peer.go rename to vendor/github.com/ethereum/go-ethereum/les/peer.go index 2aadbb1f4..a191eeeff 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/les/peer.go +++ b/vendor/github.com/ethereum/go-ethereum/les/peer.go @@ -51,10 +51,9 @@ type peer struct { id string - firstHeadInfo, headInfo *newBlockHashData - headInfoLen int - lock sync.RWMutex + headInfoLen int + lock sync.RWMutex newBlockHashChn chan newBlockHashData @@ -68,11 +67,11 @@ func newPeer(version, network int, p *p2p.Peer, rw p2p.MsgReadWriter) *peer { id := p.ID() return &peer{ - Peer: p, - rw: rw, - version: version, - network: network, - id: fmt.Sprintf("%x", id[:8]), + Peer: p, + rw: rw, + version: version, + network: network, + id: fmt.Sprintf("%x", id[:8]), newBlockHashChn: make(chan newBlockHashData, 20), } } @@ -95,6 +94,14 @@ func (p *peer) Head() (hash common.Hash) { return hash } +func (p *peer) HeadAndTd() (hash common.Hash, td *big.Int) { + p.lock.RLock() + defer p.lock.RUnlock() + + copy(hash[:], p.headInfo.Hash[:]) + return hash, p.headInfo.Td +} + func (p *peer) headBlockInfo() blockInfo { p.lock.RLock() defer p.lock.RUnlock() @@ -141,7 +148,7 @@ func (p *peer) gotHeader(hash common.Hash, number uint64, td *big.Int) bool { h = h.next // propagate haveHeaders through the chain for h != nil { - hh := last.Number-h.ReorgDepth + hh := last.Number - h.ReorgDepth if last.haveHeaders < hh { hh = last.haveHeaders } diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/protocol.go b/vendor/github.com/ethereum/go-ethereum/les/protocol.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/protocol.go rename to vendor/github.com/ethereum/go-ethereum/les/protocol.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/server.go b/vendor/github.com/ethereum/go-ethereum/les/server.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/server.go rename to vendor/github.com/ethereum/go-ethereum/les/server.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/status/txqueue.go b/vendor/github.com/ethereum/go-ethereum/les/status/txqueue.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/status/txqueue.go rename to vendor/github.com/ethereum/go-ethereum/les/status/txqueue.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/sync.go b/vendor/github.com/ethereum/go-ethereum/les/sync.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/sync.go rename to vendor/github.com/ethereum/go-ethereum/les/sync.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/les/txrelay.go b/vendor/github.com/ethereum/go-ethereum/les/txrelay.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/les/txrelay.go rename to vendor/github.com/ethereum/go-ethereum/les/txrelay.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/light/lightchain.go b/vendor/github.com/ethereum/go-ethereum/light/lightchain.go similarity index 97% rename from src/vendor/github.com/ethereum/go-ethereum/light/lightchain.go rename to vendor/github.com/ethereum/go-ethereum/light/lightchain.go index 66b6d05df..8e45d54d3 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/light/lightchain.go +++ b/vendor/github.com/ethereum/go-ethereum/light/lightchain.go @@ -104,10 +104,17 @@ func NewLightChain(odr OdrBackend, config *core.ChainConfig, pow pow.PoW, mux *e if bc.genesisBlock.Hash() == (common.Hash{212, 229, 103, 64, 248, 118, 174, 248, 192, 16, 184, 106, 64, 213, 245, 103, 69, 161, 24, 208, 144, 106, 52, 230, 154, 236, 140, 13, 177, 203, 143, 163}) { // add trusted CHT - WriteTrustedCht(bc.chainDb, TrustedCht{ - Number: 459, - Root: common.HexToHash("9f14334360d1e48ed49a3d6b0b9e38a1706732cebc6a9c47bdde8d9824cd6d6b"), - }) + if config.DAOForkSupport { + WriteTrustedCht(bc.chainDb, TrustedCht{ + Number: 523, + Root: common.HexToHash("c9c3203ca7e58bf0ceaae50ed00c7ae234e7b3cc054aee086a1d0873f843df4e"), + }) + } else { + WriteTrustedCht(bc.chainDb, TrustedCht{ + Number: 523, + Root: common.HexToHash("c035076523faf514038f619715de404a65398c51899b5dccca9c05b00bc79315"), + }) + } glog.V(logger.Info).Infoln("Added trusted CHT for mainnet") } else { if bc.genesisBlock.Hash() == (common.Hash{12, 215, 134, 162, 66, 93, 22, 241, 82, 198, 88, 49, 108, 66, 62, 108, 225, 24, 30, 21, 195, 41, 88, 38, 215, 201, 144, 76, 186, 156, 227, 3}) { diff --git a/src/vendor/github.com/ethereum/go-ethereum/light/odr.go b/vendor/github.com/ethereum/go-ethereum/light/odr.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/light/odr.go rename to vendor/github.com/ethereum/go-ethereum/light/odr.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/light/odr_util.go b/vendor/github.com/ethereum/go-ethereum/light/odr_util.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/light/odr_util.go rename to vendor/github.com/ethereum/go-ethereum/light/odr_util.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/light/state.go b/vendor/github.com/ethereum/go-ethereum/light/state.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/light/state.go rename to vendor/github.com/ethereum/go-ethereum/light/state.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/light/state_object.go b/vendor/github.com/ethereum/go-ethereum/light/state_object.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/light/state_object.go rename to vendor/github.com/ethereum/go-ethereum/light/state_object.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/light/trie.go b/vendor/github.com/ethereum/go-ethereum/light/trie.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/light/trie.go rename to vendor/github.com/ethereum/go-ethereum/light/trie.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/light/txpool.go b/vendor/github.com/ethereum/go-ethereum/light/txpool.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/light/txpool.go rename to vendor/github.com/ethereum/go-ethereum/light/txpool.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/light/vm_env.go b/vendor/github.com/ethereum/go-ethereum/light/vm_env.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/light/vm_env.go rename to vendor/github.com/ethereum/go-ethereum/light/vm_env.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/logger/glog/LICENSE b/vendor/github.com/ethereum/go-ethereum/logger/glog/LICENSE similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/logger/glog/LICENSE rename to vendor/github.com/ethereum/go-ethereum/logger/glog/LICENSE diff --git a/src/vendor/github.com/ethereum/go-ethereum/logger/glog/README b/vendor/github.com/ethereum/go-ethereum/logger/glog/README similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/logger/glog/README rename to vendor/github.com/ethereum/go-ethereum/logger/glog/README diff --git a/src/vendor/github.com/ethereum/go-ethereum/logger/glog/glog.go b/vendor/github.com/ethereum/go-ethereum/logger/glog/glog.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/logger/glog/glog.go rename to vendor/github.com/ethereum/go-ethereum/logger/glog/glog.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/logger/glog/glog_file.go b/vendor/github.com/ethereum/go-ethereum/logger/glog/glog_file.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/logger/glog/glog_file.go rename to vendor/github.com/ethereum/go-ethereum/logger/glog/glog_file.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/logger/log.go b/vendor/github.com/ethereum/go-ethereum/logger/log.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/logger/log.go rename to vendor/github.com/ethereum/go-ethereum/logger/log.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/logger/loggers.go b/vendor/github.com/ethereum/go-ethereum/logger/loggers.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/logger/loggers.go rename to vendor/github.com/ethereum/go-ethereum/logger/loggers.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/logger/logsystem.go b/vendor/github.com/ethereum/go-ethereum/logger/logsystem.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/logger/logsystem.go rename to vendor/github.com/ethereum/go-ethereum/logger/logsystem.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/logger/sys.go b/vendor/github.com/ethereum/go-ethereum/logger/sys.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/logger/sys.go rename to vendor/github.com/ethereum/go-ethereum/logger/sys.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/logger/types.go b/vendor/github.com/ethereum/go-ethereum/logger/types.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/logger/types.go rename to vendor/github.com/ethereum/go-ethereum/logger/types.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/logger/verbosity.go b/vendor/github.com/ethereum/go-ethereum/logger/verbosity.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/logger/verbosity.go rename to vendor/github.com/ethereum/go-ethereum/logger/verbosity.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/metrics/disk.go b/vendor/github.com/ethereum/go-ethereum/metrics/disk.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/metrics/disk.go rename to vendor/github.com/ethereum/go-ethereum/metrics/disk.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/metrics/disk_linux.go b/vendor/github.com/ethereum/go-ethereum/metrics/disk_linux.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/metrics/disk_linux.go rename to vendor/github.com/ethereum/go-ethereum/metrics/disk_linux.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/metrics/disk_nop.go b/vendor/github.com/ethereum/go-ethereum/metrics/disk_nop.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/metrics/disk_nop.go rename to vendor/github.com/ethereum/go-ethereum/metrics/disk_nop.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/metrics/metrics.go b/vendor/github.com/ethereum/go-ethereum/metrics/metrics.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/metrics/metrics.go rename to vendor/github.com/ethereum/go-ethereum/metrics/metrics.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/miner/agent.go b/vendor/github.com/ethereum/go-ethereum/miner/agent.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/miner/agent.go rename to vendor/github.com/ethereum/go-ethereum/miner/agent.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/miner/miner.go b/vendor/github.com/ethereum/go-ethereum/miner/miner.go similarity index 89% rename from src/vendor/github.com/ethereum/go-ethereum/miner/miner.go rename to vendor/github.com/ethereum/go-ethereum/miner/miner.go index 7cc25cdf7..c16cbe6ae 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/miner/miner.go +++ b/vendor/github.com/ethereum/go-ethereum/miner/miner.go @@ -22,11 +22,13 @@ import ( "math/big" "sync/atomic" + "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/downloader" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" @@ -34,6 +36,15 @@ import ( "github.com/ethereum/go-ethereum/pow" ) +// Backend wraps all methods required for mining. +type Backend interface { + AccountManager() *accounts.Manager + BlockChain() *core.BlockChain + TxPool() *core.TxPool + ChainDb() ethdb.Database +} + +// Miner creates blocks and searches for proof-of-work values. type Miner struct { mux *event.TypeMux @@ -44,15 +55,21 @@ type Miner struct { threads int coinbase common.Address mining int32 - eth core.Backend + eth Backend pow pow.PoW canStart int32 // can start indicates whether we can start the mining operation shouldStart int32 // should start indicates whether we should start after sync } -func New(eth core.Backend, config *core.ChainConfig, mux *event.TypeMux, pow pow.PoW) *Miner { - miner := &Miner{eth: eth, mux: mux, pow: pow, worker: newWorker(config, common.Address{}, eth), canStart: 1} +func New(eth Backend, config *core.ChainConfig, mux *event.TypeMux, pow pow.PoW) *Miner { + miner := &Miner{ + eth: eth, + mux: mux, + pow: pow, + worker: newWorker(config, common.Address{}, eth, mux), + canStart: 1, + } go miner.update() return miner diff --git a/src/vendor/github.com/ethereum/go-ethereum/miner/remote_agent.go b/vendor/github.com/ethereum/go-ethereum/miner/remote_agent.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/miner/remote_agent.go rename to vendor/github.com/ethereum/go-ethereum/miner/remote_agent.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/miner/worker.go b/vendor/github.com/ethereum/go-ethereum/miner/worker.go similarity index 99% rename from src/vendor/github.com/ethereum/go-ethereum/miner/worker.go rename to vendor/github.com/ethereum/go-ethereum/miner/worker.go index dfda6d898..59406bf4e 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/miner/worker.go +++ b/vendor/github.com/ethereum/go-ethereum/miner/worker.go @@ -60,7 +60,7 @@ type uint64RingBuffer struct { next int //where is the next insertion? assert 0 <= next < len(ints) } -// environment is the workers current environment and holds +// Work is the workers current environment and holds // all of the current state information type Work struct { config *core.ChainConfig @@ -105,7 +105,7 @@ type worker struct { recv chan *Result pow pow.PoW - eth core.Backend + eth Backend chain *core.BlockChain proc core.Validator chainDb ethdb.Database @@ -130,11 +130,11 @@ type worker struct { fullValidation bool } -func newWorker(config *core.ChainConfig, coinbase common.Address, eth core.Backend) *worker { +func newWorker(config *core.ChainConfig, coinbase common.Address, eth Backend, mux *event.TypeMux) *worker { worker := &worker{ config: config, eth: eth, - mux: eth.EventMux(), + mux: mux, chainDb: eth.ChainDb(), recv: make(chan *Result, resultQueueSize), gasPrice: new(big.Int), diff --git a/src/vendor/github.com/ethereum/go-ethereum/node/api.go b/vendor/github.com/ethereum/go-ethereum/node/api.go similarity index 95% rename from src/vendor/github.com/ethereum/go-ethereum/node/api.go rename to vendor/github.com/ethereum/go-ethereum/node/api.go index 9b2be9c2e..3523874ab 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/node/api.go +++ b/vendor/github.com/ethereum/go-ethereum/node/api.go @@ -58,6 +58,22 @@ func (api *PrivateAdminAPI) AddPeer(url string) (bool, error) { return true, nil } +// RemovePeer disconnects from a a remote node if the connection exists +func (api *PrivateAdminAPI) RemovePeer(url string) (bool, error) { + // Make sure the server is running, fail otherwise + server := api.node.Server() + if server == nil { + return false, ErrNodeStopped + } + // Try to remove the url as a static peer and return + node, err := discover.ParseNode(url) + if err != nil { + return false, fmt.Errorf("invalid enode: %v", err) + } + server.RemovePeer(node) + return true, nil +} + // StartRPC starts the HTTP RPC API server. func (api *PrivateAdminAPI) StartRPC(host *string, port *rpc.HexNumber, cors *string, apis *string) (bool, error) { api.node.lock.Lock() diff --git a/src/vendor/github.com/ethereum/go-ethereum/node/config.go b/vendor/github.com/ethereum/go-ethereum/node/config.go similarity index 82% rename from src/vendor/github.com/ethereum/go-ethereum/node/config.go rename to vendor/github.com/ethereum/go-ethereum/node/config.go index bc9fec618..432da7015 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/node/config.go +++ b/vendor/github.com/ethereum/go-ethereum/node/config.go @@ -27,6 +27,7 @@ import ( "runtime" "strings" + "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/logger" @@ -36,10 +37,11 @@ import ( ) var ( - datadirPrivateKey = "nodekey" // Path within the datadir to the node's private key - datadirStaticNodes = "static-nodes.json" // Path within the datadir to the static node list - datadirTrustedNodes = "trusted-nodes.json" // Path within the datadir to the trusted node list - datadirNodeDatabase = "nodes" // Path within the datadir to store the node infos + datadirPrivateKey = "nodekey" // Path within the datadir to the node's private key + datadirDefaultKeyStore = "keystore" // Path within the datadir to the keystore + datadirStaticNodes = "static-nodes.json" // Path within the datadir to the static node list + datadirTrustedNodes = "trusted-nodes.json" // Path within the datadir to the trusted node list + datadirNodeDatabase = "nodes" // Path within the datadir to store the node infos ) // Config represents a small collection of configuration values to fine tune the @@ -53,6 +55,19 @@ type Config struct { // in memory. DataDir string + // KeyStoreDir is the file system folder that contains private keys. The directory can + // be specified as a relative path, in which case it is resolved relative to the + // current directory. + // + // If KeyStoreDir is empty, the default location is the "keystore" subdirectory of + // DataDir. If DataDir is unspecified and KeyStoreDir is empty, an ephemeral directory + // is created by New and destroyed when the node is stopped. + KeyStoreDir string + + // UseLightweightKDF lowers the memory and CPU requirements of the key store + // scrypt KDF at the expense of security. + UseLightweightKDF bool + // IPCPath is the requested location to place the IPC endpoint. If the path is // a simple file name, it is placed inside the data directory (or on the root // pipe path on Windows), whereas if it's a resolvable path name (absolute or @@ -278,3 +293,38 @@ func (c *Config) parsePersistentNodes(file string) []*discover.Node { } return nodes } + +func makeAccountManager(conf *Config) (am *accounts.Manager, ephemeralKeystore string, err error) { + scryptN := accounts.StandardScryptN + scryptP := accounts.StandardScryptP + if conf.UseLightweightKDF { + scryptN = accounts.LightScryptN + scryptP = accounts.LightScryptP + } + + var keydir string + switch { + case filepath.IsAbs(conf.KeyStoreDir): + keydir = conf.KeyStoreDir + case conf.DataDir != "": + if conf.KeyStoreDir == "" { + keydir = filepath.Join(conf.DataDir, datadirDefaultKeyStore) + } else { + keydir, err = filepath.Abs(conf.KeyStoreDir) + } + case conf.KeyStoreDir != "": + keydir, err = filepath.Abs(conf.KeyStoreDir) + default: + // There is no datadir. + keydir, err = ioutil.TempDir("", "go-ethereum-keystore") + ephemeralKeystore = keydir + } + if err != nil { + return nil, "", err + } + if err := os.MkdirAll(keydir, 0700); err != nil { + return nil, "", err + } + + return accounts.NewManager(keydir, scryptN, scryptP), ephemeralKeystore, nil +} diff --git a/src/vendor/github.com/ethereum/go-ethereum/node/errors.go b/vendor/github.com/ethereum/go-ethereum/node/errors.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/node/errors.go rename to vendor/github.com/ethereum/go-ethereum/node/errors.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/node/node.go b/vendor/github.com/ethereum/go-ethereum/node/node.go similarity index 94% rename from src/vendor/github.com/ethereum/go-ethereum/node/node.go rename to vendor/github.com/ethereum/go-ethereum/node/node.go index 1f517a027..f3be2f763 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/node/node.go +++ b/vendor/github.com/ethereum/go-ethereum/node/node.go @@ -26,6 +26,7 @@ import ( "sync" "syscall" + "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/internal/debug" "github.com/ethereum/go-ethereum/logger" @@ -49,6 +50,9 @@ type Node struct { datadir string // Path to the currently used data directory eventmux *event.TypeMux // Event multiplexer used between the services of a stack + accman *accounts.Manager + ephemeralKeystore string // if non-empty, the key directory that will be removed by Stop + serverConfig p2p.Config server *p2p.Server // Currently running P2P networking layer @@ -90,13 +94,20 @@ func New(conf *Config) (*Node, error) { return nil, err } } + am, ephemeralKeystore, err := makeAccountManager(conf) + if err != nil { + return nil, err + } + // Assemble the networking layer and the node itself nodeDbPath := "" if conf.DataDir != "" { nodeDbPath = filepath.Join(conf.DataDir, datadirNodeDatabase) } return &Node{ - datadir: conf.DataDir, + datadir: conf.DataDir, + accman: am, + ephemeralKeystore: ephemeralKeystore, serverConfig: p2p.Config{ PrivateKey: conf.NodeKey(), Name: conf.Name, @@ -156,9 +167,10 @@ func (n *Node) Start() error { for _, constructor := range n.serviceFuncs { // Create a new context for the particular service ctx := &ServiceContext{ - datadir: n.datadir, - services: make(map[reflect.Type]Service), - EventMux: n.eventmux, + datadir: n.datadir, + services: make(map[reflect.Type]Service), + EventMux: n.eventmux, + AccountManager: n.accman, } for kind, s := range services { // copy needed for threaded access ctx.services[kind] = s @@ -473,9 +485,18 @@ func (n *Node) Stop() error { n.server = nil close(n.stop) + // Remove the keystore if it was created ephemerally. + var keystoreErr error + if n.ephemeralKeystore != "" { + keystoreErr = os.RemoveAll(n.ephemeralKeystore) + } + if len(failure.Services) > 0 { return failure } + if keystoreErr != nil { + return keystoreErr + } return nil } @@ -505,16 +526,14 @@ func (n *Node) Restart() error { } // Attach creates an RPC client attached to an in-process API handler. -func (n *Node) Attach() (rpc.Client, error) { +func (n *Node) Attach() (*rpc.Client, error) { n.lock.RLock() defer n.lock.RUnlock() - // Short circuit if the node's not running if n.server == nil { return nil, ErrNodeStopped } - // Otherwise attach to the API and return - return rpc.NewInProcRPCClient(n.inprocHandler), nil + return rpc.DialInProc(n.inprocHandler), nil } // Server retrieves the currently running P2P network layer. This method is meant @@ -550,6 +569,11 @@ func (n *Node) DataDir() string { return n.datadir } +// AccountManager retrieves the account manager used by the protocol stack. +func (n *Node) AccountManager() *accounts.Manager { + return n.accman +} + // IPCEndpoint retrieves the current IPC endpoint used by the protocol stack. func (n *Node) IPCEndpoint() string { return n.ipcEndpoint diff --git a/src/vendor/github.com/ethereum/go-ethereum/node/service.go b/vendor/github.com/ethereum/go-ethereum/node/service.go similarity index 89% rename from src/vendor/github.com/ethereum/go-ethereum/node/service.go rename to vendor/github.com/ethereum/go-ethereum/node/service.go index 4d9a6e42c..51531466b 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/node/service.go +++ b/vendor/github.com/ethereum/go-ethereum/node/service.go @@ -20,6 +20,7 @@ import ( "path/filepath" "reflect" + "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/p2p" @@ -30,9 +31,10 @@ import ( // the protocol stack, that is passed to all constructors to be optionally used; // as well as utility methods to operate on the service environment. type ServiceContext struct { - datadir string // Data directory for protocol persistence - services map[reflect.Type]Service // Index of the already constructed services - EventMux *event.TypeMux // Event multiplexer used for decoupled notifications + datadir string // Data directory for protocol persistence + services map[reflect.Type]Service // Index of the already constructed services + EventMux *event.TypeMux // Event multiplexer used for decoupled notifications + AccountManager *accounts.Manager // Account manager created by the node. } // OpenDatabase opens an existing database with the given name (or creates one diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/dial.go b/vendor/github.com/ethereum/go-ethereum/p2p/dial.go similarity index 98% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/dial.go rename to vendor/github.com/ethereum/go-ethereum/p2p/dial.go index c0e703d7d..691b8539e 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/p2p/dial.go +++ b/vendor/github.com/ethereum/go-ethereum/p2p/dial.go @@ -121,6 +121,11 @@ func (s *dialstate) addStatic(n *discover.Node) { s.static[n.ID] = &dialTask{flags: staticDialedConn, dest: n} } +func (s *dialstate) removeStatic(n *discover.Node) { + // This removes a task so future attempts to connect will not be made. + delete(s.static, n.ID) +} + func (s *dialstate) newTasks(nRunning int, peers map[discover.NodeID]*Peer, now time.Time) []task { var newtasks []task isDialing := func(id discover.NodeID) bool { diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/discover/database.go b/vendor/github.com/ethereum/go-ethereum/p2p/discover/database.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/discover/database.go rename to vendor/github.com/ethereum/go-ethereum/p2p/discover/database.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/discover/node.go b/vendor/github.com/ethereum/go-ethereum/p2p/discover/node.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/discover/node.go rename to vendor/github.com/ethereum/go-ethereum/p2p/discover/node.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/discover/ntp.go b/vendor/github.com/ethereum/go-ethereum/p2p/discover/ntp.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/discover/ntp.go rename to vendor/github.com/ethereum/go-ethereum/p2p/discover/ntp.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/discover/table.go b/vendor/github.com/ethereum/go-ethereum/p2p/discover/table.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/discover/table.go rename to vendor/github.com/ethereum/go-ethereum/p2p/discover/table.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/discover/udp.go b/vendor/github.com/ethereum/go-ethereum/p2p/discover/udp.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/discover/udp.go rename to vendor/github.com/ethereum/go-ethereum/p2p/discover/udp.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/discover/udp_notwindows.go b/vendor/github.com/ethereum/go-ethereum/p2p/discover/udp_notwindows.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/discover/udp_notwindows.go rename to vendor/github.com/ethereum/go-ethereum/p2p/discover/udp_notwindows.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/discover/udp_windows.go b/vendor/github.com/ethereum/go-ethereum/p2p/discover/udp_windows.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/discover/udp_windows.go rename to vendor/github.com/ethereum/go-ethereum/p2p/discover/udp_windows.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/message.go b/vendor/github.com/ethereum/go-ethereum/p2p/message.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/message.go rename to vendor/github.com/ethereum/go-ethereum/p2p/message.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/metrics.go b/vendor/github.com/ethereum/go-ethereum/p2p/metrics.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/metrics.go rename to vendor/github.com/ethereum/go-ethereum/p2p/metrics.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/nat/nat.go b/vendor/github.com/ethereum/go-ethereum/p2p/nat/nat.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/nat/nat.go rename to vendor/github.com/ethereum/go-ethereum/p2p/nat/nat.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/nat/natpmp.go b/vendor/github.com/ethereum/go-ethereum/p2p/nat/natpmp.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/nat/natpmp.go rename to vendor/github.com/ethereum/go-ethereum/p2p/nat/natpmp.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/nat/natupnp.go b/vendor/github.com/ethereum/go-ethereum/p2p/nat/natupnp.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/nat/natupnp.go rename to vendor/github.com/ethereum/go-ethereum/p2p/nat/natupnp.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/peer.go b/vendor/github.com/ethereum/go-ethereum/p2p/peer.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/peer.go rename to vendor/github.com/ethereum/go-ethereum/p2p/peer.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/peer_error.go b/vendor/github.com/ethereum/go-ethereum/p2p/peer_error.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/peer_error.go rename to vendor/github.com/ethereum/go-ethereum/p2p/peer_error.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/protocol.go b/vendor/github.com/ethereum/go-ethereum/p2p/protocol.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/protocol.go rename to vendor/github.com/ethereum/go-ethereum/p2p/protocol.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/rlpx.go b/vendor/github.com/ethereum/go-ethereum/p2p/rlpx.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/rlpx.go rename to vendor/github.com/ethereum/go-ethereum/p2p/rlpx.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/p2p/server.go b/vendor/github.com/ethereum/go-ethereum/p2p/server.go similarity index 97% rename from src/vendor/github.com/ethereum/go-ethereum/p2p/server.go rename to vendor/github.com/ethereum/go-ethereum/p2p/server.go index 880aa7cf1..8e3cd93f9 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/p2p/server.go +++ b/vendor/github.com/ethereum/go-ethereum/p2p/server.go @@ -142,6 +142,7 @@ type Server struct { quit chan struct{} addstatic chan *discover.Node + removestatic chan *discover.Node posthandshake chan *conn addpeer chan *conn delpeer chan *Peer @@ -257,6 +258,14 @@ func (srv *Server) AddPeer(node *discover.Node) { } } +// RemovePeer disconnects from the given node +func (srv *Server) RemovePeer(node *discover.Node) { + select { + case srv.removestatic <- node: + case <-srv.quit: + } +} + // Self returns the local node's endpoint information. func (srv *Server) Self() *discover.Node { srv.lock.Lock() @@ -327,6 +336,7 @@ func (srv *Server) Start() (err error) { srv.delpeer = make(chan *Peer) srv.posthandshake = make(chan *conn) srv.addstatic = make(chan *discover.Node) + srv.removestatic = make(chan *discover.Node) srv.peerOp = make(chan peerOpFunc) srv.peerOpDone = make(chan struct{}) @@ -395,6 +405,7 @@ type dialer interface { newTasks(running int, peers map[discover.NodeID]*Peer, now time.Time) []task taskDone(task, time.Time) addStatic(*discover.Node) + removeStatic(*discover.Node) } func (srv *Server) run(dialstate dialer) { @@ -458,6 +469,15 @@ running: // it will keep the node connected. glog.V(logger.Detail).Infoln("<-addstatic:", n) dialstate.addStatic(n) + case n := <-srv.removestatic: + // This channel is used by RemovePeer to send a + // disconnect request to a peer and begin the + // stop keeping the node connected + glog.V(logger.Detail).Infoln("<-removestatic:", n) + dialstate.removeStatic(n) + if p, ok := peers[n.ID]; ok { + p.Disconnect(DiscRequested) + } case op := <-srv.peerOp: // This channel is used by Peers and PeerCount. op(peers) diff --git a/src/vendor/github.com/ethereum/go-ethereum/params/dao.go b/vendor/github.com/ethereum/go-ethereum/params/dao.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/params/dao.go rename to vendor/github.com/ethereum/go-ethereum/params/dao.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/params/protocol_params.go b/vendor/github.com/ethereum/go-ethereum/params/protocol_params.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/params/protocol_params.go rename to vendor/github.com/ethereum/go-ethereum/params/protocol_params.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/params/util.go b/vendor/github.com/ethereum/go-ethereum/params/util.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/params/util.go rename to vendor/github.com/ethereum/go-ethereum/params/util.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/pow/block.go b/vendor/github.com/ethereum/go-ethereum/pow/block.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/pow/block.go rename to vendor/github.com/ethereum/go-ethereum/pow/block.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/pow/dagger/dagger.go b/vendor/github.com/ethereum/go-ethereum/pow/dagger/dagger.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/pow/dagger/dagger.go rename to vendor/github.com/ethereum/go-ethereum/pow/dagger/dagger.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/pow/ezp/pow.go b/vendor/github.com/ethereum/go-ethereum/pow/ezp/pow.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/pow/ezp/pow.go rename to vendor/github.com/ethereum/go-ethereum/pow/ezp/pow.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/pow/pow.go b/vendor/github.com/ethereum/go-ethereum/pow/pow.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/pow/pow.go rename to vendor/github.com/ethereum/go-ethereum/pow/pow.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/release/contract.go b/vendor/github.com/ethereum/go-ethereum/release/contract.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/release/contract.go rename to vendor/github.com/ethereum/go-ethereum/release/contract.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/release/contract.sol b/vendor/github.com/ethereum/go-ethereum/release/contract.sol similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/release/contract.sol rename to vendor/github.com/ethereum/go-ethereum/release/contract.sol diff --git a/src/vendor/github.com/ethereum/go-ethereum/release/generator.go b/vendor/github.com/ethereum/go-ethereum/release/generator.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/release/generator.go rename to vendor/github.com/ethereum/go-ethereum/release/generator.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/release/release.go b/vendor/github.com/ethereum/go-ethereum/release/release.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/release/release.go rename to vendor/github.com/ethereum/go-ethereum/release/release.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/rlp/decode.go b/vendor/github.com/ethereum/go-ethereum/rlp/decode.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/rlp/decode.go rename to vendor/github.com/ethereum/go-ethereum/rlp/decode.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/rlp/doc.go b/vendor/github.com/ethereum/go-ethereum/rlp/doc.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/rlp/doc.go rename to vendor/github.com/ethereum/go-ethereum/rlp/doc.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/rlp/encode.go b/vendor/github.com/ethereum/go-ethereum/rlp/encode.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/rlp/encode.go rename to vendor/github.com/ethereum/go-ethereum/rlp/encode.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/rlp/raw.go b/vendor/github.com/ethereum/go-ethereum/rlp/raw.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/rlp/raw.go rename to vendor/github.com/ethereum/go-ethereum/rlp/raw.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/rlp/typecache.go b/vendor/github.com/ethereum/go-ethereum/rlp/typecache.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/rlp/typecache.go rename to vendor/github.com/ethereum/go-ethereum/rlp/typecache.go diff --git a/vendor/github.com/ethereum/go-ethereum/rpc/client.go b/vendor/github.com/ethereum/go-ethereum/rpc/client.go new file mode 100644 index 000000000..34a3b7831 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/rpc/client.go @@ -0,0 +1,776 @@ +// Copyright 2016 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package rpc + +import ( + "bytes" + "container/list" + "encoding/json" + "errors" + "fmt" + "net" + "net/url" + "reflect" + "strconv" + "sync" + "sync/atomic" + "time" + + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "golang.org/x/net/context" +) + +var ( + ErrClientQuit = errors.New("client is closed") + ErrNoResult = errors.New("no result in JSON-RPC response") + ErrSubscriptionQueueOverflow = errors.New("subscription queue overflow") +) + +const ( + // Timeouts + tcpKeepAliveInterval = 30 * time.Second + defaultDialTimeout = 10 * time.Second // used when dialing if the context has no deadline + defaultWriteTimeout = 10 * time.Second // used for calls if the context has no deadline + subscribeTimeout = 5 * time.Second // overall timeout eth_subscribe, rpc_modules calls +) + +const ( + // Subscriptions are removed when the subscriber cannot keep up. + // + // This can be worked around by supplying a channel with sufficiently sized buffer, + // but this can be inconvenient and hard to explain in the docs. Another issue with + // buffered channels is that the buffer is static even though it might not be needed + // most of the time. + // + // The approach taken here is to maintain a per-subscription linked list buffer + // shrinks on demand. If the buffer reaches the size below, the subscription is + // dropped. + maxClientSubscriptionBuffer = 8000 +) + +// BatchElem is an element in a batch request. +type BatchElem struct { + Method string + Args []interface{} + // The result is unmarshaled into this field. Result must be set to a + // non-nil pointer value of the desired type, otherwise the response will be + // discarded. + Result interface{} + // Error is set if the server returns an error for this request, or if + // unmarshaling into Result fails. It is not set for I/O errors. + Error error +} + +// A value of this type can a JSON-RPC request, notification, successful response or +// error response. Which one it is depends on the fields. +type jsonrpcMessage struct { + Version string `json:"jsonrpc"` + ID json.RawMessage `json:"id,omitempty"` + Method string `json:"method,omitempty"` + Params json.RawMessage `json:"params,omitempty"` + Error *jsonError `json:"error,omitempty"` + Result json.RawMessage `json:"result,omitempty"` +} + +func (msg *jsonrpcMessage) isNotification() bool { + return msg.ID == nil && msg.Method != "" +} + +func (msg *jsonrpcMessage) isResponse() bool { + return msg.hasValidID() && msg.Method == "" && len(msg.Params) == 0 +} + +func (msg *jsonrpcMessage) hasValidID() bool { + return len(msg.ID) > 0 && msg.ID[0] != '{' && msg.ID[0] != '[' +} + +func (msg *jsonrpcMessage) String() string { + b, _ := json.Marshal(msg) + return string(b) +} + +// Client represents a connection to an RPC server. +type Client struct { + idCounter uint32 + connectFunc func(ctx context.Context) (net.Conn, error) + isHTTP bool + + // writeConn is only safe to access outside dispatch, with the + // write lock held. The write lock is taken by sending on + // requestOp and released by sending on sendDone. + writeConn net.Conn + + // for dispatch + close chan struct{} + didQuit chan struct{} // closed when client quits + reconnected chan net.Conn // where write/reconnect sends the new connection + readErr chan error // errors from read + readResp chan []*jsonrpcMessage // valid messages from read + requestOp chan *requestOp // for registering response IDs + sendDone chan error // signals write completion, releases write lock + respWait map[string]*requestOp // active requests + subs map[string]*ClientSubscription // active subscriptions +} + +type requestOp struct { + ids []json.RawMessage + err error + resp chan *jsonrpcMessage // receives up to len(ids) responses + sub *ClientSubscription // only set for EthSubscribe requests +} + +func (op *requestOp) wait(ctx context.Context) (*jsonrpcMessage, error) { + select { + case <-ctx.Done(): + return nil, ctx.Err() + case resp := <-op.resp: + return resp, op.err + } +} + +// Dial creates a new client for the given URL. +// +// The currently supported URL schemes are "http", "https", "ws" and "wss". If rawurl is a +// file name with no URL scheme, a local socket connection is established using UNIX +// domain sockets on supported platforms and named pipes on Windows. If you want to +// configure transport options, use DialHTTP, DialWebsocket or DialIPC instead. +// +// For websocket connections, the origin is set to the local host name. +// +// The client reconnects automatically if the connection is lost. +func Dial(rawurl string) (*Client, error) { + return DialContext(context.Background(), rawurl) +} + +// DialContext creates a new RPC client, just like Dial. +// +// The context is used to cancel or time out the initial connection establishment. It does +// not affect subsequent interactions with the client. +func DialContext(ctx context.Context, rawurl string) (*Client, error) { + u, err := url.Parse(rawurl) + if err != nil { + return nil, err + } + switch u.Scheme { + case "http", "https": + return DialHTTP(rawurl) + case "ws", "wss": + return DialWebsocket(ctx, rawurl, "") + case "": + return DialIPC(ctx, rawurl) + default: + return nil, fmt.Errorf("no known transport for URL scheme %q", u.Scheme) + } +} + +func newClient(initctx context.Context, connectFunc func(context.Context) (net.Conn, error)) (*Client, error) { + conn, err := connectFunc(initctx) + if err != nil { + return nil, err + } + _, isHTTP := conn.(*httpConn) + + c := &Client{ + writeConn: conn, + isHTTP: isHTTP, + connectFunc: connectFunc, + close: make(chan struct{}), + didQuit: make(chan struct{}), + reconnected: make(chan net.Conn), + readErr: make(chan error), + readResp: make(chan []*jsonrpcMessage), + requestOp: make(chan *requestOp), + sendDone: make(chan error, 1), + respWait: make(map[string]*requestOp), + subs: make(map[string]*ClientSubscription), + } + if !isHTTP { + go c.dispatch(conn) + } + return c, nil +} + +func (c *Client) nextID() json.RawMessage { + id := atomic.AddUint32(&c.idCounter, 1) + return []byte(strconv.FormatUint(uint64(id), 10)) +} + +// SupportedModules calls the rpc_modules method, retrieving the list of +// APIs that are available on the server. +func (c *Client) SupportedModules() (map[string]string, error) { + var result map[string]string + ctx, cancel := context.WithTimeout(context.Background(), subscribeTimeout) + defer cancel() + err := c.CallContext(ctx, &result, "rpc_modules") + return result, err +} + +// Close closes the client, aborting any in-flight requests. +func (c *Client) Close() { + if c.isHTTP { + return + } + select { + case c.close <- struct{}{}: + <-c.didQuit + case <-c.didQuit: + } +} + +// Call performs a JSON-RPC call with the given arguments and unmarshals into +// result if no error occurred. +// +// The result must be a pointer so that package json can unmarshal into it. You +// can also pass nil, in which case the result is ignored. +func (c *Client) Call(result interface{}, method string, args ...interface{}) error { + ctx := context.Background() + return c.CallContext(ctx, result, method, args...) +} + +// CallContext performs a JSON-RPC call with the given arguments. If the context is +// canceled before the call has successfully returned, CallContext returns immediately. +// +// The result must be a pointer so that package json can unmarshal into it. You +// can also pass nil, in which case the result is ignored. +func (c *Client) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error { + msg, err := c.newMessage(method, args...) + if err != nil { + return err + } + op := &requestOp{ids: []json.RawMessage{msg.ID}, resp: make(chan *jsonrpcMessage, 1)} + + if c.isHTTP { + err = c.sendHTTP(ctx, op, msg) + } else { + err = c.send(ctx, op, msg) + } + if err != nil { + return err + } + + // dispatch has accepted the request and will close the channel it when it quits. + switch resp, err := op.wait(ctx); { + case err != nil: + return err + case resp.Error != nil: + return resp.Error + case len(resp.Result) == 0: + return ErrNoResult + default: + return json.Unmarshal(resp.Result, &result) + } +} + +// BatchCall sends all given requests as a single batch and waits for the server +// to return a response for all of them. +// +// In contrast to Call, BatchCall only returns I/O errors. Any error specific to +// a request is reported through the Error field of the corresponding BatchElem. +// +// Note that batch calls may not be executed atomically on the server side. +func (c *Client) BatchCall(b []BatchElem) error { + ctx := context.Background() + return c.BatchCallContext(ctx, b) +} + +// BatchCall sends all given requests as a single batch and waits for the server +// to return a response for all of them. The wait duration is bounded by the +// context's deadline. +// +// In contrast to CallContext, BatchCallContext only returns errors that have occurred +// while sending the request. Any error specific to a request is reported through the +// Error field of the corresponding BatchElem. +// +// Note that batch calls may not be executed atomically on the server side. +func (c *Client) BatchCallContext(ctx context.Context, b []BatchElem) error { + msgs := make([]*jsonrpcMessage, len(b)) + op := &requestOp{ + ids: make([]json.RawMessage, len(b)), + resp: make(chan *jsonrpcMessage, len(b)), + } + for i, elem := range b { + msg, err := c.newMessage(elem.Method, elem.Args...) + if err != nil { + return err + } + msgs[i] = msg + op.ids[i] = msg.ID + } + + var err error + if c.isHTTP { + err = c.sendBatchHTTP(ctx, op, msgs) + } else { + err = c.send(ctx, op, msgs) + } + + // Wait for all responses to come back. + for n := 0; n < len(b) && err == nil; n++ { + var resp *jsonrpcMessage + resp, err = op.wait(ctx) + if err != nil { + break + } + // Find the element corresponding to this response. + // The element is guaranteed to be present because dispatch + // only sends valid IDs to our channel. + var elem *BatchElem + for i := range msgs { + if bytes.Equal(msgs[i].ID, resp.ID) { + elem = &b[i] + break + } + } + if resp.Error != nil { + elem.Error = resp.Error + continue + } + if len(resp.Result) == 0 { + elem.Error = ErrNoResult + continue + } + elem.Error = json.Unmarshal(resp.Result, elem.Result) + } + return err +} + +// EthSubscribe calls the "eth_subscribe" method with the given arguments, +// registering a subscription. Server notifications for the subscription are +// sent to the given channel. The element type of the channel must match the +// expected type of content returned by the subscription. +// +// The context argument cancels the RPC request that sets up the subscription but has no +// effect on the subscription after EthSubscribe has returned. +// +// Slow subscribers will be dropped eventually. Client buffers up to 8000 notifications +// before considering the subscriber dead. The subscription Err channel will receive +// ErrSubscriptionQueueOverflow. Use a sufficiently large buffer on the channel or ensure +// that the channel usually has at least one reader to prevent this issue. +func (c *Client) EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (*ClientSubscription, error) { + // Check type of channel first. + chanVal := reflect.ValueOf(channel) + if chanVal.Kind() != reflect.Chan || chanVal.Type().ChanDir()&reflect.SendDir == 0 { + panic("first argument to EthSubscribe must be a writable channel") + } + if chanVal.IsNil() { + panic("channel given to EthSubscribe must not be nil") + } + if c.isHTTP { + return nil, ErrNotificationsUnsupported + } + + msg, err := c.newMessage(subscribeMethod, args...) + if err != nil { + return nil, err + } + op := &requestOp{ + ids: []json.RawMessage{msg.ID}, + resp: make(chan *jsonrpcMessage), + sub: newClientSubscription(c, chanVal), + } + + // Send the subscription request. + // The arrival and validity of the response is signaled on sub.quit. + if err := c.send(ctx, op, msg); err != nil { + return nil, err + } + if _, err := op.wait(ctx); err != nil { + return nil, err + } + return op.sub, nil +} + +func (c *Client) newMessage(method string, paramsIn ...interface{}) (*jsonrpcMessage, error) { + params, err := json.Marshal(paramsIn) + if err != nil { + return nil, err + } + return &jsonrpcMessage{Version: "2.0", ID: c.nextID(), Method: method, Params: params}, nil +} + +// send registers op with the dispatch loop, then sends msg on the connection. +// if sending fails, op is deregistered. +func (c *Client) send(ctx context.Context, op *requestOp, msg interface{}) error { + select { + case c.requestOp <- op: + if glog.V(logger.Detail) { + glog.Info("sending ", msg) + } + err := c.write(ctx, msg) + c.sendDone <- err + return err + case <-ctx.Done(): + // This can happen if the client is overloaded or unable to keep up with + // subscription notifications. + return ctx.Err() + case <-c.didQuit: + return ErrClientQuit + } +} + +func (c *Client) write(ctx context.Context, msg interface{}) error { + deadline, ok := ctx.Deadline() + if !ok { + deadline = time.Now().Add(defaultWriteTimeout) + } + // The previous write failed. Try to establish a new connection. + if c.writeConn == nil { + if err := c.reconnect(ctx); err != nil { + return err + } + } + c.writeConn.SetWriteDeadline(deadline) + err := json.NewEncoder(c.writeConn).Encode(msg) + if err != nil { + c.writeConn = nil + } + return err +} + +func (c *Client) reconnect(ctx context.Context) error { + newconn, err := c.connectFunc(ctx) + if err != nil { + glog.V(logger.Detail).Infof("reconnect failed: %v", err) + return err + } + select { + case c.reconnected <- newconn: + c.writeConn = newconn + return nil + case <-c.didQuit: + newconn.Close() + return ErrClientQuit + } +} + +// dispatch is the main loop of the client. +// It sends read messages to waiting calls to Call and BatchCall +// and subscription notifications to registered subscriptions. +func (c *Client) dispatch(conn net.Conn) { + // Spawn the initial read loop. + go c.read(conn) + + var ( + lastOp *requestOp // tracks last send operation + requestOpLock = c.requestOp // nil while the send lock is held + reading = true // if true, a read loop is running + ) + defer close(c.didQuit) + defer func() { + c.closeRequestOps(ErrClientQuit) + conn.Close() + if reading { + // Empty read channels until read is dead. + for { + select { + case <-c.readResp: + case <-c.readErr: + return + } + } + } + }() + + for { + select { + case <-c.close: + return + + // Read path. + case batch := <-c.readResp: + for _, msg := range batch { + switch { + case msg.isNotification(): + if glog.V(logger.Detail) { + glog.Info("<-readResp: notification ", msg) + } + c.handleNotification(msg) + case msg.isResponse(): + if glog.V(logger.Detail) { + glog.Info("<-readResp: response ", msg) + } + c.handleResponse(msg) + default: + if glog.V(logger.Debug) { + glog.Error("<-readResp: dropping weird message", msg) + } + // TODO: maybe close + } + } + + case err := <-c.readErr: + glog.V(logger.Debug).Infof("<-readErr: %v", err) + c.closeRequestOps(err) + conn.Close() + reading = false + + case newconn := <-c.reconnected: + glog.V(logger.Debug).Infof("<-reconnected: (reading=%t) %v", reading, conn.RemoteAddr()) + if reading { + // Wait for the previous read loop to exit. This is a rare case. + conn.Close() + <-c.readErr + } + go c.read(newconn) + reading = true + conn = newconn + + // Send path. + case op := <-requestOpLock: + // Stop listening for further send ops until the current one is done. + requestOpLock = nil + lastOp = op + for _, id := range op.ids { + c.respWait[string(id)] = op + } + + case err := <-c.sendDone: + if err != nil { + // Remove response handlers for the last send. We remove those here + // because the error is already handled in Call or BatchCall. When the + // read loop goes down, it will signal all other current operations. + for _, id := range lastOp.ids { + delete(c.respWait, string(id)) + } + } + // Listen for send ops again. + requestOpLock = c.requestOp + lastOp = nil + } + } +} + +// closeRequestOps unblocks pending send ops and active subscriptions. +func (c *Client) closeRequestOps(err error) { + didClose := make(map[*requestOp]bool) + + for id, op := range c.respWait { + // Remove the op so that later calls will not close op.resp again. + delete(c.respWait, id) + + if !didClose[op] { + op.err = err + close(op.resp) + didClose[op] = true + } + } + for id, sub := range c.subs { + delete(c.subs, id) + sub.quitWithError(err, false) + } +} + +func (c *Client) handleNotification(msg *jsonrpcMessage) { + if msg.Method != notificationMethod { + glog.V(logger.Debug).Info("dropping non-subscription message: ", msg) + return + } + var subResult struct { + ID string `json:"subscription"` + Result json.RawMessage `json:"result"` + } + if err := json.Unmarshal(msg.Params, &subResult); err != nil { + glog.V(logger.Debug).Info("dropping invalid subscription message: ", msg) + return + } + if c.subs[subResult.ID] != nil { + c.subs[subResult.ID].deliver(subResult.Result) + } +} + +func (c *Client) handleResponse(msg *jsonrpcMessage) { + op := c.respWait[string(msg.ID)] + if op == nil { + glog.V(logger.Debug).Infof("unsolicited response %v", msg) + return + } + delete(c.respWait, string(msg.ID)) + // For normal responses, just forward the reply to Call/BatchCall. + if op.sub == nil { + op.resp <- msg + return + } + // For subscription responses, start the subscription if the server + // indicates success. EthSubscribe gets unblocked in either case through + // the op.resp channel. + defer close(op.resp) + if msg.Error != nil { + op.err = msg.Error + return + } + if op.err = json.Unmarshal(msg.Result, &op.sub.subid); op.err == nil { + go op.sub.start() + c.subs[op.sub.subid] = op.sub + } +} + +// Reading happens on a dedicated goroutine. + +func (c *Client) read(conn net.Conn) error { + var ( + buf json.RawMessage + dec = json.NewDecoder(conn) + ) + readMessage := func() (rs []*jsonrpcMessage, err error) { + buf = buf[:0] + if err = dec.Decode(&buf); err != nil { + return nil, err + } + if isBatch(buf) { + err = json.Unmarshal(buf, &rs) + } else { + rs = make([]*jsonrpcMessage, 1) + err = json.Unmarshal(buf, &rs[0]) + } + return rs, err + } + + for { + resp, err := readMessage() + if err != nil { + c.readErr <- err + return err + } + c.readResp <- resp + } +} + +// Subscriptions. + +// A ClientSubscription represents a subscription established through EthSubscribe. +type ClientSubscription struct { + client *Client + etype reflect.Type + channel reflect.Value + subid string + in chan json.RawMessage + + quitOnce sync.Once // ensures quit is closed once + quit chan struct{} // quit is closed when the subscription exits + errOnce sync.Once // ensures err is closed once + err chan error +} + +func newClientSubscription(c *Client, channel reflect.Value) *ClientSubscription { + sub := &ClientSubscription{ + client: c, + etype: channel.Type().Elem(), + channel: channel, + quit: make(chan struct{}), + err: make(chan error, 1), + in: make(chan json.RawMessage), + } + return sub +} + +// Err returns the subscription error channel. The intended use of Err is to schedule +// resubscription when the client connection is closed unexpectedly. +// +// The error channel receives a value when the subscription has ended due +// to an error. The received error is ErrClientQuit if Close has been called +// on the underlying client and no other error has occurred. +// +// The error channel is closed when Unsubscribe is called on the subscription. +func (sub *ClientSubscription) Err() <-chan error { + return sub.err +} + +// Unsubscribe unsubscribes the notification and closes the error channel. +// It can safely be called more than once. +func (sub *ClientSubscription) Unsubscribe() { + sub.quitWithError(nil, true) + sub.errOnce.Do(func() { close(sub.err) }) +} + +func (sub *ClientSubscription) quitWithError(err error, unsubscribeServer bool) { + sub.quitOnce.Do(func() { + // The dispatch loop won't be able to execute the unsubscribe call + // if it is blocked on deliver. Close sub.quit first because it + // unblocks deliver. + close(sub.quit) + if unsubscribeServer { + sub.requestUnsubscribe() + } + if err != nil { + sub.err <- err + } + }) +} + +func (sub *ClientSubscription) deliver(result json.RawMessage) (ok bool) { + select { + case sub.in <- result: + return true + case <-sub.quit: + return false + } +} + +func (sub *ClientSubscription) start() { + sub.quitWithError(sub.forward()) +} + +func (sub *ClientSubscription) forward() (err error, unsubscribeServer bool) { + cases := []reflect.SelectCase{ + {Dir: reflect.SelectRecv, Chan: reflect.ValueOf(sub.quit)}, + {Dir: reflect.SelectRecv, Chan: reflect.ValueOf(sub.in)}, + {Dir: reflect.SelectSend, Chan: sub.channel}, + } + buffer := list.New() + defer buffer.Init() + for { + var chosen int + var recv reflect.Value + if buffer.Len() == 0 { + // Idle, omit send case. + chosen, recv, _ = reflect.Select(cases[:2]) + } else { + // Non-empty buffer, send the first queued item. + cases[2].Send = reflect.ValueOf(buffer.Front().Value) + chosen, recv, _ = reflect.Select(cases) + } + + switch chosen { + case 0: // <-sub.quit + return nil, false + case 1: // <-sub.in + val, err := sub.unmarshal(recv.Interface().(json.RawMessage)) + if err != nil { + return err, true + } + if buffer.Len() == maxClientSubscriptionBuffer { + return ErrSubscriptionQueueOverflow, true + } + buffer.PushBack(val) + case 2: // sub.channel<- + cases[2].Send = reflect.Value{} // Don't hold onto the value. + buffer.Remove(buffer.Front()) + } + } +} + +func (sub *ClientSubscription) unmarshal(result json.RawMessage) (interface{}, error) { + val := reflect.New(sub.etype) + err := json.Unmarshal(result, val.Interface()) + return val.Elem().Interface(), err +} + +func (sub *ClientSubscription) requestUnsubscribe() error { + var result interface{} + return sub.client.Call(&result, unsubscribeMethod, sub.subid) +} diff --git a/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.4.go b/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.4.go new file mode 100644 index 000000000..ac956a17d --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.4.go @@ -0,0 +1,60 @@ +// Copyright 2016 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +// +build !go1.5 + +package rpc + +import ( + "net" + "net/http" + "time" + + "golang.org/x/net/context" +) + +// In older versions of Go (below 1.5), dials cannot be canceled +// via a channel or context. The context deadline can still applied. + +// contextDialer returns a dialer that applies the deadline value from the given context. +func contextDialer(ctx context.Context) *net.Dialer { + dialer := &net.Dialer{KeepAlive: tcpKeepAliveInterval} + if deadline, ok := ctx.Deadline(); ok { + dialer.Deadline = deadline + } else { + dialer.Deadline = time.Now().Add(defaultDialTimeout) + } + return dialer +} + +// dialContext connects to the given address, aborting the dial if ctx is canceled. +func dialContext(ctx context.Context, network, addr string) (net.Conn, error) { + return contextDialer(ctx).Dial(network, addr) +} + +// requestWithContext copies req, adding the cancelation channel and deadline from ctx. +func requestWithContext(c *http.Client, req *http.Request, ctx context.Context) (*http.Client, *http.Request) { + // Set Timeout on the client if the context has a deadline. + // Note that there is no default timeout (unlike in contextDialer) because + // the timeout applies to the entire request, including reads from body. + if deadline, ok := ctx.Deadline(); ok { + c2 := *c + c2.Timeout = deadline.Sub(time.Now()) + c = &c2 + } + req2 := *req + return c, &req2 +} diff --git a/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.5.go b/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.5.go new file mode 100644 index 000000000..4a007d9f8 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.5.go @@ -0,0 +1,61 @@ +// Copyright 2016 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +// +build go1.5,!go1.6 + +package rpc + +import ( + "net" + "net/http" + "time" + + "golang.org/x/net/context" +) + +// In Go 1.5, dials cannot be canceled via a channel or context. The context deadline can +// still be applied. Go 1.5 adds the ability to cancel HTTP requests via a channel. + +// contextDialer returns a dialer that applies the deadline value from the given context. +func contextDialer(ctx context.Context) *net.Dialer { + dialer := &net.Dialer{KeepAlive: tcpKeepAliveInterval} + if deadline, ok := ctx.Deadline(); ok { + dialer.Deadline = deadline + } else { + dialer.Deadline = time.Now().Add(defaultDialTimeout) + } + return dialer +} + +// dialContext connects to the given address, aborting the dial if ctx is canceled. +func dialContext(ctx context.Context, network, addr string) (net.Conn, error) { + return contextDialer(ctx).Dial(network, addr) +} + +// requestWithContext copies req, adding the cancelation channel and deadline from ctx. +func requestWithContext(c *http.Client, req *http.Request, ctx context.Context) (*http.Client, *http.Request) { + // Set Timeout on the client if the context has a deadline. + // Note that there is no default timeout (unlike in contextDialer) because + // the timeout applies to the entire request, including reads from body. + if deadline, ok := ctx.Deadline(); ok { + c2 := *c + c2.Timeout = deadline.Sub(time.Now()) + c = &c2 + } + req2 := *req + req2.Cancel = ctx.Done() + return c, &req2 +} diff --git a/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.6.go b/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.6.go new file mode 100644 index 000000000..67777ddc6 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.6.go @@ -0,0 +1,55 @@ +// Copyright 2016 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +// +build go1.6,!go1.7 + +package rpc + +import ( + "net" + "net/http" + "time" + + "golang.org/x/net/context" +) + +// In Go 1.6, net.Dialer gained the ability to cancel via a channel. + +// contextDialer returns a dialer that applies the deadline value from the given context. +func contextDialer(ctx context.Context) *net.Dialer { + dialer := &net.Dialer{Cancel: ctx.Done(), KeepAlive: tcpKeepAliveInterval} + if deadline, ok := ctx.Deadline(); ok { + dialer.Deadline = deadline + } else { + dialer.Deadline = time.Now().Add(defaultDialTimeout) + } + return dialer +} + +// dialContext connects to the given address, aborting the dial if ctx is canceled. +func dialContext(ctx context.Context, network, addr string) (net.Conn, error) { + return contextDialer(ctx).Dial(network, addr) +} + +// requestWithContext copies req, adding the cancelation channel and deadline from ctx. +func requestWithContext(c *http.Client, req *http.Request, ctx context.Context) (*http.Client, *http.Request) { + // We set Timeout on the client for Go <= 1.5. There + // is no need to do that here because the dial will be canceled + // by package http. + req2 := *req + req2.Cancel = ctx.Done() + return c, &req2 +} diff --git a/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.7.go b/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.7.go new file mode 100644 index 000000000..56ce12ab8 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/rpc/client_context_go1.7.go @@ -0,0 +1,51 @@ +// Copyright 2016 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +// +build go1.7 + +package rpc + +import ( + "context" + "net" + "net/http" + "time" +) + +// In Go 1.7, context moved into the standard library and support +// for cancelation via context was added to net.Dialer and http.Request. + +// contextDialer returns a dialer that applies the deadline value from the given context. +func contextDialer(ctx context.Context) *net.Dialer { + dialer := &net.Dialer{Cancel: ctx.Done(), KeepAlive: tcpKeepAliveInterval} + if deadline, ok := ctx.Deadline(); ok { + dialer.Deadline = deadline + } else { + dialer.Deadline = time.Now().Add(defaultDialTimeout) + } + return dialer +} + +// dialContext connects to the given address, aborting the dial if ctx is canceled. +func dialContext(ctx context.Context, network, addr string) (net.Conn, error) { + d := &net.Dialer{KeepAlive: tcpKeepAliveInterval} + return d.DialContext(ctx, network, addr) +} + +// requestWithContext copies req, adding the cancelation channel and deadline from ctx. +func requestWithContext(c *http.Client, req *http.Request, ctx context.Context) (*http.Client, *http.Request) { + return c, req.WithContext(ctx) +} diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/doc.go b/vendor/github.com/ethereum/go-ethereum/rpc/doc.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/rpc/doc.go rename to vendor/github.com/ethereum/go-ethereum/rpc/doc.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/errors.go b/vendor/github.com/ethereum/go-ethereum/rpc/errors.go similarity index 59% rename from src/vendor/github.com/ethereum/go-ethereum/rpc/errors.go rename to vendor/github.com/ethereum/go-ethereum/rpc/errors.go index bc352fc45..9cf9dc60c 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/errors.go +++ b/vendor/github.com/ethereum/go-ethereum/rpc/errors.go @@ -24,74 +24,43 @@ type methodNotFoundError struct { method string } -func (e *methodNotFoundError) Code() int { - return -32601 -} +func (e *methodNotFoundError) ErrorCode() int { return -32601 } func (e *methodNotFoundError) Error() string { return fmt.Sprintf("The method %s%s%s does not exist/is not available", e.service, serviceMethodSeparator, e.method) } // received message isn't a valid request -type invalidRequestError struct { - message string -} +type invalidRequestError struct{ message string } -func (e *invalidRequestError) Code() int { - return -32600 -} +func (e *invalidRequestError) ErrorCode() int { return -32600 } -func (e *invalidRequestError) Error() string { - return e.message -} +func (e *invalidRequestError) Error() string { return e.message } // received message is invalid -type invalidMessageError struct { - message string -} +type invalidMessageError struct{ message string } -func (e *invalidMessageError) Code() int { - return -32700 -} +func (e *invalidMessageError) ErrorCode() int { return -32700 } -func (e *invalidMessageError) Error() string { - return e.message -} +func (e *invalidMessageError) Error() string { return e.message } // unable to decode supplied params, or an invalid number of parameters -type invalidParamsError struct { - message string -} +type invalidParamsError struct{ message string } -func (e *invalidParamsError) Code() int { - return -32602 -} +func (e *invalidParamsError) ErrorCode() int { return -32602 } -func (e *invalidParamsError) Error() string { - return e.message -} +func (e *invalidParamsError) Error() string { return e.message } // logic error, callback returned an error -type callbackError struct { - message string -} +type callbackError struct{ message string } -func (e *callbackError) Code() int { - return -32000 -} +func (e *callbackError) ErrorCode() int { return -32000 } -func (e *callbackError) Error() string { - return e.message -} +func (e *callbackError) Error() string { return e.message } // issued when a request is received after the server is issued to stop. -type shutdownError struct { -} +type shutdownError struct{} -func (e *shutdownError) Code() int { - return -32000 -} +func (e *shutdownError) ErrorCode() int { return -32000 } -func (e *shutdownError) Error() string { - return "server is shutting down" -} +func (e *shutdownError) Error() string { return "server is shutting down" } diff --git a/vendor/github.com/ethereum/go-ethereum/rpc/http.go b/vendor/github.com/ethereum/go-ethereum/rpc/http.go new file mode 100644 index 000000000..afcdd4bd6 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/rpc/http.go @@ -0,0 +1,175 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package rpc + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net" + "net/http" + "strings" + "sync" + "time" + + "github.com/rs/cors" + "golang.org/x/net/context" +) + +const ( + maxHTTPRequestContentLength = 1024 * 128 +) + +var nullAddr, _ = net.ResolveTCPAddr("tcp", "127.0.0.1:0") + +type httpConn struct { + client *http.Client + req *http.Request + closeOnce sync.Once + closed chan struct{} +} + +// httpConn is treated specially by Client. +func (hc *httpConn) LocalAddr() net.Addr { return nullAddr } +func (hc *httpConn) RemoteAddr() net.Addr { return nullAddr } +func (hc *httpConn) SetReadDeadline(time.Time) error { return nil } +func (hc *httpConn) SetWriteDeadline(time.Time) error { return nil } +func (hc *httpConn) SetDeadline(time.Time) error { return nil } +func (hc *httpConn) Write([]byte) (int, error) { panic("Write called") } + +func (hc *httpConn) Read(b []byte) (int, error) { + <-hc.closed + return 0, io.EOF +} + +func (hc *httpConn) Close() error { + hc.closeOnce.Do(func() { close(hc.closed) }) + return nil +} + +// DialHTTP creates a new RPC clients that connection to an RPC server over HTTP. +func DialHTTP(endpoint string) (*Client, error) { + req, err := http.NewRequest("POST", endpoint, nil) + if err != nil { + return nil, err + } + req.Header.Set("Content-Type", "application/json") + req.Header.Set("Accept", "application/json") + + initctx := context.Background() + return newClient(initctx, func(context.Context) (net.Conn, error) { + return &httpConn{client: new(http.Client), req: req, closed: make(chan struct{})}, nil + }) +} + +func (c *Client) sendHTTP(ctx context.Context, op *requestOp, msg interface{}) error { + hc := c.writeConn.(*httpConn) + respBody, err := hc.doRequest(ctx, msg) + if err != nil { + return err + } + defer respBody.Close() + var respmsg jsonrpcMessage + if err := json.NewDecoder(respBody).Decode(&respmsg); err != nil { + return err + } + op.resp <- &respmsg + return nil +} + +func (c *Client) sendBatchHTTP(ctx context.Context, op *requestOp, msgs []*jsonrpcMessage) error { + hc := c.writeConn.(*httpConn) + respBody, err := hc.doRequest(ctx, msgs) + if err != nil { + return err + } + defer respBody.Close() + var respmsgs []jsonrpcMessage + if err := json.NewDecoder(respBody).Decode(&respmsgs); err != nil { + return err + } + for _, respmsg := range respmsgs { + op.resp <- &respmsg + } + return nil +} + +func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadCloser, error) { + body, err := json.Marshal(msg) + if err != nil { + return nil, err + } + client, req := requestWithContext(hc.client, hc.req, ctx) + req.Body = ioutil.NopCloser(bytes.NewReader(body)) + req.ContentLength = int64(len(body)) + + resp, err := client.Do(req) + if err != nil { + return nil, err + } + return resp.Body, nil +} + +// httpReadWriteNopCloser wraps a io.Reader and io.Writer with a NOP Close method. +type httpReadWriteNopCloser struct { + io.Reader + io.Writer +} + +// Close does nothing and returns always nil +func (t *httpReadWriteNopCloser) Close() error { + return nil +} + +// NewHTTPServer creates a new HTTP RPC server around an API provider. +// +// Deprecated: Server implements http.Handler +func NewHTTPServer(corsString string, srv *Server) *http.Server { + return &http.Server{Handler: newCorsHandler(srv, corsString)} +} + +// ServeHTTP serves JSON-RPC requests over HTTP. +func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if r.ContentLength > maxHTTPRequestContentLength { + http.Error(w, + fmt.Sprintf("content length too large (%d>%d)", r.ContentLength, maxHTTPRequestContentLength), + http.StatusRequestEntityTooLarge) + return + } + w.Header().Set("content-type", "application/json") + + // create a codec that reads direct from the request body until + // EOF and writes the response to w and order the server to process + // a single request. + codec := NewJSONCodec(&httpReadWriteNopCloser{r.Body, w}) + defer codec.Close() + srv.ServeSingleRequest(codec, OptionMethodInvocation) +} + +func newCorsHandler(srv *Server, corsString string) http.Handler { + var allowedOrigins []string + for _, domain := range strings.Split(corsString, ",") { + allowedOrigins = append(allowedOrigins, strings.TrimSpace(domain)) + } + c := cors.New(cors.Options{ + AllowedOrigins: allowedOrigins, + AllowedMethods: []string{"POST", "GET"}, + }) + return c.Handler(srv) +} diff --git a/vendor/github.com/ethereum/go-ethereum/rpc/inproc.go b/vendor/github.com/ethereum/go-ethereum/rpc/inproc.go new file mode 100644 index 000000000..f72b97497 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/rpc/inproc.go @@ -0,0 +1,34 @@ +// Copyright 2016 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package rpc + +import ( + "net" + + "golang.org/x/net/context" +) + +// NewInProcClient attaches an in-process connection to the given RPC server. +func DialInProc(handler *Server) *Client { + initctx := context.Background() + c, _ := newClient(initctx, func(context.Context) (net.Conn, error) { + p1, p2 := net.Pipe() + go handler.ServeCodec(NewJSONCodec(p1), OptionMethodInvocation|OptionSubscriptions) + return p2, nil + }) + return c +} diff --git a/vendor/github.com/ethereum/go-ethereum/rpc/ipc.go b/vendor/github.com/ethereum/go-ethereum/rpc/ipc.go new file mode 100644 index 000000000..c2b9e3871 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/rpc/ipc.go @@ -0,0 +1,55 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package rpc + +import ( + "net" + + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "golang.org/x/net/context" +) + +// CreateIPCListener creates an listener, on Unix platforms this is a unix socket, on +// Windows this is a named pipe +func CreateIPCListener(endpoint string) (net.Listener, error) { + return ipcListen(endpoint) +} + +// ServeListener accepts connections on l, serving JSON-RPC on them. +func (srv *Server) ServeListener(l net.Listener) error { + for { + conn, err := l.Accept() + if err != nil { + return err + } + glog.V(logger.Detail).Infoln("accepted conn", conn.RemoteAddr()) + go srv.ServeCodec(NewJSONCodec(conn), OptionMethodInvocation|OptionSubscriptions) + } +} + +// DialIPC create a new IPC client that connects to the given endpoint. On Unix it assumes +// the endpoint is the full path to a unix socket, and Windows the endpoint is an +// identifier for a named pipe. +// +// The context is used for the initial connection establishment. It does not +// affect subsequent interactions with the client. +func DialIPC(ctx context.Context, endpoint string) (*Client, error) { + return newClient(ctx, func(ctx context.Context) (net.Conn, error) { + return newIPCConnection(ctx, endpoint) + }) +} diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/ipc_unix.go b/vendor/github.com/ethereum/go-ethereum/rpc/ipc_unix.go similarity index 90% rename from src/vendor/github.com/ethereum/go-ethereum/rpc/ipc_unix.go rename to vendor/github.com/ethereum/go-ethereum/rpc/ipc_unix.go index 9ece01240..a25b21627 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/ipc_unix.go +++ b/vendor/github.com/ethereum/go-ethereum/rpc/ipc_unix.go @@ -22,6 +22,8 @@ import ( "net" "os" "path/filepath" + + "golang.org/x/net/context" ) // ipcListen will create a Unix socket on the given endpoint. @@ -40,6 +42,6 @@ func ipcListen(endpoint string) (net.Listener, error) { } // newIPCConnection will connect to a Unix socket on the given endpoint. -func newIPCConnection(endpoint string) (net.Conn, error) { - return net.DialUnix("unix", nil, &net.UnixAddr{Name: endpoint, Net: "unix"}) +func newIPCConnection(ctx context.Context, endpoint string) (net.Conn, error) { + return dialContext(ctx, "unix", endpoint) } diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/ipc_windows.go b/vendor/github.com/ethereum/go-ethereum/rpc/ipc_windows.go similarity index 70% rename from src/vendor/github.com/ethereum/go-ethereum/rpc/ipc_windows.go rename to vendor/github.com/ethereum/go-ethereum/rpc/ipc_windows.go index 8342d04d5..68234d215 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/ipc_windows.go +++ b/vendor/github.com/ethereum/go-ethereum/rpc/ipc_windows.go @@ -22,16 +22,27 @@ import ( "net" "time" + "golang.org/x/net/context" "gopkg.in/natefinch/npipe.v2" ) +// This is used if the dialing context has no deadline. It is much smaller than the +// defaultDialTimeout because named pipes are local and there is no need to wait so long. +const defaultPipeDialTimeout = 2 * time.Second + // ipcListen will create a named pipe on the given endpoint. func ipcListen(endpoint string) (net.Listener, error) { return npipe.Listen(endpoint) } // newIPCConnection will connect to a named pipe with the given endpoint as name. -func newIPCConnection(endpoint string) (net.Conn, error) { - timeout := 5 * time.Second +func newIPCConnection(ctx context.Context, endpoint string) (net.Conn, error) { + timeout := defaultPipeDialTimeout + if deadline, ok := ctx.Deadline(); ok { + timeout = deadline.Sub(time.Now()) + if timeout < 0 { + timeout = 0 + } + } return npipe.DialTimeout(endpoint, timeout) } diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/json.go b/vendor/github.com/ethereum/go-ethereum/rpc/json.go similarity index 87% rename from src/vendor/github.com/ethereum/go-ethereum/rpc/json.go rename to vendor/github.com/ethereum/go-ethereum/rpc/json.go index 151ed546e..a7053e3f5 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/json.go +++ b/vendor/github.com/ethereum/go-ethereum/rpc/json.go @@ -30,49 +30,43 @@ import ( ) const ( - JSONRPCVersion = "2.0" + jsonrpcVersion = "2.0" serviceMethodSeparator = "_" subscribeMethod = "eth_subscribe" unsubscribeMethod = "eth_unsubscribe" notificationMethod = "eth_subscription" ) -// JSON-RPC request -type JSONRequest struct { +type jsonRequest struct { Method string `json:"method"` Version string `json:"jsonrpc"` Id json.RawMessage `json:"id,omitempty"` Payload json.RawMessage `json:"params,omitempty"` } -// JSON-RPC response -type JSONSuccessResponse struct { +type jsonSuccessResponse struct { Version string `json:"jsonrpc"` Id interface{} `json:"id,omitempty"` Result interface{} `json:"result"` } -// JSON-RPC error object -type JSONError struct { +type jsonError struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` } -// JSON-RPC error response -type JSONErrResponse struct { +type jsonErrResponse struct { Version string `json:"jsonrpc"` Id interface{} `json:"id,omitempty"` - Error JSONError `json:"error"` + Error jsonError `json:"error"` } -// JSON-RPC notification payload type jsonSubscription struct { Subscription string `json:"subscription"` Result interface{} `json:"result,omitempty"` } -// JSON-RPC notification type jsonNotification struct { Version string `json:"jsonrpc"` Method string `json:"method"` @@ -91,6 +85,17 @@ type jsonCodec struct { rw io.ReadWriteCloser // connection } +func (err *jsonError) Error() string { + if err.Message == "" { + return fmt.Sprintf("json-rpc error %d", err.Code) + } + return err.Message +} + +func (err *jsonError) ErrorCode() int { + return err.Code +} + // NewJSONCodec creates a new RPC server codec with support for JSON-RPC 2.0 func NewJSONCodec(rwc io.ReadWriteCloser) ServerCodec { d := json.NewDecoder(rwc) @@ -113,7 +118,7 @@ func isBatch(msg json.RawMessage) bool { // ReadRequestHeaders will read new requests without parsing the arguments. It will // return a collection of requests, an indication if these requests are in batch // form or an error when the incoming message could not be read/parsed. -func (c *jsonCodec) ReadRequestHeaders() ([]rpcRequest, bool, RPCError) { +func (c *jsonCodec) ReadRequestHeaders() ([]rpcRequest, bool, Error) { c.decMu.Lock() defer c.decMu.Unlock() @@ -148,8 +153,8 @@ func checkReqId(reqId json.RawMessage) error { // parseRequest will parse a single request from the given RawMessage. It will return // the parsed request, an indication if the request was a batch or an error when // the request could not be parsed. -func parseRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, RPCError) { - var in JSONRequest +func parseRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, Error) { + var in jsonRequest if err := json.Unmarshal(incomingMsg, &in); err != nil { return nil, false, &invalidMessageError{err.Error()} } @@ -182,12 +187,12 @@ func parseRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, RPCError) { method: unsubscribeMethod, params: in.Payload}}, false, nil } - // regular RPC call elems := strings.Split(in.Method, serviceMethodSeparator) if len(elems) != 2 { return nil, false, &methodNotFoundError{in.Method, ""} } + // regular RPC call if len(in.Payload) == 0 { return []rpcRequest{rpcRequest{service: elems[0], method: elems[1], id: &in.Id}}, false, nil } @@ -197,8 +202,8 @@ func parseRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, RPCError) { // parseBatchRequest will parse a batch request into a collection of requests from the given RawMessage, an indication // if the request was a batch or an error when the request could not be read. -func parseBatchRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, RPCError) { - var in []JSONRequest +func parseBatchRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, Error) { + var in []jsonRequest if err := json.Unmarshal(incomingMsg, &in); err != nil { return nil, false, &invalidMessageError{err.Error()} } @@ -236,15 +241,15 @@ func parseBatchRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, RPCErro continue } - elems := strings.Split(r.Method, serviceMethodSeparator) - if len(elems) != 2 { - return nil, true, &methodNotFoundError{r.Method, ""} - } - if len(r.Payload) == 0 { - requests[i] = rpcRequest{service: elems[0], method: elems[1], id: id, params: nil} + requests[i] = rpcRequest{id: id, params: nil} } else { - requests[i] = rpcRequest{service: elems[0], method: elems[1], id: id, params: r.Payload} + requests[i] = rpcRequest{id: id, params: r.Payload} + } + if elem := strings.Split(r.Method, serviceMethodSeparator); len(elem) == 2 { + requests[i].service, requests[i].method = elem[0], elem[1] + } else { + requests[i].err = &methodNotFoundError{r.Method, ""} } } @@ -253,7 +258,7 @@ func parseBatchRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, RPCErro // ParseRequestArguments tries to parse the given params (json.RawMessage) with the given types. It returns the parsed // values or an error when the parsing failed. -func (c *jsonCodec) ParseRequestArguments(argTypes []reflect.Type, params interface{}) ([]reflect.Value, RPCError) { +func (c *jsonCodec) ParseRequestArguments(argTypes []reflect.Type, params interface{}) ([]reflect.Value, Error) { if args, ok := params.(json.RawMessage); !ok { return nil, &invalidParamsError{"Invalid params supplied"} } else { @@ -264,7 +269,7 @@ func (c *jsonCodec) ParseRequestArguments(argTypes []reflect.Type, params interf // parsePositionalArguments tries to parse the given args to an array of values with the given types. // It returns the parsed values or an error when the args could not be parsed. Missing optional arguments // are returned as reflect.Zero values. -func parsePositionalArguments(args json.RawMessage, callbackArgs []reflect.Type) ([]reflect.Value, RPCError) { +func parsePositionalArguments(args json.RawMessage, callbackArgs []reflect.Type) ([]reflect.Value, Error) { params := make([]interface{}, 0, len(callbackArgs)) for _, t := range callbackArgs { params = append(params, reflect.New(t).Interface()) @@ -302,31 +307,31 @@ func parsePositionalArguments(args json.RawMessage, callbackArgs []reflect.Type) // CreateResponse will create a JSON-RPC success response with the given id and reply as result. func (c *jsonCodec) CreateResponse(id interface{}, reply interface{}) interface{} { if isHexNum(reflect.TypeOf(reply)) { - return &JSONSuccessResponse{Version: JSONRPCVersion, Id: id, Result: fmt.Sprintf(`%#x`, reply)} + return &jsonSuccessResponse{Version: jsonrpcVersion, Id: id, Result: fmt.Sprintf(`%#x`, reply)} } - return &JSONSuccessResponse{Version: JSONRPCVersion, Id: id, Result: reply} + return &jsonSuccessResponse{Version: jsonrpcVersion, Id: id, Result: reply} } // CreateErrorResponse will create a JSON-RPC error response with the given id and error. -func (c *jsonCodec) CreateErrorResponse(id interface{}, err RPCError) interface{} { - return &JSONErrResponse{Version: JSONRPCVersion, Id: id, Error: JSONError{Code: err.Code(), Message: err.Error()}} +func (c *jsonCodec) CreateErrorResponse(id interface{}, err Error) interface{} { + return &jsonErrResponse{Version: jsonrpcVersion, Id: id, Error: jsonError{Code: err.ErrorCode(), Message: err.Error()}} } // CreateErrorResponseWithInfo will create a JSON-RPC error response with the given id and error. // info is optional and contains additional information about the error. When an empty string is passed it is ignored. -func (c *jsonCodec) CreateErrorResponseWithInfo(id interface{}, err RPCError, info interface{}) interface{} { - return &JSONErrResponse{Version: JSONRPCVersion, Id: id, - Error: JSONError{Code: err.Code(), Message: err.Error(), Data: info}} +func (c *jsonCodec) CreateErrorResponseWithInfo(id interface{}, err Error, info interface{}) interface{} { + return &jsonErrResponse{Version: jsonrpcVersion, Id: id, + Error: jsonError{Code: err.ErrorCode(), Message: err.Error(), Data: info}} } // CreateNotification will create a JSON-RPC notification with the given subscription id and event as params. func (c *jsonCodec) CreateNotification(subid string, event interface{}) interface{} { if isHexNum(reflect.TypeOf(event)) { - return &jsonNotification{Version: JSONRPCVersion, Method: notificationMethod, + return &jsonNotification{Version: jsonrpcVersion, Method: notificationMethod, Params: jsonSubscription{Subscription: subid, Result: fmt.Sprintf(`%#x`, event)}} } - return &jsonNotification{Version: JSONRPCVersion, Method: notificationMethod, + return &jsonNotification{Version: jsonrpcVersion, Method: notificationMethod, Params: jsonSubscription{Subscription: subid, Result: event}} } diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/server.go b/vendor/github.com/ethereum/go-ethereum/rpc/server.go similarity index 95% rename from src/vendor/github.com/ethereum/go-ethereum/rpc/server.go rename to vendor/github.com/ethereum/go-ethereum/rpc/server.go index ce820fef9..f7dddded7 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/server.go +++ b/vendor/github.com/ethereum/go-ethereum/rpc/server.go @@ -21,7 +21,6 @@ import ( "reflect" "runtime" "sync/atomic" - "time" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" @@ -30,8 +29,6 @@ import ( ) const ( - stopPendingRequestTimeout = 3 * time.Second // give pending requests stopPendingRequestTimeout the time to finish when the server is stopped - notificationBufferSize = 10000 // max buffered notifications before codec is closed MetadataApi = "rpc" @@ -169,7 +166,7 @@ func (s *Server) serveRequest(codec ServerCodec, singleShot bool, options CodecO // to send notification to clients. It is thight to the codec/connection. If the // connection is closed the notifier will stop and cancels all active subscriptions. if options&OptionSubscriptions == OptionSubscriptions { - ctx = context.WithValue(ctx, notifierKey{}, newBufferedNotifier(codec, notificationBufferSize)) + ctx = context.WithValue(ctx, notifierKey{}, newNotifier(codec)) } s.codecsMu.Lock() if atomic.LoadInt32(&s.run) != 1 { // server stopped @@ -183,7 +180,7 @@ func (s *Server) serveRequest(codec ServerCodec, singleShot bool, options CodecO for atomic.LoadInt32(&s.run) == 1 { reqs, batch, err := s.readRequest(codec) if err != nil { - glog.V(logger.Debug).Infof("%v\n", err) + glog.V(logger.Debug).Infof("read error %v\n", err) codec.Write(codec.CreateErrorResponse(nil, err)) return nil } @@ -240,19 +237,17 @@ func (s *Server) ServeSingleRequest(codec ServerCodec, options CodecOption) { func (s *Server) Stop() { if atomic.CompareAndSwapInt32(&s.run, 1, 0) { glog.V(logger.Debug).Infoln("RPC Server shutdown initiatied") - time.AfterFunc(stopPendingRequestTimeout, func() { - s.codecsMu.Lock() - defer s.codecsMu.Unlock() - s.codecs.Each(func(c interface{}) bool { - c.(ServerCodec).Close() - return true - }) + s.codecsMu.Lock() + defer s.codecsMu.Unlock() + s.codecs.Each(func(c interface{}) bool { + c.(ServerCodec).Close() + return true }) } } // createSubscription will call the subscription callback and returns the subscription id or error. -func (s *Server) createSubscription(ctx context.Context, c ServerCodec, req *serverRequest) (string, error) { +func (s *Server) createSubscription(ctx context.Context, c ServerCodec, req *serverRequest) (ID, error) { // subscription have as first argument the context following optional arguments args := []reflect.Value{req.callb.rcvr, reflect.ValueOf(ctx)} args = append(args, req.args...) @@ -262,7 +257,7 @@ func (s *Server) createSubscription(ctx context.Context, c ServerCodec, req *ser return "", reply[1].Interface().(error) } - return reply[0].Interface().(Subscription).ID(), nil + return reply[0].Interface().(*Subscription).ID, nil } // handle executes a request and returns the response from the callback. @@ -278,8 +273,8 @@ func (s *Server) handle(ctx context.Context, codec ServerCodec, req *serverReque return codec.CreateErrorResponse(&req.id, &callbackError{ErrNotificationsUnsupported.Error()}), nil } - subid := req.args[0].String() - if err := notifier.Unsubscribe(subid); err != nil { + subid := ID(req.args[0].String()) + if err := notifier.unsubscribe(subid); err != nil { return codec.CreateErrorResponse(&req.id, &callbackError{err.Error()}), nil } @@ -297,7 +292,7 @@ func (s *Server) handle(ctx context.Context, codec ServerCodec, req *serverReque // active the subscription after the sub id was successfully sent to the client activateSub := func() { notifier, _ := NotifierFromContext(ctx) - notifier.(*bufferedNotifier).activate(subid) + notifier.activate(subid) } return codec.CreateResponse(req.id, subid), activateSub @@ -398,7 +393,7 @@ fmt.Println()*/ // readRequest requests the next (batch) request from the codec. It will return the collection // of requests, an indication if the request was a batch, the invalid request identifier and an // error when the request could not be read/parsed. -func (s *Server) readRequest(codec ServerCodec) ([]*serverRequest, bool, RPCError) { +func (s *Server) readRequest(codec ServerCodec) ([]*serverRequest, bool, Error) { reqs, batch, err := codec.ReadRequestHeaders() if err != nil { return nil, batch, err @@ -415,6 +410,11 @@ fmt.Println(r)*/ var ok bool var svc *service + if r.err != nil { + requests[i] = &serverRequest{id: r.id, err: r.err} + continue + } + if r.isPubSub && r.method == unsubscribeMethod { requests[i] = &serverRequest{id: r.id, isUnsubscribe: true} argTypes := []reflect.Type{reflect.TypeOf("")} // expect subscription id as first arg diff --git a/vendor/github.com/ethereum/go-ethereum/rpc/subscription.go b/vendor/github.com/ethereum/go-ethereum/rpc/subscription.go new file mode 100644 index 000000000..863d34b20 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/rpc/subscription.go @@ -0,0 +1,135 @@ +// Copyright 2016 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package rpc + +import ( + "errors" + "sync" + + "golang.org/x/net/context" +) + +var ( + // ErrNotificationsUnsupported is returned when the connection doesn't support notifications + ErrNotificationsUnsupported = errors.New("notifications not supported") + // ErrNotificationNotFound is returned when the notification for the given id is not found + ErrSubscriptionNotFound = errors.New("subscription not found") +) + +// ID defines a psuedo random number that is used to identify RPC subscriptions. +type ID string + +// a Subscription is created by a notifier and tight to that notifier. The client can use +// this subscription to wait for an unsubscribe request for the client, see Err(). +type Subscription struct { + ID ID + err chan error // closed on unsubscribe +} + +// Err returns a channel that is closed when the client send an unsubscribe request. +func (s *Subscription) Err() <-chan error { + return s.err +} + +// notifierKey is used to store a notifier within the connection context. +type notifierKey struct{} + +// Notifier is tight to a RPC connection that supports subscriptions. +// Server callbacks use the notifier to send notifications. +type Notifier struct { + codec ServerCodec + subMu sync.RWMutex // guards active and inactive maps + stopped bool + active map[ID]*Subscription + inactive map[ID]*Subscription +} + +// newNotifier creates a new notifier that can be used to send subscription +// notifications to the client. +func newNotifier(codec ServerCodec) *Notifier { + return &Notifier{ + codec: codec, + active: make(map[ID]*Subscription), + inactive: make(map[ID]*Subscription), + } +} + +// NotifierFromContext returns the Notifier value stored in ctx, if any. +func NotifierFromContext(ctx context.Context) (*Notifier, bool) { + n, ok := ctx.Value(notifierKey{}).(*Notifier) + return n, ok +} + +// CreateSubscription returns a new subscription that is coupled to the +// RPC connection. By default subscriptions are inactive and notifications +// are dropped until the subscription is marked as active. This is done +// by the RPC server after the subscription ID is send to the client. +func (n *Notifier) CreateSubscription() *Subscription { + s := &Subscription{NewID(), make(chan error)} + n.subMu.Lock() + n.inactive[s.ID] = s + n.subMu.Unlock() + return s +} + +// Notify sends a notification to the client with the given data as payload. +// If an error occurs the RPC connection is closed and the error is returned. +func (n *Notifier) Notify(id ID, data interface{}) error { + n.subMu.RLock() + defer n.subMu.RUnlock() + + _, active := n.active[id] + if active { + notification := n.codec.CreateNotification(string(id), data) + if err := n.codec.Write(notification); err != nil { + n.codec.Close() + return err + } + } + return nil +} + +// Closed returns a channel that is closed when the RPC connection is closed. +func (n *Notifier) Closed() <-chan interface{} { + return n.codec.Closed() +} + +// unsubscribe a subscription. +// If the subscription could not be found ErrSubscriptionNotFound is returned. +func (n *Notifier) unsubscribe(id ID) error { + n.subMu.Lock() + defer n.subMu.Unlock() + if s, found := n.active[id]; found { + close(s.err) + delete(n.active, id) + return nil + } + return ErrSubscriptionNotFound +} + +// activate enables a subscription. Until a subscription is enabled all +// notifications are dropped. This method is called by the RPC server after +// the subscription ID was sent to client. This prevents notifications being +// send to the client before the subscription ID is send to the client. +func (n *Notifier) activate(id ID) { + n.subMu.Lock() + defer n.subMu.Unlock() + if sub, found := n.inactive[id]; found { + n.active[id] = sub + delete(n.inactive, id) + } +} diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/types.go b/vendor/github.com/ethereum/go-ethereum/rpc/types.go similarity index 88% rename from src/vendor/github.com/ethereum/go-ethereum/rpc/types.go rename to vendor/github.com/ethereum/go-ethereum/rpc/types.go index 5c821d41a..e313bcda0 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/types.go +++ b/vendor/github.com/ethereum/go-ethereum/rpc/types.go @@ -62,7 +62,7 @@ type serverRequest struct { callb *callback args []reflect.Value isUnsubscribe bool - err RPCError + err Error } type serviceRegistry map[string]*service // collection of services @@ -88,14 +88,13 @@ type rpcRequest struct { id interface{} isPubSub bool params interface{} + err Error // invalid batch element } -// RPCError implements RPC error, is add support for error codec over regular go errors -type RPCError interface { - // RPC error code - Code() int - // Error message - Error() string +// Error wraps RPC errors, which contain an error code in addition to the message. +type Error interface { + Error() string // returns the message + ErrorCode() int // returns the code } // ServerCodec implements reading, parsing and writing RPC messages for the server side of @@ -103,15 +102,15 @@ type RPCError interface { // multiple go-routines concurrently. type ServerCodec interface { // Read next request - ReadRequestHeaders() ([]rpcRequest, bool, RPCError) + ReadRequestHeaders() ([]rpcRequest, bool, Error) // Parse request argument to the given types - ParseRequestArguments([]reflect.Type, interface{}) ([]reflect.Value, RPCError) + ParseRequestArguments([]reflect.Type, interface{}) ([]reflect.Value, Error) // Assemble success response, expects response id and payload CreateResponse(interface{}, interface{}) interface{} // Assemble error response, expects response id and error - CreateErrorResponse(interface{}, RPCError) interface{} + CreateErrorResponse(interface{}, Error) interface{} // Assemble error response with extra information about the error through info - CreateErrorResponseWithInfo(id interface{}, err RPCError, info interface{}) interface{} + CreateErrorResponseWithInfo(id interface{}, err Error, info interface{}) interface{} // Create notification response CreateNotification(string, interface{}) interface{} // Write msg to client. @@ -270,45 +269,34 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error { return fmt.Errorf("blocknumber not in range [%d, %d]", earliestBlockNumber, maxBlockNumber) } -func (bn *BlockNumber) Int64() int64 { - return (int64)(*bn) -} - -// Client defines the interface for go client that wants to connect to a geth RPC endpoint -type Client interface { - // SupportedModules returns the collection of API's the server offers - SupportedModules() (map[string]string, error) - - Send(req interface{}) error - Recv(msg interface{}) error - - Close() +func (bn BlockNumber) Int64() int64 { + return (int64)(bn) } type ClientRestartWrapper struct { - client Client - newClientFn func() Client - mu sync.RWMutex + client *Client + newClientFn func() *Client + mu sync.RWMutex } -func NewClientRestartWrapper(newClientFn func() Client) *ClientRestartWrapper { - return &ClientRestartWrapper { - client: newClientFn(), +func NewClientRestartWrapper(newClientFn func() *Client) *ClientRestartWrapper { + return &ClientRestartWrapper{ + client: newClientFn(), newClientFn: newClientFn, } } -func (rw *ClientRestartWrapper) Client() Client { +func (rw *ClientRestartWrapper) Client() *Client { rw.mu.RLock() defer rw.mu.RUnlock() - + return rw.client } func (rw *ClientRestartWrapper) Restart() { rw.mu.Lock() defer rw.mu.Unlock() - + rw.client.Close() rw.client = rw.newClientFn() } diff --git a/src/vendor/github.com/ethereum/go-ethereum/rpc/utils.go b/vendor/github.com/ethereum/go-ethereum/rpc/utils.go similarity index 85% rename from src/vendor/github.com/ethereum/go-ethereum/rpc/utils.go rename to vendor/github.com/ethereum/go-ethereum/rpc/utils.go index fe482e19d..b590ba62f 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/rpc/utils.go +++ b/vendor/github.com/ethereum/go-ethereum/rpc/utils.go @@ -17,18 +17,26 @@ package rpc import ( - "crypto/rand" + "bufio" + crand "crypto/rand" + "encoding/binary" "encoding/hex" - "errors" - "fmt" "math/big" + "math/rand" "reflect" + "sync" + "time" "unicode" "unicode/utf8" "golang.org/x/net/context" ) +var ( + subscriptionIDGenMu sync.Mutex + subscriptionIDGen = idGenerator() +) + // Is this an exported - upper case - name? func isExported(name string) bool { rune, _ := utf8.DecodeRuneInString(name) @@ -219,39 +227,28 @@ METHODS: return callbacks, subscriptions } -func newSubscriptionID() (string, error) { - var subid [16]byte - n, _ := rand.Read(subid[:]) - if n != 16 { - return "", errors.New("Unable to generate subscription id") +// idGenerator helper utility that generates a (pseudo) random sequence of +// bytes that are used to generate identifiers. +func idGenerator() *rand.Rand { + if seed, err := binary.ReadVarint(bufio.NewReader(crand.Reader)); err == nil { + return rand.New(rand.NewSource(seed)) } - return "0x" + hex.EncodeToString(subid[:]), nil + return rand.New(rand.NewSource(int64(time.Now().Nanosecond()))) } -// SupportedModules returns the collection of API's that the RPC server offers -// on which the given client connects. -func SupportedModules(client Client) (map[string]string, error) { - req := JSONRequest{ - Id: []byte("1"), - Version: "2.0", - Method: MetadataApi + "_modules", - } - if err := client.Send(req); err != nil { - return nil, err - } +// NewID generates a identifier that can be used as an identifier in the RPC interface. +// e.g. filter and subscription identifier. +func NewID() ID { + subscriptionIDGenMu.Lock() + defer subscriptionIDGenMu.Unlock() - var response JSONSuccessResponse - if err := client.Recv(&response); err != nil { - return nil, err - } - if response.Result != nil { - mods := make(map[string]string) - if modules, ok := response.Result.(map[string]interface{}); ok { - for m, v := range modules { - mods[m] = fmt.Sprintf("%s", v) - } - return mods, nil + id := make([]byte, 16) + for i := 0; i < len(id); i += 7 { + val := subscriptionIDGen.Int63() + for j := 0; i+j < len(id) && j < 7; j++ { + id[i+j] = byte(val) + val >>= 8 } } - return nil, fmt.Errorf("unable to retrieve modules") + return ID("0x" + hex.EncodeToString(id)) } diff --git a/vendor/github.com/ethereum/go-ethereum/rpc/websocket.go b/vendor/github.com/ethereum/go-ethereum/rpc/websocket.go new file mode 100644 index 000000000..fc3cd0709 --- /dev/null +++ b/vendor/github.com/ethereum/go-ethereum/rpc/websocket.go @@ -0,0 +1,152 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package rpc + +import ( + "crypto/tls" + "fmt" + "net" + "net/http" + "net/url" + "os" + "strings" + + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "golang.org/x/net/context" + "golang.org/x/net/websocket" + "gopkg.in/fatih/set.v0" +) + +// WebsocketHandler returns a handler that serves JSON-RPC to WebSocket connections. +// +// allowedOrigins should be a comma-separated list of allowed origin URLs. +// To allow connections with any origin, pass "*". +func (srv *Server) WebsocketHandler(allowedOrigins string) http.Handler { + return websocket.Server{ + Handshake: wsHandshakeValidator(strings.Split(allowedOrigins, ",")), + Handler: func(conn *websocket.Conn) { + srv.ServeCodec(NewJSONCodec(conn), OptionMethodInvocation|OptionSubscriptions) + }, + } +} + +// NewWSServer creates a new websocket RPC server around an API provider. +// +// Deprecated: use Server.WebsocketHandler +func NewWSServer(allowedOrigins string, srv *Server) *http.Server { + return &http.Server{Handler: srv.WebsocketHandler(allowedOrigins)} +} + +// wsHandshakeValidator returns a handler that verifies the origin during the +// websocket upgrade process. When a '*' is specified as an allowed origins all +// connections are accepted. +func wsHandshakeValidator(allowedOrigins []string) func(*websocket.Config, *http.Request) error { + origins := set.New() + allowAllOrigins := false + + for _, origin := range allowedOrigins { + if origin == "*" { + allowAllOrigins = true + } + if origin != "" { + origins.Add(strings.ToLower(origin)) + } + } + + // allow localhost if no allowedOrigins are specified. + if len(origins.List()) == 0 { + origins.Add("http://localhost") + if hostname, err := os.Hostname(); err == nil { + origins.Add("http://" + strings.ToLower(hostname)) + } + } + + glog.V(logger.Debug).Infof("Allowed origin(s) for WS RPC interface %v\n", origins.List()) + + f := func(cfg *websocket.Config, req *http.Request) error { + origin := strings.ToLower(req.Header.Get("Origin")) + if allowAllOrigins || origins.Has(origin) { + return nil + } + glog.V(logger.Debug).Infof("origin '%s' not allowed on WS-RPC interface\n", origin) + return fmt.Errorf("origin %s not allowed", origin) + } + + return f +} + +// DialWebsocket creates a new RPC client that communicates with a JSON-RPC server +// that is listening on the given endpoint. +// +// The context is used for the initial connection establishment. It does not +// affect subsequent interactions with the client. +func DialWebsocket(ctx context.Context, endpoint, origin string) (*Client, error) { + if origin == "" { + var err error + if origin, err = os.Hostname(); err != nil { + return nil, err + } + if strings.HasPrefix(endpoint, "wss") { + origin = "https://" + strings.ToLower(origin) + } else { + origin = "http://" + strings.ToLower(origin) + } + } + config, err := websocket.NewConfig(endpoint, origin) + if err != nil { + return nil, err + } + + return newClient(ctx, func(ctx context.Context) (net.Conn, error) { + return wsDialContext(ctx, config) + }) +} + +func wsDialContext(ctx context.Context, config *websocket.Config) (*websocket.Conn, error) { + var conn net.Conn + var err error + switch config.Location.Scheme { + case "ws": + conn, err = dialContext(ctx, "tcp", wsDialAddress(config.Location)) + case "wss": + dialer := contextDialer(ctx) + conn, err = tls.DialWithDialer(dialer, "tcp", wsDialAddress(config.Location), config.TlsConfig) + default: + err = websocket.ErrBadScheme + } + if err != nil { + return nil, err + } + ws, err := websocket.NewClient(config, conn) + if err != nil { + conn.Close() + return nil, err + } + return ws, err +} + +var wsPortMap = map[string]string{"ws": "80", "wss": "443"} + +func wsDialAddress(location *url.URL) string { + if _, ok := wsPortMap[location.Scheme]; ok { + if _, _, err := net.SplitHostPort(location.Host); err != nil { + return net.JoinHostPort(location.Host, wsPortMap[location.Scheme]) + } + } + return location.Host +} diff --git a/src/vendor/github.com/ethereum/go-ethereum/trie/arc.go b/vendor/github.com/ethereum/go-ethereum/trie/arc.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/trie/arc.go rename to vendor/github.com/ethereum/go-ethereum/trie/arc.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/trie/encoding.go b/vendor/github.com/ethereum/go-ethereum/trie/encoding.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/trie/encoding.go rename to vendor/github.com/ethereum/go-ethereum/trie/encoding.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/trie/errors.go b/vendor/github.com/ethereum/go-ethereum/trie/errors.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/trie/errors.go rename to vendor/github.com/ethereum/go-ethereum/trie/errors.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/trie/iterator.go b/vendor/github.com/ethereum/go-ethereum/trie/iterator.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/trie/iterator.go rename to vendor/github.com/ethereum/go-ethereum/trie/iterator.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/trie/node.go b/vendor/github.com/ethereum/go-ethereum/trie/node.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/trie/node.go rename to vendor/github.com/ethereum/go-ethereum/trie/node.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/trie/proof.go b/vendor/github.com/ethereum/go-ethereum/trie/proof.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/trie/proof.go rename to vendor/github.com/ethereum/go-ethereum/trie/proof.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/trie/secure_trie.go b/vendor/github.com/ethereum/go-ethereum/trie/secure_trie.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/trie/secure_trie.go rename to vendor/github.com/ethereum/go-ethereum/trie/secure_trie.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/trie/sync.go b/vendor/github.com/ethereum/go-ethereum/trie/sync.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/trie/sync.go rename to vendor/github.com/ethereum/go-ethereum/trie/sync.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/trie/trie.go b/vendor/github.com/ethereum/go-ethereum/trie/trie.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/trie/trie.go rename to vendor/github.com/ethereum/go-ethereum/trie/trie.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/whisper/api.go b/vendor/github.com/ethereum/go-ethereum/whisper/api.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/whisper/api.go rename to vendor/github.com/ethereum/go-ethereum/whisper/api.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/whisper/doc.go b/vendor/github.com/ethereum/go-ethereum/whisper/doc.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/whisper/doc.go rename to vendor/github.com/ethereum/go-ethereum/whisper/doc.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/whisper/envelope.go b/vendor/github.com/ethereum/go-ethereum/whisper/envelope.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/whisper/envelope.go rename to vendor/github.com/ethereum/go-ethereum/whisper/envelope.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/whisper/filter.go b/vendor/github.com/ethereum/go-ethereum/whisper/filter.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/whisper/filter.go rename to vendor/github.com/ethereum/go-ethereum/whisper/filter.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/whisper/main.go b/vendor/github.com/ethereum/go-ethereum/whisper/main.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/whisper/main.go rename to vendor/github.com/ethereum/go-ethereum/whisper/main.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/whisper/message.go b/vendor/github.com/ethereum/go-ethereum/whisper/message.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/whisper/message.go rename to vendor/github.com/ethereum/go-ethereum/whisper/message.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/whisper/peer.go b/vendor/github.com/ethereum/go-ethereum/whisper/peer.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/whisper/peer.go rename to vendor/github.com/ethereum/go-ethereum/whisper/peer.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/whisper/topic.go b/vendor/github.com/ethereum/go-ethereum/whisper/topic.go similarity index 100% rename from src/vendor/github.com/ethereum/go-ethereum/whisper/topic.go rename to vendor/github.com/ethereum/go-ethereum/whisper/topic.go diff --git a/src/vendor/github.com/ethereum/go-ethereum/whisper/whisper.go b/vendor/github.com/ethereum/go-ethereum/whisper/whisper.go similarity index 97% rename from src/vendor/github.com/ethereum/go-ethereum/whisper/whisper.go rename to vendor/github.com/ethereum/go-ethereum/whisper/whisper.go index 68008ad8d..91cfc9b6e 100644 --- a/src/vendor/github.com/ethereum/go-ethereum/whisper/whisper.go +++ b/vendor/github.com/ethereum/go-ethereum/whisper/whisper.go @@ -165,8 +165,11 @@ func (self *Whisper) InjectIdentity(key *ecdsa.PrivateKey) error { self.keys = make(map[string]*ecdsa.PrivateKey) // reset key store self.keys[string(crypto.FromECDSAPub(&key.PublicKey))] = key self.keysMu.Unlock() + if _, ok := self.keys[string(crypto.FromECDSAPub(&key.PublicKey))]; !ok { + return fmt.Errorf("key insert into keys map failed") + } - fmt.Printf("Injected identity into whisper: %s\n", common.ToHex(crypto.FromECDSAPub(&key.PublicKey))) + glog.V(logger.Info).Infof("Injected identity into whisper: %s\n", common.ToHex(crypto.FromECDSAPub(&key.PublicKey))) return nil } diff --git a/src/vendor/github.com/golang/snappy/.gitignore b/vendor/github.com/golang/snappy/.gitignore similarity index 100% rename from src/vendor/github.com/golang/snappy/.gitignore rename to vendor/github.com/golang/snappy/.gitignore diff --git a/src/vendor/github.com/golang/snappy/AUTHORS b/vendor/github.com/golang/snappy/AUTHORS similarity index 100% rename from src/vendor/github.com/golang/snappy/AUTHORS rename to vendor/github.com/golang/snappy/AUTHORS diff --git a/src/vendor/github.com/golang/snappy/CONTRIBUTORS b/vendor/github.com/golang/snappy/CONTRIBUTORS similarity index 100% rename from src/vendor/github.com/golang/snappy/CONTRIBUTORS rename to vendor/github.com/golang/snappy/CONTRIBUTORS diff --git a/src/vendor/github.com/golang/snappy/LICENSE b/vendor/github.com/golang/snappy/LICENSE similarity index 100% rename from src/vendor/github.com/golang/snappy/LICENSE rename to vendor/github.com/golang/snappy/LICENSE diff --git a/src/vendor/github.com/golang/snappy/README b/vendor/github.com/golang/snappy/README similarity index 100% rename from src/vendor/github.com/golang/snappy/README rename to vendor/github.com/golang/snappy/README diff --git a/src/vendor/github.com/golang/snappy/decode.go b/vendor/github.com/golang/snappy/decode.go similarity index 100% rename from src/vendor/github.com/golang/snappy/decode.go rename to vendor/github.com/golang/snappy/decode.go diff --git a/src/vendor/github.com/golang/snappy/decode_amd64.go b/vendor/github.com/golang/snappy/decode_amd64.go similarity index 100% rename from src/vendor/github.com/golang/snappy/decode_amd64.go rename to vendor/github.com/golang/snappy/decode_amd64.go diff --git a/src/vendor/github.com/golang/snappy/decode_amd64.s b/vendor/github.com/golang/snappy/decode_amd64.s similarity index 100% rename from src/vendor/github.com/golang/snappy/decode_amd64.s rename to vendor/github.com/golang/snappy/decode_amd64.s diff --git a/src/vendor/github.com/golang/snappy/decode_other.go b/vendor/github.com/golang/snappy/decode_other.go similarity index 100% rename from src/vendor/github.com/golang/snappy/decode_other.go rename to vendor/github.com/golang/snappy/decode_other.go diff --git a/src/vendor/github.com/golang/snappy/encode.go b/vendor/github.com/golang/snappy/encode.go similarity index 100% rename from src/vendor/github.com/golang/snappy/encode.go rename to vendor/github.com/golang/snappy/encode.go diff --git a/src/vendor/github.com/golang/snappy/encode_amd64.go b/vendor/github.com/golang/snappy/encode_amd64.go similarity index 100% rename from src/vendor/github.com/golang/snappy/encode_amd64.go rename to vendor/github.com/golang/snappy/encode_amd64.go diff --git a/src/vendor/github.com/golang/snappy/encode_amd64.s b/vendor/github.com/golang/snappy/encode_amd64.s similarity index 100% rename from src/vendor/github.com/golang/snappy/encode_amd64.s rename to vendor/github.com/golang/snappy/encode_amd64.s diff --git a/src/vendor/github.com/golang/snappy/encode_other.go b/vendor/github.com/golang/snappy/encode_other.go similarity index 100% rename from src/vendor/github.com/golang/snappy/encode_other.go rename to vendor/github.com/golang/snappy/encode_other.go diff --git a/src/vendor/github.com/golang/snappy/snappy.go b/vendor/github.com/golang/snappy/snappy.go similarity index 100% rename from src/vendor/github.com/golang/snappy/snappy.go rename to vendor/github.com/golang/snappy/snappy.go diff --git a/src/vendor/github.com/hashicorp/golang-lru/.gitignore b/vendor/github.com/hashicorp/golang-lru/.gitignore similarity index 100% rename from src/vendor/github.com/hashicorp/golang-lru/.gitignore rename to vendor/github.com/hashicorp/golang-lru/.gitignore diff --git a/src/vendor/github.com/hashicorp/golang-lru/2q.go b/vendor/github.com/hashicorp/golang-lru/2q.go similarity index 100% rename from src/vendor/github.com/hashicorp/golang-lru/2q.go rename to vendor/github.com/hashicorp/golang-lru/2q.go diff --git a/src/vendor/github.com/hashicorp/golang-lru/LICENSE b/vendor/github.com/hashicorp/golang-lru/LICENSE similarity index 100% rename from src/vendor/github.com/hashicorp/golang-lru/LICENSE rename to vendor/github.com/hashicorp/golang-lru/LICENSE diff --git a/src/vendor/github.com/hashicorp/golang-lru/README.md b/vendor/github.com/hashicorp/golang-lru/README.md similarity index 100% rename from src/vendor/github.com/hashicorp/golang-lru/README.md rename to vendor/github.com/hashicorp/golang-lru/README.md diff --git a/src/vendor/github.com/hashicorp/golang-lru/arc.go b/vendor/github.com/hashicorp/golang-lru/arc.go similarity index 100% rename from src/vendor/github.com/hashicorp/golang-lru/arc.go rename to vendor/github.com/hashicorp/golang-lru/arc.go diff --git a/src/vendor/github.com/hashicorp/golang-lru/lru.go b/vendor/github.com/hashicorp/golang-lru/lru.go similarity index 100% rename from src/vendor/github.com/hashicorp/golang-lru/lru.go rename to vendor/github.com/hashicorp/golang-lru/lru.go diff --git a/src/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go b/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go similarity index 100% rename from src/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go rename to vendor/github.com/hashicorp/golang-lru/simplelru/lru.go diff --git a/src/vendor/github.com/huin/goupnp/.gitignore b/vendor/github.com/huin/goupnp/.gitignore similarity index 100% rename from src/vendor/github.com/huin/goupnp/.gitignore rename to vendor/github.com/huin/goupnp/.gitignore diff --git a/src/vendor/github.com/huin/goupnp/LICENSE b/vendor/github.com/huin/goupnp/LICENSE similarity index 100% rename from src/vendor/github.com/huin/goupnp/LICENSE rename to vendor/github.com/huin/goupnp/LICENSE diff --git a/src/vendor/github.com/huin/goupnp/README.md b/vendor/github.com/huin/goupnp/README.md similarity index 100% rename from src/vendor/github.com/huin/goupnp/README.md rename to vendor/github.com/huin/goupnp/README.md diff --git a/src/vendor/github.com/huin/goupnp/dcps/internetgateway1/internetgateway1.go b/vendor/github.com/huin/goupnp/dcps/internetgateway1/internetgateway1.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/dcps/internetgateway1/internetgateway1.go rename to vendor/github.com/huin/goupnp/dcps/internetgateway1/internetgateway1.go diff --git a/src/vendor/github.com/huin/goupnp/dcps/internetgateway2/internetgateway2.go b/vendor/github.com/huin/goupnp/dcps/internetgateway2/internetgateway2.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/dcps/internetgateway2/internetgateway2.go rename to vendor/github.com/huin/goupnp/dcps/internetgateway2/internetgateway2.go diff --git a/src/vendor/github.com/huin/goupnp/device.go b/vendor/github.com/huin/goupnp/device.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/device.go rename to vendor/github.com/huin/goupnp/device.go diff --git a/src/vendor/github.com/huin/goupnp/goupnp.go b/vendor/github.com/huin/goupnp/goupnp.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/goupnp.go rename to vendor/github.com/huin/goupnp/goupnp.go diff --git a/src/vendor/github.com/huin/goupnp/httpu/httpu.go b/vendor/github.com/huin/goupnp/httpu/httpu.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/httpu/httpu.go rename to vendor/github.com/huin/goupnp/httpu/httpu.go diff --git a/src/vendor/github.com/huin/goupnp/httpu/serve.go b/vendor/github.com/huin/goupnp/httpu/serve.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/httpu/serve.go rename to vendor/github.com/huin/goupnp/httpu/serve.go diff --git a/src/vendor/github.com/huin/goupnp/scpd/scpd.go b/vendor/github.com/huin/goupnp/scpd/scpd.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/scpd/scpd.go rename to vendor/github.com/huin/goupnp/scpd/scpd.go diff --git a/src/vendor/github.com/huin/goupnp/service_client.go b/vendor/github.com/huin/goupnp/service_client.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/service_client.go rename to vendor/github.com/huin/goupnp/service_client.go diff --git a/src/vendor/github.com/huin/goupnp/soap/soap.go b/vendor/github.com/huin/goupnp/soap/soap.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/soap/soap.go rename to vendor/github.com/huin/goupnp/soap/soap.go diff --git a/src/vendor/github.com/huin/goupnp/soap/types.go b/vendor/github.com/huin/goupnp/soap/types.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/soap/types.go rename to vendor/github.com/huin/goupnp/soap/types.go diff --git a/src/vendor/github.com/huin/goupnp/ssdp/registry.go b/vendor/github.com/huin/goupnp/ssdp/registry.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/ssdp/registry.go rename to vendor/github.com/huin/goupnp/ssdp/registry.go diff --git a/src/vendor/github.com/huin/goupnp/ssdp/ssdp.go b/vendor/github.com/huin/goupnp/ssdp/ssdp.go similarity index 100% rename from src/vendor/github.com/huin/goupnp/ssdp/ssdp.go rename to vendor/github.com/huin/goupnp/ssdp/ssdp.go diff --git a/src/vendor/github.com/jackpal/go-nat-pmp/.travis.yml b/vendor/github.com/jackpal/go-nat-pmp/.travis.yml similarity index 100% rename from src/vendor/github.com/jackpal/go-nat-pmp/.travis.yml rename to vendor/github.com/jackpal/go-nat-pmp/.travis.yml diff --git a/src/vendor/github.com/jackpal/go-nat-pmp/LICENSE b/vendor/github.com/jackpal/go-nat-pmp/LICENSE similarity index 100% rename from src/vendor/github.com/jackpal/go-nat-pmp/LICENSE rename to vendor/github.com/jackpal/go-nat-pmp/LICENSE diff --git a/src/vendor/github.com/jackpal/go-nat-pmp/README.md b/vendor/github.com/jackpal/go-nat-pmp/README.md similarity index 100% rename from src/vendor/github.com/jackpal/go-nat-pmp/README.md rename to vendor/github.com/jackpal/go-nat-pmp/README.md diff --git a/src/vendor/github.com/jackpal/go-nat-pmp/natpmp.go b/vendor/github.com/jackpal/go-nat-pmp/natpmp.go similarity index 100% rename from src/vendor/github.com/jackpal/go-nat-pmp/natpmp.go rename to vendor/github.com/jackpal/go-nat-pmp/natpmp.go diff --git a/src/vendor/github.com/jackpal/go-nat-pmp/network.go b/vendor/github.com/jackpal/go-nat-pmp/network.go similarity index 100% rename from src/vendor/github.com/jackpal/go-nat-pmp/network.go rename to vendor/github.com/jackpal/go-nat-pmp/network.go diff --git a/src/vendor/github.com/jackpal/go-nat-pmp/recorder.go b/vendor/github.com/jackpal/go-nat-pmp/recorder.go similarity index 100% rename from src/vendor/github.com/jackpal/go-nat-pmp/recorder.go rename to vendor/github.com/jackpal/go-nat-pmp/recorder.go diff --git a/src/vendor/github.com/microsoft/go-winio/.gitignore b/vendor/github.com/microsoft/go-winio/.gitignore similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/.gitignore rename to vendor/github.com/microsoft/go-winio/.gitignore diff --git a/src/vendor/github.com/microsoft/go-winio/LICENSE b/vendor/github.com/microsoft/go-winio/LICENSE similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/LICENSE rename to vendor/github.com/microsoft/go-winio/LICENSE diff --git a/src/vendor/github.com/microsoft/go-winio/README.md b/vendor/github.com/microsoft/go-winio/README.md similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/README.md rename to vendor/github.com/microsoft/go-winio/README.md diff --git a/src/vendor/github.com/microsoft/go-winio/backup.go b/vendor/github.com/microsoft/go-winio/backup.go similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/backup.go rename to vendor/github.com/microsoft/go-winio/backup.go diff --git a/src/vendor/github.com/microsoft/go-winio/file.go b/vendor/github.com/microsoft/go-winio/file.go similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/file.go rename to vendor/github.com/microsoft/go-winio/file.go diff --git a/src/vendor/github.com/microsoft/go-winio/fileinfo.go b/vendor/github.com/microsoft/go-winio/fileinfo.go similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/fileinfo.go rename to vendor/github.com/microsoft/go-winio/fileinfo.go diff --git a/src/vendor/github.com/microsoft/go-winio/pipe.go b/vendor/github.com/microsoft/go-winio/pipe.go similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/pipe.go rename to vendor/github.com/microsoft/go-winio/pipe.go diff --git a/src/vendor/github.com/microsoft/go-winio/privilege.go b/vendor/github.com/microsoft/go-winio/privilege.go similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/privilege.go rename to vendor/github.com/microsoft/go-winio/privilege.go diff --git a/src/vendor/github.com/microsoft/go-winio/reparse.go b/vendor/github.com/microsoft/go-winio/reparse.go similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/reparse.go rename to vendor/github.com/microsoft/go-winio/reparse.go diff --git a/src/vendor/github.com/microsoft/go-winio/sd.go b/vendor/github.com/microsoft/go-winio/sd.go similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/sd.go rename to vendor/github.com/microsoft/go-winio/sd.go diff --git a/src/vendor/github.com/microsoft/go-winio/syscall.go b/vendor/github.com/microsoft/go-winio/syscall.go similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/syscall.go rename to vendor/github.com/microsoft/go-winio/syscall.go diff --git a/src/vendor/github.com/microsoft/go-winio/zsyscall.go b/vendor/github.com/microsoft/go-winio/zsyscall.go similarity index 100% rename from src/vendor/github.com/microsoft/go-winio/zsyscall.go rename to vendor/github.com/microsoft/go-winio/zsyscall.go diff --git a/src/vendor/github.com/pborman/uuid/.travis.yml b/vendor/github.com/pborman/uuid/.travis.yml similarity index 100% rename from src/vendor/github.com/pborman/uuid/.travis.yml rename to vendor/github.com/pborman/uuid/.travis.yml diff --git a/src/vendor/github.com/pborman/uuid/CONTRIBUTING.md b/vendor/github.com/pborman/uuid/CONTRIBUTING.md similarity index 100% rename from src/vendor/github.com/pborman/uuid/CONTRIBUTING.md rename to vendor/github.com/pborman/uuid/CONTRIBUTING.md diff --git a/src/vendor/github.com/pborman/uuid/CONTRIBUTORS b/vendor/github.com/pborman/uuid/CONTRIBUTORS similarity index 100% rename from src/vendor/github.com/pborman/uuid/CONTRIBUTORS rename to vendor/github.com/pborman/uuid/CONTRIBUTORS diff --git a/src/vendor/github.com/pborman/uuid/LICENSE b/vendor/github.com/pborman/uuid/LICENSE similarity index 100% rename from src/vendor/github.com/pborman/uuid/LICENSE rename to vendor/github.com/pborman/uuid/LICENSE diff --git a/src/vendor/github.com/pborman/uuid/README.md b/vendor/github.com/pborman/uuid/README.md similarity index 100% rename from src/vendor/github.com/pborman/uuid/README.md rename to vendor/github.com/pborman/uuid/README.md diff --git a/src/vendor/github.com/pborman/uuid/dce.go b/vendor/github.com/pborman/uuid/dce.go similarity index 100% rename from src/vendor/github.com/pborman/uuid/dce.go rename to vendor/github.com/pborman/uuid/dce.go diff --git a/src/vendor/github.com/pborman/uuid/doc.go b/vendor/github.com/pborman/uuid/doc.go similarity index 100% rename from src/vendor/github.com/pborman/uuid/doc.go rename to vendor/github.com/pborman/uuid/doc.go diff --git a/src/vendor/github.com/pborman/uuid/hash.go b/vendor/github.com/pborman/uuid/hash.go similarity index 100% rename from src/vendor/github.com/pborman/uuid/hash.go rename to vendor/github.com/pborman/uuid/hash.go diff --git a/src/vendor/github.com/pborman/uuid/json.go b/vendor/github.com/pborman/uuid/json.go similarity index 100% rename from src/vendor/github.com/pborman/uuid/json.go rename to vendor/github.com/pborman/uuid/json.go diff --git a/src/vendor/github.com/pborman/uuid/node.go b/vendor/github.com/pborman/uuid/node.go similarity index 100% rename from src/vendor/github.com/pborman/uuid/node.go rename to vendor/github.com/pborman/uuid/node.go diff --git a/src/vendor/github.com/pborman/uuid/sql.go b/vendor/github.com/pborman/uuid/sql.go similarity index 100% rename from src/vendor/github.com/pborman/uuid/sql.go rename to vendor/github.com/pborman/uuid/sql.go diff --git a/src/vendor/github.com/pborman/uuid/time.go b/vendor/github.com/pborman/uuid/time.go similarity index 100% rename from src/vendor/github.com/pborman/uuid/time.go rename to vendor/github.com/pborman/uuid/time.go diff --git a/src/vendor/github.com/pborman/uuid/util.go b/vendor/github.com/pborman/uuid/util.go similarity index 100% rename from src/vendor/github.com/pborman/uuid/util.go rename to vendor/github.com/pborman/uuid/util.go diff --git a/src/vendor/github.com/pborman/uuid/uuid.go b/vendor/github.com/pborman/uuid/uuid.go similarity index 100% rename from src/vendor/github.com/pborman/uuid/uuid.go rename to vendor/github.com/pborman/uuid/uuid.go diff --git a/src/vendor/github.com/pborman/uuid/version1.go b/vendor/github.com/pborman/uuid/version1.go similarity index 100% rename from src/vendor/github.com/pborman/uuid/version1.go rename to vendor/github.com/pborman/uuid/version1.go diff --git a/src/vendor/github.com/pborman/uuid/version4.go b/vendor/github.com/pborman/uuid/version4.go similarity index 100% rename from src/vendor/github.com/pborman/uuid/version4.go rename to vendor/github.com/pborman/uuid/version4.go diff --git a/src/vendor/github.com/pkg/errors/.gitignore b/vendor/github.com/pkg/errors/.gitignore similarity index 100% rename from src/vendor/github.com/pkg/errors/.gitignore rename to vendor/github.com/pkg/errors/.gitignore diff --git a/src/vendor/github.com/pkg/errors/.travis.yml b/vendor/github.com/pkg/errors/.travis.yml similarity index 100% rename from src/vendor/github.com/pkg/errors/.travis.yml rename to vendor/github.com/pkg/errors/.travis.yml diff --git a/src/vendor/github.com/pkg/errors/LICENSE b/vendor/github.com/pkg/errors/LICENSE similarity index 100% rename from src/vendor/github.com/pkg/errors/LICENSE rename to vendor/github.com/pkg/errors/LICENSE diff --git a/src/vendor/github.com/pkg/errors/README.md b/vendor/github.com/pkg/errors/README.md similarity index 100% rename from src/vendor/github.com/pkg/errors/README.md rename to vendor/github.com/pkg/errors/README.md diff --git a/src/vendor/github.com/pkg/errors/errors.go b/vendor/github.com/pkg/errors/errors.go similarity index 100% rename from src/vendor/github.com/pkg/errors/errors.go rename to vendor/github.com/pkg/errors/errors.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/.gitignore b/vendor/github.com/rcrowley/go-metrics/.gitignore similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/.gitignore rename to vendor/github.com/rcrowley/go-metrics/.gitignore diff --git a/src/vendor/github.com/rcrowley/go-metrics/.travis.yml b/vendor/github.com/rcrowley/go-metrics/.travis.yml similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/.travis.yml rename to vendor/github.com/rcrowley/go-metrics/.travis.yml diff --git a/src/vendor/github.com/rcrowley/go-metrics/LICENSE b/vendor/github.com/rcrowley/go-metrics/LICENSE similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/LICENSE rename to vendor/github.com/rcrowley/go-metrics/LICENSE diff --git a/src/vendor/github.com/rcrowley/go-metrics/README.md b/vendor/github.com/rcrowley/go-metrics/README.md similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/README.md rename to vendor/github.com/rcrowley/go-metrics/README.md diff --git a/src/vendor/github.com/rcrowley/go-metrics/counter.go b/vendor/github.com/rcrowley/go-metrics/counter.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/counter.go rename to vendor/github.com/rcrowley/go-metrics/counter.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/debug.go b/vendor/github.com/rcrowley/go-metrics/debug.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/debug.go rename to vendor/github.com/rcrowley/go-metrics/debug.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/ewma.go b/vendor/github.com/rcrowley/go-metrics/ewma.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/ewma.go rename to vendor/github.com/rcrowley/go-metrics/ewma.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/gauge.go b/vendor/github.com/rcrowley/go-metrics/gauge.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/gauge.go rename to vendor/github.com/rcrowley/go-metrics/gauge.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/gauge_float64.go b/vendor/github.com/rcrowley/go-metrics/gauge_float64.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/gauge_float64.go rename to vendor/github.com/rcrowley/go-metrics/gauge_float64.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/graphite.go b/vendor/github.com/rcrowley/go-metrics/graphite.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/graphite.go rename to vendor/github.com/rcrowley/go-metrics/graphite.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/healthcheck.go b/vendor/github.com/rcrowley/go-metrics/healthcheck.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/healthcheck.go rename to vendor/github.com/rcrowley/go-metrics/healthcheck.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/histogram.go b/vendor/github.com/rcrowley/go-metrics/histogram.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/histogram.go rename to vendor/github.com/rcrowley/go-metrics/histogram.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/json.go b/vendor/github.com/rcrowley/go-metrics/json.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/json.go rename to vendor/github.com/rcrowley/go-metrics/json.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/log.go b/vendor/github.com/rcrowley/go-metrics/log.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/log.go rename to vendor/github.com/rcrowley/go-metrics/log.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/memory.md b/vendor/github.com/rcrowley/go-metrics/memory.md similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/memory.md rename to vendor/github.com/rcrowley/go-metrics/memory.md diff --git a/src/vendor/github.com/rcrowley/go-metrics/meter.go b/vendor/github.com/rcrowley/go-metrics/meter.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/meter.go rename to vendor/github.com/rcrowley/go-metrics/meter.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/metrics.go b/vendor/github.com/rcrowley/go-metrics/metrics.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/metrics.go rename to vendor/github.com/rcrowley/go-metrics/metrics.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/opentsdb.go b/vendor/github.com/rcrowley/go-metrics/opentsdb.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/opentsdb.go rename to vendor/github.com/rcrowley/go-metrics/opentsdb.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/registry.go b/vendor/github.com/rcrowley/go-metrics/registry.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/registry.go rename to vendor/github.com/rcrowley/go-metrics/registry.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/runtime.go b/vendor/github.com/rcrowley/go-metrics/runtime.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/runtime.go rename to vendor/github.com/rcrowley/go-metrics/runtime.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/runtime_cgo.go b/vendor/github.com/rcrowley/go-metrics/runtime_cgo.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/runtime_cgo.go rename to vendor/github.com/rcrowley/go-metrics/runtime_cgo.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/runtime_gccpufraction.go b/vendor/github.com/rcrowley/go-metrics/runtime_gccpufraction.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/runtime_gccpufraction.go rename to vendor/github.com/rcrowley/go-metrics/runtime_gccpufraction.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/runtime_no_cgo.go b/vendor/github.com/rcrowley/go-metrics/runtime_no_cgo.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/runtime_no_cgo.go rename to vendor/github.com/rcrowley/go-metrics/runtime_no_cgo.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/runtime_no_gccpufraction.go b/vendor/github.com/rcrowley/go-metrics/runtime_no_gccpufraction.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/runtime_no_gccpufraction.go rename to vendor/github.com/rcrowley/go-metrics/runtime_no_gccpufraction.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/sample.go b/vendor/github.com/rcrowley/go-metrics/sample.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/sample.go rename to vendor/github.com/rcrowley/go-metrics/sample.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/syslog.go b/vendor/github.com/rcrowley/go-metrics/syslog.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/syslog.go rename to vendor/github.com/rcrowley/go-metrics/syslog.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/timer.go b/vendor/github.com/rcrowley/go-metrics/timer.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/timer.go rename to vendor/github.com/rcrowley/go-metrics/timer.go diff --git a/src/vendor/github.com/rcrowley/go-metrics/validate.sh b/vendor/github.com/rcrowley/go-metrics/validate.sh similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/validate.sh rename to vendor/github.com/rcrowley/go-metrics/validate.sh diff --git a/src/vendor/github.com/rcrowley/go-metrics/writer.go b/vendor/github.com/rcrowley/go-metrics/writer.go similarity index 100% rename from src/vendor/github.com/rcrowley/go-metrics/writer.go rename to vendor/github.com/rcrowley/go-metrics/writer.go diff --git a/src/vendor/github.com/rjeczalik/notify/.gitignore b/vendor/github.com/rjeczalik/notify/.gitignore similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/.gitignore rename to vendor/github.com/rjeczalik/notify/.gitignore diff --git a/src/vendor/github.com/rjeczalik/notify/.travis.yml b/vendor/github.com/rjeczalik/notify/.travis.yml similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/.travis.yml rename to vendor/github.com/rjeczalik/notify/.travis.yml diff --git a/src/vendor/github.com/rjeczalik/notify/AUTHORS b/vendor/github.com/rjeczalik/notify/AUTHORS similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/AUTHORS rename to vendor/github.com/rjeczalik/notify/AUTHORS diff --git a/src/vendor/github.com/rjeczalik/notify/LICENSE b/vendor/github.com/rjeczalik/notify/LICENSE similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/LICENSE rename to vendor/github.com/rjeczalik/notify/LICENSE diff --git a/src/vendor/github.com/rjeczalik/notify/README.md b/vendor/github.com/rjeczalik/notify/README.md similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/README.md rename to vendor/github.com/rjeczalik/notify/README.md diff --git a/src/vendor/github.com/rjeczalik/notify/appveyor.yml b/vendor/github.com/rjeczalik/notify/appveyor.yml similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/appveyor.yml rename to vendor/github.com/rjeczalik/notify/appveyor.yml diff --git a/src/vendor/github.com/rjeczalik/notify/debug.go b/vendor/github.com/rjeczalik/notify/debug.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/debug.go rename to vendor/github.com/rjeczalik/notify/debug.go diff --git a/src/vendor/github.com/rjeczalik/notify/debug_debug.go b/vendor/github.com/rjeczalik/notify/debug_debug.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/debug_debug.go rename to vendor/github.com/rjeczalik/notify/debug_debug.go diff --git a/src/vendor/github.com/rjeczalik/notify/doc.go b/vendor/github.com/rjeczalik/notify/doc.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/doc.go rename to vendor/github.com/rjeczalik/notify/doc.go diff --git a/src/vendor/github.com/rjeczalik/notify/event.go b/vendor/github.com/rjeczalik/notify/event.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/event.go rename to vendor/github.com/rjeczalik/notify/event.go diff --git a/src/vendor/github.com/rjeczalik/notify/event_fen.go b/vendor/github.com/rjeczalik/notify/event_fen.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/event_fen.go rename to vendor/github.com/rjeczalik/notify/event_fen.go diff --git a/src/vendor/github.com/rjeczalik/notify/event_fsevents.go b/vendor/github.com/rjeczalik/notify/event_fsevents.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/event_fsevents.go rename to vendor/github.com/rjeczalik/notify/event_fsevents.go diff --git a/src/vendor/github.com/rjeczalik/notify/event_inotify.go b/vendor/github.com/rjeczalik/notify/event_inotify.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/event_inotify.go rename to vendor/github.com/rjeczalik/notify/event_inotify.go diff --git a/src/vendor/github.com/rjeczalik/notify/event_kqueue.go b/vendor/github.com/rjeczalik/notify/event_kqueue.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/event_kqueue.go rename to vendor/github.com/rjeczalik/notify/event_kqueue.go diff --git a/src/vendor/github.com/rjeczalik/notify/event_readdcw.go b/vendor/github.com/rjeczalik/notify/event_readdcw.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/event_readdcw.go rename to vendor/github.com/rjeczalik/notify/event_readdcw.go diff --git a/src/vendor/github.com/rjeczalik/notify/event_stub.go b/vendor/github.com/rjeczalik/notify/event_stub.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/event_stub.go rename to vendor/github.com/rjeczalik/notify/event_stub.go diff --git a/src/vendor/github.com/rjeczalik/notify/event_trigger.go b/vendor/github.com/rjeczalik/notify/event_trigger.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/event_trigger.go rename to vendor/github.com/rjeczalik/notify/event_trigger.go diff --git a/src/vendor/github.com/rjeczalik/notify/node.go b/vendor/github.com/rjeczalik/notify/node.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/node.go rename to vendor/github.com/rjeczalik/notify/node.go diff --git a/src/vendor/github.com/rjeczalik/notify/notify.go b/vendor/github.com/rjeczalik/notify/notify.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/notify.go rename to vendor/github.com/rjeczalik/notify/notify.go diff --git a/src/vendor/github.com/rjeczalik/notify/tree.go b/vendor/github.com/rjeczalik/notify/tree.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/tree.go rename to vendor/github.com/rjeczalik/notify/tree.go diff --git a/src/vendor/github.com/rjeczalik/notify/tree_nonrecursive.go b/vendor/github.com/rjeczalik/notify/tree_nonrecursive.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/tree_nonrecursive.go rename to vendor/github.com/rjeczalik/notify/tree_nonrecursive.go diff --git a/src/vendor/github.com/rjeczalik/notify/tree_recursive.go b/vendor/github.com/rjeczalik/notify/tree_recursive.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/tree_recursive.go rename to vendor/github.com/rjeczalik/notify/tree_recursive.go diff --git a/src/vendor/github.com/rjeczalik/notify/util.go b/vendor/github.com/rjeczalik/notify/util.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/util.go rename to vendor/github.com/rjeczalik/notify/util.go diff --git a/src/vendor/github.com/rjeczalik/notify/watcher.go b/vendor/github.com/rjeczalik/notify/watcher.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watcher.go rename to vendor/github.com/rjeczalik/notify/watcher.go diff --git a/src/vendor/github.com/rjeczalik/notify/watcher_fen.go b/vendor/github.com/rjeczalik/notify/watcher_fen.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watcher_fen.go rename to vendor/github.com/rjeczalik/notify/watcher_fen.go diff --git a/src/vendor/github.com/rjeczalik/notify/watcher_fen_cgo.go b/vendor/github.com/rjeczalik/notify/watcher_fen_cgo.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watcher_fen_cgo.go rename to vendor/github.com/rjeczalik/notify/watcher_fen_cgo.go diff --git a/src/vendor/github.com/rjeczalik/notify/watcher_fsevents.go b/vendor/github.com/rjeczalik/notify/watcher_fsevents.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watcher_fsevents.go rename to vendor/github.com/rjeczalik/notify/watcher_fsevents.go diff --git a/src/vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go b/vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go rename to vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go diff --git a/src/vendor/github.com/rjeczalik/notify/watcher_inotify.go b/vendor/github.com/rjeczalik/notify/watcher_inotify.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watcher_inotify.go rename to vendor/github.com/rjeczalik/notify/watcher_inotify.go diff --git a/src/vendor/github.com/rjeczalik/notify/watcher_kqueue.go b/vendor/github.com/rjeczalik/notify/watcher_kqueue.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watcher_kqueue.go rename to vendor/github.com/rjeczalik/notify/watcher_kqueue.go diff --git a/src/vendor/github.com/rjeczalik/notify/watcher_readdcw.go b/vendor/github.com/rjeczalik/notify/watcher_readdcw.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watcher_readdcw.go rename to vendor/github.com/rjeczalik/notify/watcher_readdcw.go diff --git a/src/vendor/github.com/rjeczalik/notify/watcher_stub.go b/vendor/github.com/rjeczalik/notify/watcher_stub.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watcher_stub.go rename to vendor/github.com/rjeczalik/notify/watcher_stub.go diff --git a/src/vendor/github.com/rjeczalik/notify/watcher_trigger.go b/vendor/github.com/rjeczalik/notify/watcher_trigger.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watcher_trigger.go rename to vendor/github.com/rjeczalik/notify/watcher_trigger.go diff --git a/src/vendor/github.com/rjeczalik/notify/watchpoint.go b/vendor/github.com/rjeczalik/notify/watchpoint.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watchpoint.go rename to vendor/github.com/rjeczalik/notify/watchpoint.go diff --git a/src/vendor/github.com/rjeczalik/notify/watchpoint_other.go b/vendor/github.com/rjeczalik/notify/watchpoint_other.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watchpoint_other.go rename to vendor/github.com/rjeczalik/notify/watchpoint_other.go diff --git a/src/vendor/github.com/rjeczalik/notify/watchpoint_readdcw.go b/vendor/github.com/rjeczalik/notify/watchpoint_readdcw.go similarity index 100% rename from src/vendor/github.com/rjeczalik/notify/watchpoint_readdcw.go rename to vendor/github.com/rjeczalik/notify/watchpoint_readdcw.go diff --git a/src/vendor/github.com/robertkrimen/otto/DESIGN.markdown b/vendor/github.com/robertkrimen/otto/DESIGN.markdown similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/DESIGN.markdown rename to vendor/github.com/robertkrimen/otto/DESIGN.markdown diff --git a/src/vendor/github.com/robertkrimen/otto/LICENSE b/vendor/github.com/robertkrimen/otto/LICENSE similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/LICENSE rename to vendor/github.com/robertkrimen/otto/LICENSE diff --git a/src/vendor/github.com/robertkrimen/otto/Makefile b/vendor/github.com/robertkrimen/otto/Makefile similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/Makefile rename to vendor/github.com/robertkrimen/otto/Makefile diff --git a/src/vendor/github.com/robertkrimen/otto/README.markdown b/vendor/github.com/robertkrimen/otto/README.markdown similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/README.markdown rename to vendor/github.com/robertkrimen/otto/README.markdown diff --git a/src/vendor/github.com/robertkrimen/otto/array_test.go b/vendor/github.com/robertkrimen/otto/array_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/array_test.go rename to vendor/github.com/robertkrimen/otto/array_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/ast/README.markdown b/vendor/github.com/robertkrimen/otto/ast/README.markdown similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/ast/README.markdown rename to vendor/github.com/robertkrimen/otto/ast/README.markdown diff --git a/src/vendor/github.com/robertkrimen/otto/ast/comments.go b/vendor/github.com/robertkrimen/otto/ast/comments.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/ast/comments.go rename to vendor/github.com/robertkrimen/otto/ast/comments.go diff --git a/src/vendor/github.com/robertkrimen/otto/ast/comments_test.go b/vendor/github.com/robertkrimen/otto/ast/comments_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/ast/comments_test.go rename to vendor/github.com/robertkrimen/otto/ast/comments_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/ast/node.go b/vendor/github.com/robertkrimen/otto/ast/node.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/ast/node.go rename to vendor/github.com/robertkrimen/otto/ast/node.go diff --git a/src/vendor/github.com/robertkrimen/otto/bug_test.go b/vendor/github.com/robertkrimen/otto/bug_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/bug_test.go rename to vendor/github.com/robertkrimen/otto/bug_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin.go b/vendor/github.com/robertkrimen/otto/builtin.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin.go rename to vendor/github.com/robertkrimen/otto/builtin.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_array.go b/vendor/github.com/robertkrimen/otto/builtin_array.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_array.go rename to vendor/github.com/robertkrimen/otto/builtin_array.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_boolean.go b/vendor/github.com/robertkrimen/otto/builtin_boolean.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_boolean.go rename to vendor/github.com/robertkrimen/otto/builtin_boolean.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_date.go b/vendor/github.com/robertkrimen/otto/builtin_date.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_date.go rename to vendor/github.com/robertkrimen/otto/builtin_date.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_error.go b/vendor/github.com/robertkrimen/otto/builtin_error.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_error.go rename to vendor/github.com/robertkrimen/otto/builtin_error.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_function.go b/vendor/github.com/robertkrimen/otto/builtin_function.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_function.go rename to vendor/github.com/robertkrimen/otto/builtin_function.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_json.go b/vendor/github.com/robertkrimen/otto/builtin_json.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_json.go rename to vendor/github.com/robertkrimen/otto/builtin_json.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_math.go b/vendor/github.com/robertkrimen/otto/builtin_math.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_math.go rename to vendor/github.com/robertkrimen/otto/builtin_math.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_number.go b/vendor/github.com/robertkrimen/otto/builtin_number.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_number.go rename to vendor/github.com/robertkrimen/otto/builtin_number.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_object.go b/vendor/github.com/robertkrimen/otto/builtin_object.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_object.go rename to vendor/github.com/robertkrimen/otto/builtin_object.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_regexp.go b/vendor/github.com/robertkrimen/otto/builtin_regexp.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_regexp.go rename to vendor/github.com/robertkrimen/otto/builtin_regexp.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_string.go b/vendor/github.com/robertkrimen/otto/builtin_string.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_string.go rename to vendor/github.com/robertkrimen/otto/builtin_string.go diff --git a/src/vendor/github.com/robertkrimen/otto/builtin_test.go b/vendor/github.com/robertkrimen/otto/builtin_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/builtin_test.go rename to vendor/github.com/robertkrimen/otto/builtin_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/call_test.go b/vendor/github.com/robertkrimen/otto/call_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/call_test.go rename to vendor/github.com/robertkrimen/otto/call_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/clone.go b/vendor/github.com/robertkrimen/otto/clone.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/clone.go rename to vendor/github.com/robertkrimen/otto/clone.go diff --git a/src/vendor/github.com/robertkrimen/otto/clone_test.go b/vendor/github.com/robertkrimen/otto/clone_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/clone_test.go rename to vendor/github.com/robertkrimen/otto/clone_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/cmpl.go b/vendor/github.com/robertkrimen/otto/cmpl.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/cmpl.go rename to vendor/github.com/robertkrimen/otto/cmpl.go diff --git a/src/vendor/github.com/robertkrimen/otto/cmpl_evaluate.go b/vendor/github.com/robertkrimen/otto/cmpl_evaluate.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/cmpl_evaluate.go rename to vendor/github.com/robertkrimen/otto/cmpl_evaluate.go diff --git a/src/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go b/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go rename to vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go diff --git a/src/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go b/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go rename to vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go diff --git a/src/vendor/github.com/robertkrimen/otto/cmpl_parse.go b/vendor/github.com/robertkrimen/otto/cmpl_parse.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/cmpl_parse.go rename to vendor/github.com/robertkrimen/otto/cmpl_parse.go diff --git a/src/vendor/github.com/robertkrimen/otto/cmpl_test.go b/vendor/github.com/robertkrimen/otto/cmpl_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/cmpl_test.go rename to vendor/github.com/robertkrimen/otto/cmpl_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/console.go b/vendor/github.com/robertkrimen/otto/console.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/console.go rename to vendor/github.com/robertkrimen/otto/console.go diff --git a/src/vendor/github.com/robertkrimen/otto/date_test.go b/vendor/github.com/robertkrimen/otto/date_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/date_test.go rename to vendor/github.com/robertkrimen/otto/date_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/dbg.go b/vendor/github.com/robertkrimen/otto/dbg.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/dbg.go rename to vendor/github.com/robertkrimen/otto/dbg.go diff --git a/src/vendor/github.com/robertkrimen/otto/dbg/dbg.go b/vendor/github.com/robertkrimen/otto/dbg/dbg.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/dbg/dbg.go rename to vendor/github.com/robertkrimen/otto/dbg/dbg.go diff --git a/src/vendor/github.com/robertkrimen/otto/documentation_test.go b/vendor/github.com/robertkrimen/otto/documentation_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/documentation_test.go rename to vendor/github.com/robertkrimen/otto/documentation_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/error.go b/vendor/github.com/robertkrimen/otto/error.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/error.go rename to vendor/github.com/robertkrimen/otto/error.go diff --git a/src/vendor/github.com/robertkrimen/otto/error_native_test.go b/vendor/github.com/robertkrimen/otto/error_native_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/error_native_test.go rename to vendor/github.com/robertkrimen/otto/error_native_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/error_test.go b/vendor/github.com/robertkrimen/otto/error_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/error_test.go rename to vendor/github.com/robertkrimen/otto/error_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/evaluate.go b/vendor/github.com/robertkrimen/otto/evaluate.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/evaluate.go rename to vendor/github.com/robertkrimen/otto/evaluate.go diff --git a/src/vendor/github.com/robertkrimen/otto/file/README.markdown b/vendor/github.com/robertkrimen/otto/file/README.markdown similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/file/README.markdown rename to vendor/github.com/robertkrimen/otto/file/README.markdown diff --git a/src/vendor/github.com/robertkrimen/otto/file/file.go b/vendor/github.com/robertkrimen/otto/file/file.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/file/file.go rename to vendor/github.com/robertkrimen/otto/file/file.go diff --git a/src/vendor/github.com/robertkrimen/otto/function_stack_test.go b/vendor/github.com/robertkrimen/otto/function_stack_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/function_stack_test.go rename to vendor/github.com/robertkrimen/otto/function_stack_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/function_test.go b/vendor/github.com/robertkrimen/otto/function_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/function_test.go rename to vendor/github.com/robertkrimen/otto/function_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/global.go b/vendor/github.com/robertkrimen/otto/global.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/global.go rename to vendor/github.com/robertkrimen/otto/global.go diff --git a/src/vendor/github.com/robertkrimen/otto/global_test.go b/vendor/github.com/robertkrimen/otto/global_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/global_test.go rename to vendor/github.com/robertkrimen/otto/global_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/inline.go b/vendor/github.com/robertkrimen/otto/inline.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/inline.go rename to vendor/github.com/robertkrimen/otto/inline.go diff --git a/src/vendor/github.com/robertkrimen/otto/inline.pl b/vendor/github.com/robertkrimen/otto/inline.pl similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/inline.pl rename to vendor/github.com/robertkrimen/otto/inline.pl diff --git a/src/vendor/github.com/robertkrimen/otto/json_test.go b/vendor/github.com/robertkrimen/otto/json_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/json_test.go rename to vendor/github.com/robertkrimen/otto/json_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/math_test.go b/vendor/github.com/robertkrimen/otto/math_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/math_test.go rename to vendor/github.com/robertkrimen/otto/math_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/native_stack_test.go b/vendor/github.com/robertkrimen/otto/native_stack_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/native_stack_test.go rename to vendor/github.com/robertkrimen/otto/native_stack_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/number_test.go b/vendor/github.com/robertkrimen/otto/number_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/number_test.go rename to vendor/github.com/robertkrimen/otto/number_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/object.go b/vendor/github.com/robertkrimen/otto/object.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/object.go rename to vendor/github.com/robertkrimen/otto/object.go diff --git a/src/vendor/github.com/robertkrimen/otto/object_class.go b/vendor/github.com/robertkrimen/otto/object_class.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/object_class.go rename to vendor/github.com/robertkrimen/otto/object_class.go diff --git a/src/vendor/github.com/robertkrimen/otto/object_test.go b/vendor/github.com/robertkrimen/otto/object_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/object_test.go rename to vendor/github.com/robertkrimen/otto/object_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/otto.go b/vendor/github.com/robertkrimen/otto/otto.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/otto.go rename to vendor/github.com/robertkrimen/otto/otto.go diff --git a/src/vendor/github.com/robertkrimen/otto/otto/Makefile b/vendor/github.com/robertkrimen/otto/otto/Makefile similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/otto/Makefile rename to vendor/github.com/robertkrimen/otto/otto/Makefile diff --git a/src/vendor/github.com/robertkrimen/otto/otto/main.go b/vendor/github.com/robertkrimen/otto/otto/main.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/otto/main.go rename to vendor/github.com/robertkrimen/otto/otto/main.go diff --git a/src/vendor/github.com/robertkrimen/otto/otto_.go b/vendor/github.com/robertkrimen/otto/otto_.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/otto_.go rename to vendor/github.com/robertkrimen/otto/otto_.go diff --git a/src/vendor/github.com/robertkrimen/otto/otto_error_test.go b/vendor/github.com/robertkrimen/otto/otto_error_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/otto_error_test.go rename to vendor/github.com/robertkrimen/otto/otto_error_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/otto_test.go b/vendor/github.com/robertkrimen/otto/otto_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/otto_test.go rename to vendor/github.com/robertkrimen/otto/otto_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/panic_test.go b/vendor/github.com/robertkrimen/otto/panic_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/panic_test.go rename to vendor/github.com/robertkrimen/otto/panic_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/Makefile b/vendor/github.com/robertkrimen/otto/parser/Makefile similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/Makefile rename to vendor/github.com/robertkrimen/otto/parser/Makefile diff --git a/src/vendor/github.com/robertkrimen/otto/parser/README.markdown b/vendor/github.com/robertkrimen/otto/parser/README.markdown similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/README.markdown rename to vendor/github.com/robertkrimen/otto/parser/README.markdown diff --git a/src/vendor/github.com/robertkrimen/otto/parser/comments_test.go b/vendor/github.com/robertkrimen/otto/parser/comments_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/comments_test.go rename to vendor/github.com/robertkrimen/otto/parser/comments_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/dbg.go b/vendor/github.com/robertkrimen/otto/parser/dbg.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/dbg.go rename to vendor/github.com/robertkrimen/otto/parser/dbg.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/error.go b/vendor/github.com/robertkrimen/otto/parser/error.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/error.go rename to vendor/github.com/robertkrimen/otto/parser/error.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/expression.go b/vendor/github.com/robertkrimen/otto/parser/expression.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/expression.go rename to vendor/github.com/robertkrimen/otto/parser/expression.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/lexer.go b/vendor/github.com/robertkrimen/otto/parser/lexer.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/lexer.go rename to vendor/github.com/robertkrimen/otto/parser/lexer.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/lexer_test.go b/vendor/github.com/robertkrimen/otto/parser/lexer_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/lexer_test.go rename to vendor/github.com/robertkrimen/otto/parser/lexer_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/marshal_test.go b/vendor/github.com/robertkrimen/otto/parser/marshal_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/marshal_test.go rename to vendor/github.com/robertkrimen/otto/parser/marshal_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/parser.go b/vendor/github.com/robertkrimen/otto/parser/parser.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/parser.go rename to vendor/github.com/robertkrimen/otto/parser/parser.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/parser_test.go b/vendor/github.com/robertkrimen/otto/parser/parser_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/parser_test.go rename to vendor/github.com/robertkrimen/otto/parser/parser_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/regexp.go b/vendor/github.com/robertkrimen/otto/parser/regexp.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/regexp.go rename to vendor/github.com/robertkrimen/otto/parser/regexp.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/regexp_test.go b/vendor/github.com/robertkrimen/otto/parser/regexp_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/regexp_test.go rename to vendor/github.com/robertkrimen/otto/parser/regexp_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/scope.go b/vendor/github.com/robertkrimen/otto/parser/scope.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/scope.go rename to vendor/github.com/robertkrimen/otto/parser/scope.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser/statement.go b/vendor/github.com/robertkrimen/otto/parser/statement.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser/statement.go rename to vendor/github.com/robertkrimen/otto/parser/statement.go diff --git a/src/vendor/github.com/robertkrimen/otto/parser_test.go b/vendor/github.com/robertkrimen/otto/parser_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/parser_test.go rename to vendor/github.com/robertkrimen/otto/parser_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/property.go b/vendor/github.com/robertkrimen/otto/property.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/property.go rename to vendor/github.com/robertkrimen/otto/property.go diff --git a/src/vendor/github.com/robertkrimen/otto/reflect_test.go b/vendor/github.com/robertkrimen/otto/reflect_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/reflect_test.go rename to vendor/github.com/robertkrimen/otto/reflect_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/regexp_test.go b/vendor/github.com/robertkrimen/otto/regexp_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/regexp_test.go rename to vendor/github.com/robertkrimen/otto/regexp_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/registry/README.markdown b/vendor/github.com/robertkrimen/otto/registry/README.markdown similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/registry/README.markdown rename to vendor/github.com/robertkrimen/otto/registry/README.markdown diff --git a/src/vendor/github.com/robertkrimen/otto/registry/registry.go b/vendor/github.com/robertkrimen/otto/registry/registry.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/registry/registry.go rename to vendor/github.com/robertkrimen/otto/registry/registry.go diff --git a/src/vendor/github.com/robertkrimen/otto/repl/autocompleter.go b/vendor/github.com/robertkrimen/otto/repl/autocompleter.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/repl/autocompleter.go rename to vendor/github.com/robertkrimen/otto/repl/autocompleter.go diff --git a/src/vendor/github.com/robertkrimen/otto/repl/repl.go b/vendor/github.com/robertkrimen/otto/repl/repl.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/repl/repl.go rename to vendor/github.com/robertkrimen/otto/repl/repl.go diff --git a/src/vendor/github.com/robertkrimen/otto/result.go b/vendor/github.com/robertkrimen/otto/result.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/result.go rename to vendor/github.com/robertkrimen/otto/result.go diff --git a/src/vendor/github.com/robertkrimen/otto/runtime.go b/vendor/github.com/robertkrimen/otto/runtime.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/runtime.go rename to vendor/github.com/robertkrimen/otto/runtime.go diff --git a/src/vendor/github.com/robertkrimen/otto/runtime_test.go b/vendor/github.com/robertkrimen/otto/runtime_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/runtime_test.go rename to vendor/github.com/robertkrimen/otto/runtime_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/scope.go b/vendor/github.com/robertkrimen/otto/scope.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/scope.go rename to vendor/github.com/robertkrimen/otto/scope.go diff --git a/src/vendor/github.com/robertkrimen/otto/script.go b/vendor/github.com/robertkrimen/otto/script.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/script.go rename to vendor/github.com/robertkrimen/otto/script.go diff --git a/src/vendor/github.com/robertkrimen/otto/script_test.go b/vendor/github.com/robertkrimen/otto/script_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/script_test.go rename to vendor/github.com/robertkrimen/otto/script_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/sourcemap_test.go b/vendor/github.com/robertkrimen/otto/sourcemap_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/sourcemap_test.go rename to vendor/github.com/robertkrimen/otto/sourcemap_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/stash.go b/vendor/github.com/robertkrimen/otto/stash.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/stash.go rename to vendor/github.com/robertkrimen/otto/stash.go diff --git a/src/vendor/github.com/robertkrimen/otto/string_test.go b/vendor/github.com/robertkrimen/otto/string_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/string_test.go rename to vendor/github.com/robertkrimen/otto/string_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/terst/terst.go b/vendor/github.com/robertkrimen/otto/terst/terst.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/terst/terst.go rename to vendor/github.com/robertkrimen/otto/terst/terst.go diff --git a/src/vendor/github.com/robertkrimen/otto/test/Makefile b/vendor/github.com/robertkrimen/otto/test/Makefile similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/test/Makefile rename to vendor/github.com/robertkrimen/otto/test/Makefile diff --git a/src/vendor/github.com/robertkrimen/otto/test/tester.go b/vendor/github.com/robertkrimen/otto/test/tester.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/test/tester.go rename to vendor/github.com/robertkrimen/otto/test/tester.go diff --git a/src/vendor/github.com/robertkrimen/otto/testing_test.go b/vendor/github.com/robertkrimen/otto/testing_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/testing_test.go rename to vendor/github.com/robertkrimen/otto/testing_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/token/Makefile b/vendor/github.com/robertkrimen/otto/token/Makefile similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/token/Makefile rename to vendor/github.com/robertkrimen/otto/token/Makefile diff --git a/src/vendor/github.com/robertkrimen/otto/token/README.markdown b/vendor/github.com/robertkrimen/otto/token/README.markdown similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/token/README.markdown rename to vendor/github.com/robertkrimen/otto/token/README.markdown diff --git a/src/vendor/github.com/robertkrimen/otto/token/token.go b/vendor/github.com/robertkrimen/otto/token/token.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/token/token.go rename to vendor/github.com/robertkrimen/otto/token/token.go diff --git a/src/vendor/github.com/robertkrimen/otto/token/token_const.go b/vendor/github.com/robertkrimen/otto/token/token_const.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/token/token_const.go rename to vendor/github.com/robertkrimen/otto/token/token_const.go diff --git a/src/vendor/github.com/robertkrimen/otto/token/tokenfmt b/vendor/github.com/robertkrimen/otto/token/tokenfmt similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/token/tokenfmt rename to vendor/github.com/robertkrimen/otto/token/tokenfmt diff --git a/src/vendor/github.com/robertkrimen/otto/type_arguments.go b/vendor/github.com/robertkrimen/otto/type_arguments.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_arguments.go rename to vendor/github.com/robertkrimen/otto/type_arguments.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_array.go b/vendor/github.com/robertkrimen/otto/type_array.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_array.go rename to vendor/github.com/robertkrimen/otto/type_array.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_boolean.go b/vendor/github.com/robertkrimen/otto/type_boolean.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_boolean.go rename to vendor/github.com/robertkrimen/otto/type_boolean.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_date.go b/vendor/github.com/robertkrimen/otto/type_date.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_date.go rename to vendor/github.com/robertkrimen/otto/type_date.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_error.go b/vendor/github.com/robertkrimen/otto/type_error.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_error.go rename to vendor/github.com/robertkrimen/otto/type_error.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_function.go b/vendor/github.com/robertkrimen/otto/type_function.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_function.go rename to vendor/github.com/robertkrimen/otto/type_function.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_go_array.go b/vendor/github.com/robertkrimen/otto/type_go_array.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_go_array.go rename to vendor/github.com/robertkrimen/otto/type_go_array.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_go_map.go b/vendor/github.com/robertkrimen/otto/type_go_map.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_go_map.go rename to vendor/github.com/robertkrimen/otto/type_go_map.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_go_slice.go b/vendor/github.com/robertkrimen/otto/type_go_slice.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_go_slice.go rename to vendor/github.com/robertkrimen/otto/type_go_slice.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_go_slice_test.go b/vendor/github.com/robertkrimen/otto/type_go_slice_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_go_slice_test.go rename to vendor/github.com/robertkrimen/otto/type_go_slice_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_go_struct.go b/vendor/github.com/robertkrimen/otto/type_go_struct.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_go_struct.go rename to vendor/github.com/robertkrimen/otto/type_go_struct.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_number.go b/vendor/github.com/robertkrimen/otto/type_number.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_number.go rename to vendor/github.com/robertkrimen/otto/type_number.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_reference.go b/vendor/github.com/robertkrimen/otto/type_reference.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_reference.go rename to vendor/github.com/robertkrimen/otto/type_reference.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_regexp.go b/vendor/github.com/robertkrimen/otto/type_regexp.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_regexp.go rename to vendor/github.com/robertkrimen/otto/type_regexp.go diff --git a/src/vendor/github.com/robertkrimen/otto/type_string.go b/vendor/github.com/robertkrimen/otto/type_string.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/type_string.go rename to vendor/github.com/robertkrimen/otto/type_string.go diff --git a/src/vendor/github.com/robertkrimen/otto/underscore/Makefile b/vendor/github.com/robertkrimen/otto/underscore/Makefile similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore/Makefile rename to vendor/github.com/robertkrimen/otto/underscore/Makefile diff --git a/src/vendor/github.com/robertkrimen/otto/underscore/README.markdown b/vendor/github.com/robertkrimen/otto/underscore/README.markdown similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore/README.markdown rename to vendor/github.com/robertkrimen/otto/underscore/README.markdown diff --git a/src/vendor/github.com/robertkrimen/otto/underscore/source.go b/vendor/github.com/robertkrimen/otto/underscore/source.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore/source.go rename to vendor/github.com/robertkrimen/otto/underscore/source.go diff --git a/src/vendor/github.com/robertkrimen/otto/underscore/testify b/vendor/github.com/robertkrimen/otto/underscore/testify similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore/testify rename to vendor/github.com/robertkrimen/otto/underscore/testify diff --git a/src/vendor/github.com/robertkrimen/otto/underscore/underscore.go b/vendor/github.com/robertkrimen/otto/underscore/underscore.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore/underscore.go rename to vendor/github.com/robertkrimen/otto/underscore/underscore.go diff --git a/src/vendor/github.com/robertkrimen/otto/underscore_arrays_test.go b/vendor/github.com/robertkrimen/otto/underscore_arrays_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore_arrays_test.go rename to vendor/github.com/robertkrimen/otto/underscore_arrays_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/underscore_chaining_test.go b/vendor/github.com/robertkrimen/otto/underscore_chaining_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore_chaining_test.go rename to vendor/github.com/robertkrimen/otto/underscore_chaining_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/underscore_collections_test.go b/vendor/github.com/robertkrimen/otto/underscore_collections_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore_collections_test.go rename to vendor/github.com/robertkrimen/otto/underscore_collections_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/underscore_functions_test.go b/vendor/github.com/robertkrimen/otto/underscore_functions_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore_functions_test.go rename to vendor/github.com/robertkrimen/otto/underscore_functions_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/underscore_objects_test.go b/vendor/github.com/robertkrimen/otto/underscore_objects_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore_objects_test.go rename to vendor/github.com/robertkrimen/otto/underscore_objects_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/underscore_test.go b/vendor/github.com/robertkrimen/otto/underscore_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore_test.go rename to vendor/github.com/robertkrimen/otto/underscore_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/underscore_utility_test.go b/vendor/github.com/robertkrimen/otto/underscore_utility_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/underscore_utility_test.go rename to vendor/github.com/robertkrimen/otto/underscore_utility_test.go diff --git a/src/vendor/github.com/robertkrimen/otto/value.go b/vendor/github.com/robertkrimen/otto/value.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/value.go rename to vendor/github.com/robertkrimen/otto/value.go diff --git a/src/vendor/github.com/robertkrimen/otto/value_boolean.go b/vendor/github.com/robertkrimen/otto/value_boolean.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/value_boolean.go rename to vendor/github.com/robertkrimen/otto/value_boolean.go diff --git a/src/vendor/github.com/robertkrimen/otto/value_number.go b/vendor/github.com/robertkrimen/otto/value_number.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/value_number.go rename to vendor/github.com/robertkrimen/otto/value_number.go diff --git a/src/vendor/github.com/robertkrimen/otto/value_primitive.go b/vendor/github.com/robertkrimen/otto/value_primitive.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/value_primitive.go rename to vendor/github.com/robertkrimen/otto/value_primitive.go diff --git a/src/vendor/github.com/robertkrimen/otto/value_string.go b/vendor/github.com/robertkrimen/otto/value_string.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/value_string.go rename to vendor/github.com/robertkrimen/otto/value_string.go diff --git a/src/vendor/github.com/robertkrimen/otto/value_test.go b/vendor/github.com/robertkrimen/otto/value_test.go similarity index 100% rename from src/vendor/github.com/robertkrimen/otto/value_test.go rename to vendor/github.com/robertkrimen/otto/value_test.go diff --git a/src/vendor/github.com/rs/cors/.travis.yml b/vendor/github.com/rs/cors/.travis.yml similarity index 100% rename from src/vendor/github.com/rs/cors/.travis.yml rename to vendor/github.com/rs/cors/.travis.yml diff --git a/src/vendor/github.com/rs/cors/LICENSE b/vendor/github.com/rs/cors/LICENSE similarity index 100% rename from src/vendor/github.com/rs/cors/LICENSE rename to vendor/github.com/rs/cors/LICENSE diff --git a/src/vendor/github.com/rs/cors/README.md b/vendor/github.com/rs/cors/README.md similarity index 100% rename from src/vendor/github.com/rs/cors/README.md rename to vendor/github.com/rs/cors/README.md diff --git a/src/vendor/github.com/rs/cors/cors.go b/vendor/github.com/rs/cors/cors.go similarity index 100% rename from src/vendor/github.com/rs/cors/cors.go rename to vendor/github.com/rs/cors/cors.go diff --git a/src/vendor/github.com/rs/cors/utils.go b/vendor/github.com/rs/cors/utils.go similarity index 100% rename from src/vendor/github.com/rs/cors/utils.go rename to vendor/github.com/rs/cors/utils.go diff --git a/src/vendor/github.com/rs/xhandler/.travis.yml b/vendor/github.com/rs/xhandler/.travis.yml similarity index 100% rename from src/vendor/github.com/rs/xhandler/.travis.yml rename to vendor/github.com/rs/xhandler/.travis.yml diff --git a/src/vendor/github.com/rs/xhandler/LICENSE b/vendor/github.com/rs/xhandler/LICENSE similarity index 100% rename from src/vendor/github.com/rs/xhandler/LICENSE rename to vendor/github.com/rs/xhandler/LICENSE diff --git a/src/vendor/github.com/rs/xhandler/README.md b/vendor/github.com/rs/xhandler/README.md similarity index 100% rename from src/vendor/github.com/rs/xhandler/README.md rename to vendor/github.com/rs/xhandler/README.md diff --git a/src/vendor/github.com/rs/xhandler/chain.go b/vendor/github.com/rs/xhandler/chain.go similarity index 100% rename from src/vendor/github.com/rs/xhandler/chain.go rename to vendor/github.com/rs/xhandler/chain.go diff --git a/src/vendor/github.com/rs/xhandler/middleware.go b/vendor/github.com/rs/xhandler/middleware.go similarity index 100% rename from src/vendor/github.com/rs/xhandler/middleware.go rename to vendor/github.com/rs/xhandler/middleware.go diff --git a/src/vendor/github.com/rs/xhandler/xhandler.go b/vendor/github.com/rs/xhandler/xhandler.go similarity index 100% rename from src/vendor/github.com/rs/xhandler/xhandler.go rename to vendor/github.com/rs/xhandler/xhandler.go diff --git a/src/vendor/github.com/syndtr/goleveldb/LICENSE b/vendor/github.com/syndtr/goleveldb/LICENSE similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/LICENSE rename to vendor/github.com/syndtr/goleveldb/LICENSE diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/batch.go b/vendor/github.com/syndtr/goleveldb/leveldb/batch.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/batch.go rename to vendor/github.com/syndtr/goleveldb/leveldb/batch.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go b/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go rename to vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/cache/lru.go b/vendor/github.com/syndtr/goleveldb/leveldb/cache/lru.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/cache/lru.go rename to vendor/github.com/syndtr/goleveldb/leveldb/cache/lru.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/comparer.go b/vendor/github.com/syndtr/goleveldb/leveldb/comparer.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/comparer.go rename to vendor/github.com/syndtr/goleveldb/leveldb/comparer.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go b/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go rename to vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go b/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go rename to vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/db.go b/vendor/github.com/syndtr/goleveldb/leveldb/db.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/db.go rename to vendor/github.com/syndtr/goleveldb/leveldb/db.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go rename to vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go rename to vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/db_snapshot.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_snapshot.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/db_snapshot.go rename to vendor/github.com/syndtr/goleveldb/leveldb/db_snapshot.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/db_state.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_state.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/db_state.go rename to vendor/github.com/syndtr/goleveldb/leveldb/db_state.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/db_transaction.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_transaction.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/db_transaction.go rename to vendor/github.com/syndtr/goleveldb/leveldb/db_transaction.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go rename to vendor/github.com/syndtr/goleveldb/leveldb/db_util.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/db_write.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_write.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/db_write.go rename to vendor/github.com/syndtr/goleveldb/leveldb/db_write.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/doc.go b/vendor/github.com/syndtr/goleveldb/leveldb/doc.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/doc.go rename to vendor/github.com/syndtr/goleveldb/leveldb/doc.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/errors.go b/vendor/github.com/syndtr/goleveldb/leveldb/errors.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/errors.go rename to vendor/github.com/syndtr/goleveldb/leveldb/errors.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go b/vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go rename to vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/filter.go b/vendor/github.com/syndtr/goleveldb/leveldb/filter.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/filter.go rename to vendor/github.com/syndtr/goleveldb/leveldb/filter.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/filter/bloom.go b/vendor/github.com/syndtr/goleveldb/leveldb/filter/bloom.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/filter/bloom.go rename to vendor/github.com/syndtr/goleveldb/leveldb/filter/bloom.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/filter/filter.go b/vendor/github.com/syndtr/goleveldb/leveldb/filter/filter.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/filter/filter.go rename to vendor/github.com/syndtr/goleveldb/leveldb/filter/filter.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go b/vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go rename to vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go b/vendor/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go rename to vendor/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter.go b/vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter.go rename to vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go b/vendor/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go rename to vendor/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/journal/journal.go b/vendor/github.com/syndtr/goleveldb/leveldb/journal/journal.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/journal/journal.go rename to vendor/github.com/syndtr/goleveldb/leveldb/journal/journal.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/key.go b/vendor/github.com/syndtr/goleveldb/leveldb/key.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/key.go rename to vendor/github.com/syndtr/goleveldb/leveldb/key.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go b/vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go rename to vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go b/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go rename to vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/options.go b/vendor/github.com/syndtr/goleveldb/leveldb/options.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/options.go rename to vendor/github.com/syndtr/goleveldb/leveldb/options.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/session.go b/vendor/github.com/syndtr/goleveldb/leveldb/session.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/session.go rename to vendor/github.com/syndtr/goleveldb/leveldb/session.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/session_compaction.go b/vendor/github.com/syndtr/goleveldb/leveldb/session_compaction.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/session_compaction.go rename to vendor/github.com/syndtr/goleveldb/leveldb/session_compaction.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/session_record.go b/vendor/github.com/syndtr/goleveldb/leveldb/session_record.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/session_record.go rename to vendor/github.com/syndtr/goleveldb/leveldb/session_record.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go b/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go rename to vendor/github.com/syndtr/goleveldb/leveldb/session_util.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go b/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go rename to vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go b/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go rename to vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go b/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go rename to vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go b/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go rename to vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_windows.go b/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_windows.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_windows.go rename to vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_windows.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go b/vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go rename to vendor/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/storage/storage.go b/vendor/github.com/syndtr/goleveldb/leveldb/storage/storage.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/storage/storage.go rename to vendor/github.com/syndtr/goleveldb/leveldb/storage/storage.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/table.go b/vendor/github.com/syndtr/goleveldb/leveldb/table.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/table.go rename to vendor/github.com/syndtr/goleveldb/leveldb/table.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/table/reader.go b/vendor/github.com/syndtr/goleveldb/leveldb/table/reader.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/table/reader.go rename to vendor/github.com/syndtr/goleveldb/leveldb/table/reader.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/table/table.go b/vendor/github.com/syndtr/goleveldb/leveldb/table/table.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/table/table.go rename to vendor/github.com/syndtr/goleveldb/leveldb/table/table.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/table/writer.go b/vendor/github.com/syndtr/goleveldb/leveldb/table/writer.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/table/writer.go rename to vendor/github.com/syndtr/goleveldb/leveldb/table/writer.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/util.go b/vendor/github.com/syndtr/goleveldb/leveldb/util.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/util.go rename to vendor/github.com/syndtr/goleveldb/leveldb/util.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer.go b/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer.go rename to vendor/github.com/syndtr/goleveldb/leveldb/util/buffer.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go b/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go rename to vendor/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/util/crc32.go b/vendor/github.com/syndtr/goleveldb/leveldb/util/crc32.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/util/crc32.go rename to vendor/github.com/syndtr/goleveldb/leveldb/util/crc32.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go b/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go rename to vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/util/range.go b/vendor/github.com/syndtr/goleveldb/leveldb/util/range.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/util/range.go rename to vendor/github.com/syndtr/goleveldb/leveldb/util/range.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/util/util.go b/vendor/github.com/syndtr/goleveldb/leveldb/util/util.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/util/util.go rename to vendor/github.com/syndtr/goleveldb/leveldb/util/util.go diff --git a/src/vendor/github.com/syndtr/goleveldb/leveldb/version.go b/vendor/github.com/syndtr/goleveldb/leveldb/version.go similarity index 100% rename from src/vendor/github.com/syndtr/goleveldb/leveldb/version.go rename to vendor/github.com/syndtr/goleveldb/leveldb/version.go diff --git a/src/vendor/golang.org/x/crypto/LICENSE b/vendor/golang.org/x/crypto/LICENSE similarity index 100% rename from src/vendor/golang.org/x/crypto/LICENSE rename to vendor/golang.org/x/crypto/LICENSE diff --git a/src/vendor/golang.org/x/crypto/PATENTS b/vendor/golang.org/x/crypto/PATENTS similarity index 100% rename from src/vendor/golang.org/x/crypto/PATENTS rename to vendor/golang.org/x/crypto/PATENTS diff --git a/src/vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go b/vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go similarity index 100% rename from src/vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go rename to vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go diff --git a/src/vendor/golang.org/x/crypto/ripemd160/ripemd160.go b/vendor/golang.org/x/crypto/ripemd160/ripemd160.go similarity index 100% rename from src/vendor/golang.org/x/crypto/ripemd160/ripemd160.go rename to vendor/golang.org/x/crypto/ripemd160/ripemd160.go diff --git a/src/vendor/golang.org/x/crypto/ripemd160/ripemd160block.go b/vendor/golang.org/x/crypto/ripemd160/ripemd160block.go similarity index 100% rename from src/vendor/golang.org/x/crypto/ripemd160/ripemd160block.go rename to vendor/golang.org/x/crypto/ripemd160/ripemd160block.go diff --git a/src/vendor/golang.org/x/crypto/scrypt/scrypt.go b/vendor/golang.org/x/crypto/scrypt/scrypt.go similarity index 100% rename from src/vendor/golang.org/x/crypto/scrypt/scrypt.go rename to vendor/golang.org/x/crypto/scrypt/scrypt.go diff --git a/src/vendor/golang.org/x/net/LICENSE b/vendor/golang.org/x/net/LICENSE similarity index 100% rename from src/vendor/golang.org/x/net/LICENSE rename to vendor/golang.org/x/net/LICENSE diff --git a/src/vendor/golang.org/x/net/PATENTS b/vendor/golang.org/x/net/PATENTS similarity index 100% rename from src/vendor/golang.org/x/net/PATENTS rename to vendor/golang.org/x/net/PATENTS diff --git a/src/vendor/golang.org/x/net/context/context.go b/vendor/golang.org/x/net/context/context.go similarity index 100% rename from src/vendor/golang.org/x/net/context/context.go rename to vendor/golang.org/x/net/context/context.go diff --git a/src/vendor/golang.org/x/net/context/go17.go b/vendor/golang.org/x/net/context/go17.go similarity index 100% rename from src/vendor/golang.org/x/net/context/go17.go rename to vendor/golang.org/x/net/context/go17.go diff --git a/src/vendor/golang.org/x/net/context/pre_go17.go b/vendor/golang.org/x/net/context/pre_go17.go similarity index 100% rename from src/vendor/golang.org/x/net/context/pre_go17.go rename to vendor/golang.org/x/net/context/pre_go17.go diff --git a/src/vendor/golang.org/x/net/html/atom/atom.go b/vendor/golang.org/x/net/html/atom/atom.go similarity index 100% rename from src/vendor/golang.org/x/net/html/atom/atom.go rename to vendor/golang.org/x/net/html/atom/atom.go diff --git a/src/vendor/golang.org/x/net/html/atom/gen.go b/vendor/golang.org/x/net/html/atom/gen.go similarity index 100% rename from src/vendor/golang.org/x/net/html/atom/gen.go rename to vendor/golang.org/x/net/html/atom/gen.go diff --git a/src/vendor/golang.org/x/net/html/atom/table.go b/vendor/golang.org/x/net/html/atom/table.go similarity index 100% rename from src/vendor/golang.org/x/net/html/atom/table.go rename to vendor/golang.org/x/net/html/atom/table.go diff --git a/src/vendor/golang.org/x/net/html/charset/charset.go b/vendor/golang.org/x/net/html/charset/charset.go similarity index 100% rename from src/vendor/golang.org/x/net/html/charset/charset.go rename to vendor/golang.org/x/net/html/charset/charset.go diff --git a/src/vendor/golang.org/x/net/html/const.go b/vendor/golang.org/x/net/html/const.go similarity index 100% rename from src/vendor/golang.org/x/net/html/const.go rename to vendor/golang.org/x/net/html/const.go diff --git a/src/vendor/golang.org/x/net/html/doc.go b/vendor/golang.org/x/net/html/doc.go similarity index 100% rename from src/vendor/golang.org/x/net/html/doc.go rename to vendor/golang.org/x/net/html/doc.go diff --git a/src/vendor/golang.org/x/net/html/doctype.go b/vendor/golang.org/x/net/html/doctype.go similarity index 100% rename from src/vendor/golang.org/x/net/html/doctype.go rename to vendor/golang.org/x/net/html/doctype.go diff --git a/src/vendor/golang.org/x/net/html/entity.go b/vendor/golang.org/x/net/html/entity.go similarity index 100% rename from src/vendor/golang.org/x/net/html/entity.go rename to vendor/golang.org/x/net/html/entity.go diff --git a/src/vendor/golang.org/x/net/html/escape.go b/vendor/golang.org/x/net/html/escape.go similarity index 100% rename from src/vendor/golang.org/x/net/html/escape.go rename to vendor/golang.org/x/net/html/escape.go diff --git a/src/vendor/golang.org/x/net/html/foreign.go b/vendor/golang.org/x/net/html/foreign.go similarity index 100% rename from src/vendor/golang.org/x/net/html/foreign.go rename to vendor/golang.org/x/net/html/foreign.go diff --git a/src/vendor/golang.org/x/net/html/node.go b/vendor/golang.org/x/net/html/node.go similarity index 100% rename from src/vendor/golang.org/x/net/html/node.go rename to vendor/golang.org/x/net/html/node.go diff --git a/src/vendor/golang.org/x/net/html/parse.go b/vendor/golang.org/x/net/html/parse.go similarity index 100% rename from src/vendor/golang.org/x/net/html/parse.go rename to vendor/golang.org/x/net/html/parse.go diff --git a/src/vendor/golang.org/x/net/html/render.go b/vendor/golang.org/x/net/html/render.go similarity index 100% rename from src/vendor/golang.org/x/net/html/render.go rename to vendor/golang.org/x/net/html/render.go diff --git a/src/vendor/golang.org/x/net/html/token.go b/vendor/golang.org/x/net/html/token.go similarity index 100% rename from src/vendor/golang.org/x/net/html/token.go rename to vendor/golang.org/x/net/html/token.go diff --git a/src/vendor/golang.org/x/net/websocket/client.go b/vendor/golang.org/x/net/websocket/client.go similarity index 100% rename from src/vendor/golang.org/x/net/websocket/client.go rename to vendor/golang.org/x/net/websocket/client.go diff --git a/src/vendor/golang.org/x/net/websocket/hybi.go b/vendor/golang.org/x/net/websocket/hybi.go similarity index 100% rename from src/vendor/golang.org/x/net/websocket/hybi.go rename to vendor/golang.org/x/net/websocket/hybi.go diff --git a/src/vendor/golang.org/x/net/websocket/server.go b/vendor/golang.org/x/net/websocket/server.go similarity index 100% rename from src/vendor/golang.org/x/net/websocket/server.go rename to vendor/golang.org/x/net/websocket/server.go diff --git a/src/vendor/golang.org/x/net/websocket/websocket.go b/vendor/golang.org/x/net/websocket/websocket.go similarity index 100% rename from src/vendor/golang.org/x/net/websocket/websocket.go rename to vendor/golang.org/x/net/websocket/websocket.go diff --git a/src/vendor/golang.org/x/sys/LICENSE b/vendor/golang.org/x/sys/LICENSE similarity index 100% rename from src/vendor/golang.org/x/sys/LICENSE rename to vendor/golang.org/x/sys/LICENSE diff --git a/src/vendor/golang.org/x/sys/PATENTS b/vendor/golang.org/x/sys/PATENTS similarity index 100% rename from src/vendor/golang.org/x/sys/PATENTS rename to vendor/golang.org/x/sys/PATENTS diff --git a/src/vendor/golang.org/x/sys/windows/asm_windows_386.s b/vendor/golang.org/x/sys/windows/asm_windows_386.s similarity index 100% rename from src/vendor/golang.org/x/sys/windows/asm_windows_386.s rename to vendor/golang.org/x/sys/windows/asm_windows_386.s diff --git a/src/vendor/golang.org/x/sys/windows/asm_windows_amd64.s b/vendor/golang.org/x/sys/windows/asm_windows_amd64.s similarity index 100% rename from src/vendor/golang.org/x/sys/windows/asm_windows_amd64.s rename to vendor/golang.org/x/sys/windows/asm_windows_amd64.s diff --git a/src/vendor/golang.org/x/sys/windows/dll_windows.go b/vendor/golang.org/x/sys/windows/dll_windows.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/dll_windows.go rename to vendor/golang.org/x/sys/windows/dll_windows.go diff --git a/src/vendor/golang.org/x/sys/windows/env_unset.go b/vendor/golang.org/x/sys/windows/env_unset.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/env_unset.go rename to vendor/golang.org/x/sys/windows/env_unset.go diff --git a/src/vendor/golang.org/x/sys/windows/env_windows.go b/vendor/golang.org/x/sys/windows/env_windows.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/env_windows.go rename to vendor/golang.org/x/sys/windows/env_windows.go diff --git a/src/vendor/golang.org/x/sys/windows/eventlog.go b/vendor/golang.org/x/sys/windows/eventlog.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/eventlog.go rename to vendor/golang.org/x/sys/windows/eventlog.go diff --git a/src/vendor/golang.org/x/sys/windows/exec_windows.go b/vendor/golang.org/x/sys/windows/exec_windows.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/exec_windows.go rename to vendor/golang.org/x/sys/windows/exec_windows.go diff --git a/src/vendor/golang.org/x/sys/windows/race.go b/vendor/golang.org/x/sys/windows/race.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/race.go rename to vendor/golang.org/x/sys/windows/race.go diff --git a/src/vendor/golang.org/x/sys/windows/race0.go b/vendor/golang.org/x/sys/windows/race0.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/race0.go rename to vendor/golang.org/x/sys/windows/race0.go diff --git a/src/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/security_windows.go rename to vendor/golang.org/x/sys/windows/security_windows.go diff --git a/src/vendor/golang.org/x/sys/windows/service.go b/vendor/golang.org/x/sys/windows/service.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/service.go rename to vendor/golang.org/x/sys/windows/service.go diff --git a/src/vendor/golang.org/x/sys/windows/str.go b/vendor/golang.org/x/sys/windows/str.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/str.go rename to vendor/golang.org/x/sys/windows/str.go diff --git a/src/vendor/golang.org/x/sys/windows/syscall.go b/vendor/golang.org/x/sys/windows/syscall.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/syscall.go rename to vendor/golang.org/x/sys/windows/syscall.go diff --git a/src/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/syscall_windows.go rename to vendor/golang.org/x/sys/windows/syscall_windows.go diff --git a/src/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/zsyscall_windows.go rename to vendor/golang.org/x/sys/windows/zsyscall_windows.go diff --git a/src/vendor/golang.org/x/sys/windows/ztypes_windows.go b/vendor/golang.org/x/sys/windows/ztypes_windows.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/ztypes_windows.go rename to vendor/golang.org/x/sys/windows/ztypes_windows.go diff --git a/src/vendor/golang.org/x/sys/windows/ztypes_windows_386.go b/vendor/golang.org/x/sys/windows/ztypes_windows_386.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/ztypes_windows_386.go rename to vendor/golang.org/x/sys/windows/ztypes_windows_386.go diff --git a/src/vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go b/vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go similarity index 100% rename from src/vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go rename to vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go diff --git a/src/vendor/golang.org/x/text/LICENSE b/vendor/golang.org/x/text/LICENSE similarity index 100% rename from src/vendor/golang.org/x/text/LICENSE rename to vendor/golang.org/x/text/LICENSE diff --git a/src/vendor/golang.org/x/text/PATENTS b/vendor/golang.org/x/text/PATENTS similarity index 100% rename from src/vendor/golang.org/x/text/PATENTS rename to vendor/golang.org/x/text/PATENTS diff --git a/src/vendor/golang.org/x/text/encoding/charmap/charmap.go b/vendor/golang.org/x/text/encoding/charmap/charmap.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/charmap/charmap.go rename to vendor/golang.org/x/text/encoding/charmap/charmap.go diff --git a/src/vendor/golang.org/x/text/encoding/charmap/maketables.go b/vendor/golang.org/x/text/encoding/charmap/maketables.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/charmap/maketables.go rename to vendor/golang.org/x/text/encoding/charmap/maketables.go diff --git a/src/vendor/golang.org/x/text/encoding/charmap/tables.go b/vendor/golang.org/x/text/encoding/charmap/tables.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/charmap/tables.go rename to vendor/golang.org/x/text/encoding/charmap/tables.go diff --git a/src/vendor/golang.org/x/text/encoding/encoding.go b/vendor/golang.org/x/text/encoding/encoding.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/encoding.go rename to vendor/golang.org/x/text/encoding/encoding.go diff --git a/src/vendor/golang.org/x/text/encoding/htmlindex/gen.go b/vendor/golang.org/x/text/encoding/htmlindex/gen.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/htmlindex/gen.go rename to vendor/golang.org/x/text/encoding/htmlindex/gen.go diff --git a/src/vendor/golang.org/x/text/encoding/htmlindex/htmlindex.go b/vendor/golang.org/x/text/encoding/htmlindex/htmlindex.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/htmlindex/htmlindex.go rename to vendor/golang.org/x/text/encoding/htmlindex/htmlindex.go diff --git a/src/vendor/golang.org/x/text/encoding/htmlindex/map.go b/vendor/golang.org/x/text/encoding/htmlindex/map.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/htmlindex/map.go rename to vendor/golang.org/x/text/encoding/htmlindex/map.go diff --git a/src/vendor/golang.org/x/text/encoding/htmlindex/tables.go b/vendor/golang.org/x/text/encoding/htmlindex/tables.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/htmlindex/tables.go rename to vendor/golang.org/x/text/encoding/htmlindex/tables.go diff --git a/src/vendor/golang.org/x/text/encoding/internal/identifier/gen.go b/vendor/golang.org/x/text/encoding/internal/identifier/gen.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/internal/identifier/gen.go rename to vendor/golang.org/x/text/encoding/internal/identifier/gen.go diff --git a/src/vendor/golang.org/x/text/encoding/internal/identifier/identifier.go b/vendor/golang.org/x/text/encoding/internal/identifier/identifier.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/internal/identifier/identifier.go rename to vendor/golang.org/x/text/encoding/internal/identifier/identifier.go diff --git a/src/vendor/golang.org/x/text/encoding/internal/identifier/mib.go b/vendor/golang.org/x/text/encoding/internal/identifier/mib.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/internal/identifier/mib.go rename to vendor/golang.org/x/text/encoding/internal/identifier/mib.go diff --git a/src/vendor/golang.org/x/text/encoding/internal/internal.go b/vendor/golang.org/x/text/encoding/internal/internal.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/internal/internal.go rename to vendor/golang.org/x/text/encoding/internal/internal.go diff --git a/src/vendor/golang.org/x/text/encoding/japanese/all.go b/vendor/golang.org/x/text/encoding/japanese/all.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/japanese/all.go rename to vendor/golang.org/x/text/encoding/japanese/all.go diff --git a/src/vendor/golang.org/x/text/encoding/japanese/eucjp.go b/vendor/golang.org/x/text/encoding/japanese/eucjp.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/japanese/eucjp.go rename to vendor/golang.org/x/text/encoding/japanese/eucjp.go diff --git a/src/vendor/golang.org/x/text/encoding/japanese/iso2022jp.go b/vendor/golang.org/x/text/encoding/japanese/iso2022jp.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/japanese/iso2022jp.go rename to vendor/golang.org/x/text/encoding/japanese/iso2022jp.go diff --git a/src/vendor/golang.org/x/text/encoding/japanese/maketables.go b/vendor/golang.org/x/text/encoding/japanese/maketables.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/japanese/maketables.go rename to vendor/golang.org/x/text/encoding/japanese/maketables.go diff --git a/src/vendor/golang.org/x/text/encoding/japanese/shiftjis.go b/vendor/golang.org/x/text/encoding/japanese/shiftjis.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/japanese/shiftjis.go rename to vendor/golang.org/x/text/encoding/japanese/shiftjis.go diff --git a/src/vendor/golang.org/x/text/encoding/japanese/tables.go b/vendor/golang.org/x/text/encoding/japanese/tables.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/japanese/tables.go rename to vendor/golang.org/x/text/encoding/japanese/tables.go diff --git a/src/vendor/golang.org/x/text/encoding/korean/euckr.go b/vendor/golang.org/x/text/encoding/korean/euckr.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/korean/euckr.go rename to vendor/golang.org/x/text/encoding/korean/euckr.go diff --git a/src/vendor/golang.org/x/text/encoding/korean/maketables.go b/vendor/golang.org/x/text/encoding/korean/maketables.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/korean/maketables.go rename to vendor/golang.org/x/text/encoding/korean/maketables.go diff --git a/src/vendor/golang.org/x/text/encoding/korean/tables.go b/vendor/golang.org/x/text/encoding/korean/tables.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/korean/tables.go rename to vendor/golang.org/x/text/encoding/korean/tables.go diff --git a/src/vendor/golang.org/x/text/encoding/simplifiedchinese/all.go b/vendor/golang.org/x/text/encoding/simplifiedchinese/all.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/simplifiedchinese/all.go rename to vendor/golang.org/x/text/encoding/simplifiedchinese/all.go diff --git a/src/vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go b/vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go rename to vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go diff --git a/src/vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go b/vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go rename to vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go diff --git a/src/vendor/golang.org/x/text/encoding/simplifiedchinese/maketables.go b/vendor/golang.org/x/text/encoding/simplifiedchinese/maketables.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/simplifiedchinese/maketables.go rename to vendor/golang.org/x/text/encoding/simplifiedchinese/maketables.go diff --git a/src/vendor/golang.org/x/text/encoding/simplifiedchinese/tables.go b/vendor/golang.org/x/text/encoding/simplifiedchinese/tables.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/simplifiedchinese/tables.go rename to vendor/golang.org/x/text/encoding/simplifiedchinese/tables.go diff --git a/src/vendor/golang.org/x/text/encoding/traditionalchinese/big5.go b/vendor/golang.org/x/text/encoding/traditionalchinese/big5.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/traditionalchinese/big5.go rename to vendor/golang.org/x/text/encoding/traditionalchinese/big5.go diff --git a/src/vendor/golang.org/x/text/encoding/traditionalchinese/maketables.go b/vendor/golang.org/x/text/encoding/traditionalchinese/maketables.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/traditionalchinese/maketables.go rename to vendor/golang.org/x/text/encoding/traditionalchinese/maketables.go diff --git a/src/vendor/golang.org/x/text/encoding/traditionalchinese/tables.go b/vendor/golang.org/x/text/encoding/traditionalchinese/tables.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/traditionalchinese/tables.go rename to vendor/golang.org/x/text/encoding/traditionalchinese/tables.go diff --git a/src/vendor/golang.org/x/text/encoding/unicode/override.go b/vendor/golang.org/x/text/encoding/unicode/override.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/unicode/override.go rename to vendor/golang.org/x/text/encoding/unicode/override.go diff --git a/src/vendor/golang.org/x/text/encoding/unicode/unicode.go b/vendor/golang.org/x/text/encoding/unicode/unicode.go similarity index 100% rename from src/vendor/golang.org/x/text/encoding/unicode/unicode.go rename to vendor/golang.org/x/text/encoding/unicode/unicode.go diff --git a/src/vendor/golang.org/x/text/internal/gen/code.go b/vendor/golang.org/x/text/internal/gen/code.go similarity index 100% rename from src/vendor/golang.org/x/text/internal/gen/code.go rename to vendor/golang.org/x/text/internal/gen/code.go diff --git a/src/vendor/golang.org/x/text/internal/gen/gen.go b/vendor/golang.org/x/text/internal/gen/gen.go similarity index 100% rename from src/vendor/golang.org/x/text/internal/gen/gen.go rename to vendor/golang.org/x/text/internal/gen/gen.go diff --git a/src/vendor/golang.org/x/text/internal/tag/tag.go b/vendor/golang.org/x/text/internal/tag/tag.go similarity index 100% rename from src/vendor/golang.org/x/text/internal/tag/tag.go rename to vendor/golang.org/x/text/internal/tag/tag.go diff --git a/src/vendor/golang.org/x/text/internal/testtext/codesize.go b/vendor/golang.org/x/text/internal/testtext/codesize.go similarity index 100% rename from src/vendor/golang.org/x/text/internal/testtext/codesize.go rename to vendor/golang.org/x/text/internal/testtext/codesize.go diff --git a/src/vendor/golang.org/x/text/internal/testtext/flag.go b/vendor/golang.org/x/text/internal/testtext/flag.go similarity index 100% rename from src/vendor/golang.org/x/text/internal/testtext/flag.go rename to vendor/golang.org/x/text/internal/testtext/flag.go diff --git a/src/vendor/golang.org/x/text/internal/testtext/text.go b/vendor/golang.org/x/text/internal/testtext/text.go similarity index 100% rename from src/vendor/golang.org/x/text/internal/testtext/text.go rename to vendor/golang.org/x/text/internal/testtext/text.go diff --git a/src/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go b/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go similarity index 100% rename from src/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go rename to vendor/golang.org/x/text/internal/utf8internal/utf8internal.go diff --git a/src/vendor/golang.org/x/text/language/Makefile b/vendor/golang.org/x/text/language/Makefile similarity index 100% rename from src/vendor/golang.org/x/text/language/Makefile rename to vendor/golang.org/x/text/language/Makefile diff --git a/src/vendor/golang.org/x/text/language/common.go b/vendor/golang.org/x/text/language/common.go similarity index 100% rename from src/vendor/golang.org/x/text/language/common.go rename to vendor/golang.org/x/text/language/common.go diff --git a/src/vendor/golang.org/x/text/language/coverage.go b/vendor/golang.org/x/text/language/coverage.go similarity index 100% rename from src/vendor/golang.org/x/text/language/coverage.go rename to vendor/golang.org/x/text/language/coverage.go diff --git a/src/vendor/golang.org/x/text/language/gen_common.go b/vendor/golang.org/x/text/language/gen_common.go similarity index 100% rename from src/vendor/golang.org/x/text/language/gen_common.go rename to vendor/golang.org/x/text/language/gen_common.go diff --git a/src/vendor/golang.org/x/text/language/gen_index.go b/vendor/golang.org/x/text/language/gen_index.go similarity index 100% rename from src/vendor/golang.org/x/text/language/gen_index.go rename to vendor/golang.org/x/text/language/gen_index.go diff --git a/src/vendor/golang.org/x/text/language/go1_1.go b/vendor/golang.org/x/text/language/go1_1.go similarity index 100% rename from src/vendor/golang.org/x/text/language/go1_1.go rename to vendor/golang.org/x/text/language/go1_1.go diff --git a/src/vendor/golang.org/x/text/language/go1_2.go b/vendor/golang.org/x/text/language/go1_2.go similarity index 100% rename from src/vendor/golang.org/x/text/language/go1_2.go rename to vendor/golang.org/x/text/language/go1_2.go diff --git a/src/vendor/golang.org/x/text/language/index.go b/vendor/golang.org/x/text/language/index.go similarity index 100% rename from src/vendor/golang.org/x/text/language/index.go rename to vendor/golang.org/x/text/language/index.go diff --git a/src/vendor/golang.org/x/text/language/language.go b/vendor/golang.org/x/text/language/language.go similarity index 100% rename from src/vendor/golang.org/x/text/language/language.go rename to vendor/golang.org/x/text/language/language.go diff --git a/src/vendor/golang.org/x/text/language/lookup.go b/vendor/golang.org/x/text/language/lookup.go similarity index 100% rename from src/vendor/golang.org/x/text/language/lookup.go rename to vendor/golang.org/x/text/language/lookup.go diff --git a/src/vendor/golang.org/x/text/language/maketables.go b/vendor/golang.org/x/text/language/maketables.go similarity index 100% rename from src/vendor/golang.org/x/text/language/maketables.go rename to vendor/golang.org/x/text/language/maketables.go diff --git a/src/vendor/golang.org/x/text/language/match.go b/vendor/golang.org/x/text/language/match.go similarity index 100% rename from src/vendor/golang.org/x/text/language/match.go rename to vendor/golang.org/x/text/language/match.go diff --git a/src/vendor/golang.org/x/text/language/parse.go b/vendor/golang.org/x/text/language/parse.go similarity index 100% rename from src/vendor/golang.org/x/text/language/parse.go rename to vendor/golang.org/x/text/language/parse.go diff --git a/src/vendor/golang.org/x/text/language/tables.go b/vendor/golang.org/x/text/language/tables.go similarity index 100% rename from src/vendor/golang.org/x/text/language/tables.go rename to vendor/golang.org/x/text/language/tables.go diff --git a/src/vendor/golang.org/x/text/language/tags.go b/vendor/golang.org/x/text/language/tags.go similarity index 100% rename from src/vendor/golang.org/x/text/language/tags.go rename to vendor/golang.org/x/text/language/tags.go diff --git a/src/vendor/golang.org/x/text/runes/cond.go b/vendor/golang.org/x/text/runes/cond.go similarity index 100% rename from src/vendor/golang.org/x/text/runes/cond.go rename to vendor/golang.org/x/text/runes/cond.go diff --git a/src/vendor/golang.org/x/text/runes/runes.go b/vendor/golang.org/x/text/runes/runes.go similarity index 100% rename from src/vendor/golang.org/x/text/runes/runes.go rename to vendor/golang.org/x/text/runes/runes.go diff --git a/src/vendor/golang.org/x/text/transform/transform.go b/vendor/golang.org/x/text/transform/transform.go similarity index 100% rename from src/vendor/golang.org/x/text/transform/transform.go rename to vendor/golang.org/x/text/transform/transform.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/base.go b/vendor/golang.org/x/text/unicode/cldr/base.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/base.go rename to vendor/golang.org/x/text/unicode/cldr/base.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/cldr.go b/vendor/golang.org/x/text/unicode/cldr/cldr.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/cldr.go rename to vendor/golang.org/x/text/unicode/cldr/cldr.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/cldr_test.go b/vendor/golang.org/x/text/unicode/cldr/cldr_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/cldr_test.go rename to vendor/golang.org/x/text/unicode/cldr/cldr_test.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/collate.go b/vendor/golang.org/x/text/unicode/cldr/collate.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/collate.go rename to vendor/golang.org/x/text/unicode/cldr/collate.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/collate_test.go b/vendor/golang.org/x/text/unicode/cldr/collate_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/collate_test.go rename to vendor/golang.org/x/text/unicode/cldr/collate_test.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/data_test.go b/vendor/golang.org/x/text/unicode/cldr/data_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/data_test.go rename to vendor/golang.org/x/text/unicode/cldr/data_test.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/decode.go b/vendor/golang.org/x/text/unicode/cldr/decode.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/decode.go rename to vendor/golang.org/x/text/unicode/cldr/decode.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/examples_test.go b/vendor/golang.org/x/text/unicode/cldr/examples_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/examples_test.go rename to vendor/golang.org/x/text/unicode/cldr/examples_test.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/makexml.go b/vendor/golang.org/x/text/unicode/cldr/makexml.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/makexml.go rename to vendor/golang.org/x/text/unicode/cldr/makexml.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/resolve.go b/vendor/golang.org/x/text/unicode/cldr/resolve.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/resolve.go rename to vendor/golang.org/x/text/unicode/cldr/resolve.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/resolve_test.go b/vendor/golang.org/x/text/unicode/cldr/resolve_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/resolve_test.go rename to vendor/golang.org/x/text/unicode/cldr/resolve_test.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/slice.go b/vendor/golang.org/x/text/unicode/cldr/slice.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/slice.go rename to vendor/golang.org/x/text/unicode/cldr/slice.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/slice_test.go b/vendor/golang.org/x/text/unicode/cldr/slice_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/slice_test.go rename to vendor/golang.org/x/text/unicode/cldr/slice_test.go diff --git a/src/vendor/golang.org/x/text/unicode/cldr/xml.go b/vendor/golang.org/x/text/unicode/cldr/xml.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/cldr/xml.go rename to vendor/golang.org/x/text/unicode/cldr/xml.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/composition.go b/vendor/golang.org/x/text/unicode/norm/composition.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/composition.go rename to vendor/golang.org/x/text/unicode/norm/composition.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/composition_test.go b/vendor/golang.org/x/text/unicode/norm/composition_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/composition_test.go rename to vendor/golang.org/x/text/unicode/norm/composition_test.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/example_iter_test.go b/vendor/golang.org/x/text/unicode/norm/example_iter_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/example_iter_test.go rename to vendor/golang.org/x/text/unicode/norm/example_iter_test.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/forminfo.go b/vendor/golang.org/x/text/unicode/norm/forminfo.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/forminfo.go rename to vendor/golang.org/x/text/unicode/norm/forminfo.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/forminfo_test.go b/vendor/golang.org/x/text/unicode/norm/forminfo_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/forminfo_test.go rename to vendor/golang.org/x/text/unicode/norm/forminfo_test.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/input.go b/vendor/golang.org/x/text/unicode/norm/input.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/input.go rename to vendor/golang.org/x/text/unicode/norm/input.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/iter.go b/vendor/golang.org/x/text/unicode/norm/iter.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/iter.go rename to vendor/golang.org/x/text/unicode/norm/iter.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/iter_test.go b/vendor/golang.org/x/text/unicode/norm/iter_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/iter_test.go rename to vendor/golang.org/x/text/unicode/norm/iter_test.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/maketables.go b/vendor/golang.org/x/text/unicode/norm/maketables.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/maketables.go rename to vendor/golang.org/x/text/unicode/norm/maketables.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/norm_test.go b/vendor/golang.org/x/text/unicode/norm/norm_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/norm_test.go rename to vendor/golang.org/x/text/unicode/norm/norm_test.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/normalize.go b/vendor/golang.org/x/text/unicode/norm/normalize.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/normalize.go rename to vendor/golang.org/x/text/unicode/norm/normalize.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/normalize_test.go b/vendor/golang.org/x/text/unicode/norm/normalize_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/normalize_test.go rename to vendor/golang.org/x/text/unicode/norm/normalize_test.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/readwriter.go b/vendor/golang.org/x/text/unicode/norm/readwriter.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/readwriter.go rename to vendor/golang.org/x/text/unicode/norm/readwriter.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/readwriter_test.go b/vendor/golang.org/x/text/unicode/norm/readwriter_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/readwriter_test.go rename to vendor/golang.org/x/text/unicode/norm/readwriter_test.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/tables.go b/vendor/golang.org/x/text/unicode/norm/tables.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/tables.go rename to vendor/golang.org/x/text/unicode/norm/tables.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/transform.go b/vendor/golang.org/x/text/unicode/norm/transform.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/transform.go rename to vendor/golang.org/x/text/unicode/norm/transform.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/transform_test.go b/vendor/golang.org/x/text/unicode/norm/transform_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/transform_test.go rename to vendor/golang.org/x/text/unicode/norm/transform_test.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/trie.go b/vendor/golang.org/x/text/unicode/norm/trie.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/trie.go rename to vendor/golang.org/x/text/unicode/norm/trie.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/triegen.go b/vendor/golang.org/x/text/unicode/norm/triegen.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/triegen.go rename to vendor/golang.org/x/text/unicode/norm/triegen.go diff --git a/src/vendor/golang.org/x/text/unicode/norm/ucd_test.go b/vendor/golang.org/x/text/unicode/norm/ucd_test.go similarity index 100% rename from src/vendor/golang.org/x/text/unicode/norm/ucd_test.go rename to vendor/golang.org/x/text/unicode/norm/ucd_test.go diff --git a/src/vendor/golang.org/x/tools/LICENSE b/vendor/golang.org/x/tools/LICENSE similarity index 100% rename from src/vendor/golang.org/x/tools/LICENSE rename to vendor/golang.org/x/tools/LICENSE diff --git a/src/vendor/golang.org/x/tools/PATENTS b/vendor/golang.org/x/tools/PATENTS similarity index 100% rename from src/vendor/golang.org/x/tools/PATENTS rename to vendor/golang.org/x/tools/PATENTS diff --git a/src/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go b/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go similarity index 100% rename from src/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go rename to vendor/golang.org/x/tools/go/ast/astutil/enclosing.go diff --git a/src/vendor/golang.org/x/tools/go/ast/astutil/imports.go b/vendor/golang.org/x/tools/go/ast/astutil/imports.go similarity index 100% rename from src/vendor/golang.org/x/tools/go/ast/astutil/imports.go rename to vendor/golang.org/x/tools/go/ast/astutil/imports.go diff --git a/src/vendor/golang.org/x/tools/go/ast/astutil/util.go b/vendor/golang.org/x/tools/go/ast/astutil/util.go similarity index 100% rename from src/vendor/golang.org/x/tools/go/ast/astutil/util.go rename to vendor/golang.org/x/tools/go/ast/astutil/util.go diff --git a/src/vendor/golang.org/x/tools/imports/fix.go b/vendor/golang.org/x/tools/imports/fix.go similarity index 100% rename from src/vendor/golang.org/x/tools/imports/fix.go rename to vendor/golang.org/x/tools/imports/fix.go diff --git a/src/vendor/golang.org/x/tools/imports/imports.go b/vendor/golang.org/x/tools/imports/imports.go similarity index 100% rename from src/vendor/golang.org/x/tools/imports/imports.go rename to vendor/golang.org/x/tools/imports/imports.go diff --git a/src/vendor/golang.org/x/tools/imports/mkindex.go b/vendor/golang.org/x/tools/imports/mkindex.go similarity index 100% rename from src/vendor/golang.org/x/tools/imports/mkindex.go rename to vendor/golang.org/x/tools/imports/mkindex.go diff --git a/src/vendor/golang.org/x/tools/imports/mkstdlib.go b/vendor/golang.org/x/tools/imports/mkstdlib.go similarity index 100% rename from src/vendor/golang.org/x/tools/imports/mkstdlib.go rename to vendor/golang.org/x/tools/imports/mkstdlib.go diff --git a/src/vendor/golang.org/x/tools/imports/sortimports.go b/vendor/golang.org/x/tools/imports/sortimports.go similarity index 100% rename from src/vendor/golang.org/x/tools/imports/sortimports.go rename to vendor/golang.org/x/tools/imports/sortimports.go diff --git a/src/vendor/golang.org/x/tools/imports/zstdlib.go b/vendor/golang.org/x/tools/imports/zstdlib.go similarity index 100% rename from src/vendor/golang.org/x/tools/imports/zstdlib.go rename to vendor/golang.org/x/tools/imports/zstdlib.go diff --git a/src/vendor/gopkg.in/fatih/set.v0/.travis.yml b/vendor/gopkg.in/fatih/set.v0/.travis.yml similarity index 100% rename from src/vendor/gopkg.in/fatih/set.v0/.travis.yml rename to vendor/gopkg.in/fatih/set.v0/.travis.yml diff --git a/src/vendor/gopkg.in/fatih/set.v0/LICENSE.md b/vendor/gopkg.in/fatih/set.v0/LICENSE.md similarity index 100% rename from src/vendor/gopkg.in/fatih/set.v0/LICENSE.md rename to vendor/gopkg.in/fatih/set.v0/LICENSE.md diff --git a/src/vendor/gopkg.in/fatih/set.v0/README.md b/vendor/gopkg.in/fatih/set.v0/README.md similarity index 100% rename from src/vendor/gopkg.in/fatih/set.v0/README.md rename to vendor/gopkg.in/fatih/set.v0/README.md diff --git a/src/vendor/gopkg.in/fatih/set.v0/set.go b/vendor/gopkg.in/fatih/set.v0/set.go similarity index 100% rename from src/vendor/gopkg.in/fatih/set.v0/set.go rename to vendor/gopkg.in/fatih/set.v0/set.go diff --git a/src/vendor/gopkg.in/fatih/set.v0/set_nots.go b/vendor/gopkg.in/fatih/set.v0/set_nots.go similarity index 100% rename from src/vendor/gopkg.in/fatih/set.v0/set_nots.go rename to vendor/gopkg.in/fatih/set.v0/set_nots.go diff --git a/src/vendor/gopkg.in/fatih/set.v0/set_ts.go b/vendor/gopkg.in/fatih/set.v0/set_ts.go similarity index 100% rename from src/vendor/gopkg.in/fatih/set.v0/set_ts.go rename to vendor/gopkg.in/fatih/set.v0/set_ts.go diff --git a/src/vendor/gopkg.in/karalabe/cookiejar.v2/LICENSE b/vendor/gopkg.in/karalabe/cookiejar.v2/LICENSE similarity index 100% rename from src/vendor/gopkg.in/karalabe/cookiejar.v2/LICENSE rename to vendor/gopkg.in/karalabe/cookiejar.v2/LICENSE diff --git a/src/vendor/gopkg.in/karalabe/cookiejar.v2/collections/prque/prque.go b/vendor/gopkg.in/karalabe/cookiejar.v2/collections/prque/prque.go similarity index 100% rename from src/vendor/gopkg.in/karalabe/cookiejar.v2/collections/prque/prque.go rename to vendor/gopkg.in/karalabe/cookiejar.v2/collections/prque/prque.go diff --git a/src/vendor/gopkg.in/karalabe/cookiejar.v2/collections/prque/sstack.go b/vendor/gopkg.in/karalabe/cookiejar.v2/collections/prque/sstack.go similarity index 100% rename from src/vendor/gopkg.in/karalabe/cookiejar.v2/collections/prque/sstack.go rename to vendor/gopkg.in/karalabe/cookiejar.v2/collections/prque/sstack.go diff --git a/src/vendor/gopkg.in/sourcemap.v1/.travis.yml b/vendor/gopkg.in/sourcemap.v1/.travis.yml similarity index 100% rename from src/vendor/gopkg.in/sourcemap.v1/.travis.yml rename to vendor/gopkg.in/sourcemap.v1/.travis.yml diff --git a/src/vendor/gopkg.in/sourcemap.v1/Makefile b/vendor/gopkg.in/sourcemap.v1/Makefile similarity index 100% rename from src/vendor/gopkg.in/sourcemap.v1/Makefile rename to vendor/gopkg.in/sourcemap.v1/Makefile diff --git a/src/vendor/gopkg.in/sourcemap.v1/README.md b/vendor/gopkg.in/sourcemap.v1/README.md similarity index 100% rename from src/vendor/gopkg.in/sourcemap.v1/README.md rename to vendor/gopkg.in/sourcemap.v1/README.md diff --git a/src/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go b/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go similarity index 100% rename from src/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go rename to vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go diff --git a/src/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq_test.go b/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq_test.go similarity index 100% rename from src/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq_test.go rename to vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq_test.go diff --git a/src/vendor/gopkg.in/sourcemap.v1/consumer.go b/vendor/gopkg.in/sourcemap.v1/consumer.go similarity index 100% rename from src/vendor/gopkg.in/sourcemap.v1/consumer.go rename to vendor/gopkg.in/sourcemap.v1/consumer.go diff --git a/src/vendor/gopkg.in/sourcemap.v1/consumer_test.go b/vendor/gopkg.in/sourcemap.v1/consumer_test.go similarity index 100% rename from src/vendor/gopkg.in/sourcemap.v1/consumer_test.go rename to vendor/gopkg.in/sourcemap.v1/consumer_test.go diff --git a/src/vendor/gopkg.in/sourcemap.v1/example_test.go b/vendor/gopkg.in/sourcemap.v1/example_test.go similarity index 100% rename from src/vendor/gopkg.in/sourcemap.v1/example_test.go rename to vendor/gopkg.in/sourcemap.v1/example_test.go diff --git a/src/vendor/gopkg.in/urfave/cli.v1/.gitignore b/vendor/gopkg.in/urfave/cli.v1/.gitignore similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/.gitignore rename to vendor/gopkg.in/urfave/cli.v1/.gitignore diff --git a/src/vendor/gopkg.in/urfave/cli.v1/.travis.yml b/vendor/gopkg.in/urfave/cli.v1/.travis.yml similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/.travis.yml rename to vendor/gopkg.in/urfave/cli.v1/.travis.yml diff --git a/src/vendor/gopkg.in/urfave/cli.v1/CHANGELOG.md b/vendor/gopkg.in/urfave/cli.v1/CHANGELOG.md similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/CHANGELOG.md rename to vendor/gopkg.in/urfave/cli.v1/CHANGELOG.md diff --git a/src/vendor/gopkg.in/urfave/cli.v1/LICENSE b/vendor/gopkg.in/urfave/cli.v1/LICENSE similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/LICENSE rename to vendor/gopkg.in/urfave/cli.v1/LICENSE diff --git a/src/vendor/gopkg.in/urfave/cli.v1/README.md b/vendor/gopkg.in/urfave/cli.v1/README.md similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/README.md rename to vendor/gopkg.in/urfave/cli.v1/README.md diff --git a/src/vendor/gopkg.in/urfave/cli.v1/app.go b/vendor/gopkg.in/urfave/cli.v1/app.go similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/app.go rename to vendor/gopkg.in/urfave/cli.v1/app.go diff --git a/src/vendor/gopkg.in/urfave/cli.v1/appveyor.yml b/vendor/gopkg.in/urfave/cli.v1/appveyor.yml similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/appveyor.yml rename to vendor/gopkg.in/urfave/cli.v1/appveyor.yml diff --git a/src/vendor/gopkg.in/urfave/cli.v1/category.go b/vendor/gopkg.in/urfave/cli.v1/category.go similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/category.go rename to vendor/gopkg.in/urfave/cli.v1/category.go diff --git a/src/vendor/gopkg.in/urfave/cli.v1/cli.go b/vendor/gopkg.in/urfave/cli.v1/cli.go similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/cli.go rename to vendor/gopkg.in/urfave/cli.v1/cli.go diff --git a/src/vendor/gopkg.in/urfave/cli.v1/command.go b/vendor/gopkg.in/urfave/cli.v1/command.go similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/command.go rename to vendor/gopkg.in/urfave/cli.v1/command.go diff --git a/src/vendor/gopkg.in/urfave/cli.v1/context.go b/vendor/gopkg.in/urfave/cli.v1/context.go similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/context.go rename to vendor/gopkg.in/urfave/cli.v1/context.go diff --git a/src/vendor/gopkg.in/urfave/cli.v1/errors.go b/vendor/gopkg.in/urfave/cli.v1/errors.go similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/errors.go rename to vendor/gopkg.in/urfave/cli.v1/errors.go diff --git a/src/vendor/gopkg.in/urfave/cli.v1/flag.go b/vendor/gopkg.in/urfave/cli.v1/flag.go similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/flag.go rename to vendor/gopkg.in/urfave/cli.v1/flag.go diff --git a/src/vendor/gopkg.in/urfave/cli.v1/funcs.go b/vendor/gopkg.in/urfave/cli.v1/funcs.go similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/funcs.go rename to vendor/gopkg.in/urfave/cli.v1/funcs.go diff --git a/src/vendor/gopkg.in/urfave/cli.v1/help.go b/vendor/gopkg.in/urfave/cli.v1/help.go similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/help.go rename to vendor/gopkg.in/urfave/cli.v1/help.go diff --git a/src/vendor/gopkg.in/urfave/cli.v1/runtests b/vendor/gopkg.in/urfave/cli.v1/runtests similarity index 100% rename from src/vendor/gopkg.in/urfave/cli.v1/runtests rename to vendor/gopkg.in/urfave/cli.v1/runtests From edd8763c3c03a66f25eebbb6a4edeb0e528f5b34 Mon Sep 17 00:00:00 2001 From: Victor Farazdagi Date: Sun, 11 Sep 2016 14:44:14 +0300 Subject: [PATCH 2/3] Major code refactoring - geth package implemented - jail package implemented (and tested) - cgo and xgo (android, ios) builds w/o any issues - better conditional compilation of signals code --- .gitignore | 9 +- Makefile | 39 +- build/env.sh | 2 +- {src => cmd/status}/library.go | 121 ++-- {src => cmd/status}/main.go | 0 common/utils.go | 26 - {src/data => data}/static-nodes.json | 0 {src/data => data}/test-account.pk | 0 extkeys/mnemonic_test.go | 1 + src/gethdep.go => geth/accounts.go | 167 ++--- geth/accounts_test.go | 308 +++++++++ geth/node.go | 281 ++++++++ geth/node_test.go | 26 + geth/signals.c | 181 +++++ geth/txqueue.go | 43 ++ geth/txqueue_test.go | 149 +++++ {common => geth}/types.go | 4 +- geth/utils.go | 161 +++++ geth/whisper.go | 69 ++ geth/whisper_test.go | 164 +++++ jail/jail.go | 259 +++++++ jail/jail_test.go | 242 +++++++ jail/testdata/commands.js | 320 +++++++++ jail/testdata/status.js | 155 +++++ {src => jail}/web3.go | 2 +- src/Godeps/Godeps.json | 500 -------------- src/Godeps/Readme | 5 - src/gethdep_test.go | 631 ------------------ src/jail.go | 207 ------ src/library.c | 170 ----- src/node.go | 162 ----- src/whisper.go | 62 -- .../go-ethereum/accounts/account_manager.go | 2 +- .../ethereum/go-ethereum/accounts/key.go | 2 +- .../accounts/key_store_passphrase.go | 2 +- xgo/base/Dockerfile | 2 +- xgo/base/build.sh | 27 +- 37 files changed, 2522 insertions(+), 1979 deletions(-) rename {src => cmd/status}/library.go (62%) rename {src => cmd/status}/main.go (100%) delete mode 100644 common/utils.go rename {src/data => data}/static-nodes.json (100%) rename {src/data => data}/test-account.pk (100%) rename src/gethdep.go => geth/accounts.go (59%) create mode 100644 geth/accounts_test.go create mode 100644 geth/node.go create mode 100644 geth/node_test.go create mode 100644 geth/signals.c create mode 100644 geth/txqueue.go create mode 100644 geth/txqueue_test.go rename {common => geth}/types.go (94%) create mode 100644 geth/utils.go create mode 100644 geth/whisper.go create mode 100644 geth/whisper_test.go create mode 100644 jail/jail.go create mode 100644 jail/jail_test.go create mode 100644 jail/testdata/commands.js create mode 100644 jail/testdata/status.js rename {src => jail}/web3.go (99%) delete mode 100644 src/Godeps/Godeps.json delete mode 100644 src/Godeps/Readme delete mode 100644 src/gethdep_test.go delete mode 100644 src/jail.go delete mode 100644 src/library.c delete mode 100644 src/node.go delete mode 100644 src/whisper.go diff --git a/.gitignore b/.gitignore index c1b6a5eb5..f5f106634 100644 --- a/.gitignore +++ b/.gitignore @@ -13,8 +13,6 @@ .ethtest */**/*tx_database* */**/*dapps* -Godeps/_workspace/pkg -Godeps/_workspace/bin #* .#* @@ -35,8 +33,9 @@ profile.cov .vagrant # tests -src/.ethereumtest/ +.ethereumtest/ # # golang -cover.out -cover.html +coverage.out +coverage-all.out +coverage.html diff --git a/Makefile b/Makefile index 7acdf8817..65a32a292 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ GOBIN = build/bin GO ?= latest statusgo: - build/env.sh go build -i -o $(GOBIN)/statusgo -v $(shell build/flags.sh) ./src + build/env.sh go build -i -o $(GOBIN)/statusgo -v $(shell build/flags.sh) ./cmd/status @echo "status go compilation done." @echo "Run \"build/bin/statusgo\" to view available commands" @@ -14,25 +14,48 @@ statusgo-cross: statusgo-android statusgo-ios @ls -ld $(GOBIN)/statusgo-* statusgo-android: xgo - build/env.sh $(GOBIN)/xgo --image farazdagi/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=android-16/aar -v $(shell build/flags.sh) ./src + build/env.sh $(GOBIN)/xgo --image farazdagi/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=android-16/aar -v $(shell build/flags.sh) ./cmd/status @echo "Android cross compilation done:" statusgo-ios: xgo - build/env.sh $(GOBIN)/xgo --image farazdagi/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v $(shell build/flags.sh) ./src + build/env.sh $(GOBIN)/xgo --image farazdagi/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v $(shell build/flags.sh) ./cmd/status @echo "iOS framework cross compilation done:" statusgo-ios-simulator: xgo - build/env.sh $(GOBIN)/xgo --image farazdagi/xgo-ios-simulator --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v $(shell build/flags.sh) ./src + build/env.sh $(GOBIN)/xgo --image farazdagi/xgo-ios-simulator --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v $(shell build/flags.sh) ./cmd/status @echo "iOS framework cross compilation done:" xgo: build/env.sh go get github.com/karalabe/xgo -test: - build/env.sh go test -v -coverprofile=cover.out ./src +test-all: + @build/env.sh echo "mode: set" > coverage-all.out + build/env.sh go test -coverprofile=coverage.out -covermode=set ./geth + @build/env.sh tail -n +2 coverage.out >> coverage-all.out + build/env.sh go test -coverprofile=coverage.out -covermode=set ./jail + @build/env.sh tail -n +2 coverage.out >> coverage-all.out + build/env.sh go test -coverprofile=coverage.out -covermode=set ./extkeys + @build/env.sh tail -n +2 coverage.out >> coverage-all.out + @build/env.sh go tool cover -html=coverage-all.out -o coverage.html + @build/env.sh go tool cover -func=coverage-all.out -test-cover: test - build/env.sh go tool cover -html=cover.out -o cover.html +test: test-all + +test-geth: + build/env.sh go test -v -coverprofile=coverage.out ./geth + @build/env.sh go tool cover -html=coverage.out -o coverage.html + @build/env.sh go tool cover -func=coverage.out + +test-jail: + build/env.sh go test -v -coverprofile=coverage.out ./jail + @build/env.sh go tool cover -html=coverage.out -o coverage.html + @build/env.sh go tool cover -func=coverage.out + +test-extkeys: + build/env.sh go test -v -coverprofile=coverage.out ./extkeys + @build/env.sh go tool cover -html=coverage.out -o coverage.html + @build/env.sh go tool cover -func=coverage.out clean: rm -fr build/bin/* + rm coverage.out coverage-all.out coverage.html diff --git a/build/env.sh b/build/env.sh index 89e174e65..8591d6e8e 100755 --- a/build/env.sh +++ b/build/env.sh @@ -16,7 +16,7 @@ WS2="$ROOT/build/_workspace/project" if [ ! -d "$WS1/src" ]; then mkdir -p "$WS1" cd "$WS1" - ln -s "$ROOT/src/vendor" src + ln -s "$ROOT/vendor" src cd "$ROOT" fi diff --git a/src/library.go b/cmd/status/library.go similarity index 62% rename from src/library.go rename to cmd/status/library.go index b5739fcad..466d2a2d7 100644 --- a/src/library.go +++ b/cmd/status/library.go @@ -1,29 +1,39 @@ package main +/* +#include +#include +extern bool StatusServiceSignalEvent(const char *jsonEvent); +*/ import "C" import ( "encoding/json" "fmt" - "github.com/ethereum/go-ethereum/whisper" "os" + + "github.com/ethereum/go-ethereum/whisper" + "github.com/status-im/status-go/geth" + "github.com/status-im/status-go/jail" ) -var emptyError = "" +// export TriggerTestSignal +func TriggerTestSignal() { + C.StatusServiceSignalEvent(C.CString(`{"answer": 42}`)) +} //export CreateAccount func CreateAccount(password *C.char) *C.char { - // This is equivalent to creating an account from the command line, // just modified to handle the function arg passing - address, pubKey, mnemonic, err := createAccount(C.GoString(password)) + address, pubKey, mnemonic, err := geth.CreateAccount(C.GoString(password)) - errString := emptyError + errString := "" if err != nil { fmt.Fprintln(os.Stderr, err) errString = err.Error() } - out := AccountInfo{ + out := geth.AccountInfo{ Address: address, PubKey: pubKey, Mnemonic: mnemonic, @@ -37,15 +47,15 @@ func CreateAccount(password *C.char) *C.char { //export CreateChildAccount func CreateChildAccount(parentAddress, password *C.char) *C.char { - address, pubKey, err := createChildAccount(C.GoString(parentAddress), C.GoString(password)) + address, pubKey, err := geth.CreateChildAccount(C.GoString(parentAddress), C.GoString(password)) - errString := emptyError + errString := "" if err != nil { fmt.Fprintln(os.Stderr, err) errString = err.Error() } - out := AccountInfo{ + out := geth.AccountInfo{ Address: address, PubKey: pubKey, Error: errString, @@ -58,15 +68,15 @@ func CreateChildAccount(parentAddress, password *C.char) *C.char { //export RecoverAccount func RecoverAccount(password, mnemonic *C.char) *C.char { - address, pubKey, err := recoverAccount(C.GoString(password), C.GoString(mnemonic)) + address, pubKey, err := geth.RecoverAccount(C.GoString(password), C.GoString(mnemonic)) - errString := emptyError + errString := "" if err != nil { fmt.Fprintln(os.Stderr, err) errString = err.Error() } - out := AccountInfo{ + out := geth.AccountInfo{ Address: address, PubKey: pubKey, Mnemonic: C.GoString(mnemonic), @@ -81,15 +91,15 @@ func RecoverAccount(password, mnemonic *C.char) *C.char { func Login(address, password *C.char) *C.char { // loads a key file (for a given address), tries to decrypt it using the password, to verify ownership // if verified, purges all the previous identities from Whisper, and injects verified key as shh identity - err := selectAccount(C.GoString(address), C.GoString(password)) + err := geth.SelectAccount(C.GoString(address), C.GoString(password)) - errString := emptyError + errString := "" if err != nil { fmt.Fprintln(os.Stderr, err) errString = err.Error() } - out := JSONError{ + out := geth.JSONError{ Error: errString, } outBytes, _ := json.Marshal(&out) @@ -101,15 +111,15 @@ func Login(address, password *C.char) *C.char { func Logout() *C.char { // This is equivalent to clearing whisper identities - err := logout() + err := geth.Logout() - errString := emptyError + errString := "" if err != nil { fmt.Fprintln(os.Stderr, err) errString = err.Error() } - out := JSONError{ + out := geth.JSONError{ Error: errString, } outBytes, _ := json.Marshal(&out) @@ -123,15 +133,15 @@ func UnlockAccount(address, password *C.char, seconds int) *C.char { // This is equivalent to unlocking an account from the command line, // just modified to unlock the account for the currently running geth node // based on the provided arguments - err := unlockAccount(C.GoString(address), C.GoString(password), seconds) + err := geth.UnlockAccount(C.GoString(address), C.GoString(password), seconds) - errString := emptyError + errString := "" if err != nil { fmt.Fprintln(os.Stderr, err) errString = err.Error() } - out := JSONError{ + out := geth.JSONError{ Error: errString, } outBytes, _ := json.Marshal(&out) @@ -141,15 +151,15 @@ func UnlockAccount(address, password *C.char, seconds int) *C.char { //export CompleteTransaction func CompleteTransaction(id, password *C.char) *C.char { - txHash, err := completeTransaction(C.GoString(id), C.GoString(password)) + txHash, err := geth.CompleteTransaction(C.GoString(id), C.GoString(password)) - errString := emptyError + errString := "" if err != nil { fmt.Fprintln(os.Stderr, err) errString = err.Error() } - out := CompleteTransactionResult{ + out := geth.CompleteTransactionResult{ Hash: txHash.Hex(), Error: errString, } @@ -160,17 +170,16 @@ func CompleteTransaction(id, password *C.char) *C.char { //export StartNode func StartNode(datadir *C.char) *C.char { - // This starts a geth node with the given datadir - err := createAndStartNode(C.GoString(datadir)) + err := geth.CreateAndRunNode(C.GoString(datadir), geth.RPCPort) - errString := emptyError + errString := "" if err != nil { fmt.Fprintln(os.Stderr, err) errString = err.Error() } - out := JSONError{ + out := geth.JSONError{ Error: errString, } outBytes, _ := json.Marshal(&out) @@ -178,33 +187,33 @@ func StartNode(datadir *C.char) *C.char { return C.CString(string(outBytes)) } -//export parse -func parse(chatId *C.char, js *C.char) *C.char { - res := Parse(C.GoString(chatId), C.GoString(js)) +//export InitJail +func InitJail(js *C.char) { + jail.Init(C.GoString(js)) +} + +//export Parse +func Parse(chatId *C.char, js *C.char) *C.char { + res := jail.GetInstance().Parse(C.GoString(chatId), C.GoString(js)) return C.CString(res) } -//export call -func call(chatId *C.char, path *C.char, params *C.char) *C.char { - res := Call(C.GoString(chatId), C.GoString(path), C.GoString(params)) +//export Call +func Call(chatId *C.char, path *C.char, params *C.char) *C.char { + res := jail.GetInstance().Call(C.GoString(chatId), C.GoString(path), C.GoString(params)) return C.CString(res) } -//export initJail -func initJail(js *C.char) { - Init(C.GoString(js)) -} - -//export addPeer -func addPeer(url *C.char) *C.char { - success, err := doAddPeer(C.GoString(url)) - errString := emptyError +//export AddPeer +func AddPeer(url *C.char) *C.char { + success, err := geth.GetNodeManager().AddPeer(C.GoString(url)) + errString := "" if err != nil { fmt.Fprintln(os.Stderr, err) errString = err.Error() } - out := AddPeerResult{ + out := geth.AddPeerResult{ Success: success, Error: errString, } @@ -213,24 +222,24 @@ func addPeer(url *C.char) *C.char { return C.CString(string(outBytes)) } -//export addWhisperFilter -func addWhisperFilter(filterJson *C.char) *C.char { +//export AddWhisperFilter +func AddWhisperFilter(filterJson *C.char) *C.char { var id int var filter whisper.NewFilterArgs err := json.Unmarshal([]byte(C.GoString(filterJson)), &filter) if err == nil { - id = doAddWhisperFilter(filter) + id = geth.AddWhisperFilter(filter) } - errString := emptyError + errString := "" if err != nil { fmt.Fprintln(os.Stderr, err) errString = err.Error() } - out := AddWhisperFilterResult{ + out := geth.AddWhisperFilterResult{ Id: id, Error: errString, } @@ -240,14 +249,12 @@ func addWhisperFilter(filterJson *C.char) *C.char { } -//export removeWhisperFilter -func removeWhisperFilter(idFilter int) { - - doRemoveWhisperFilter(idFilter) +//export RemoveWhisperFilter +func RemoveWhisperFilter(idFilter int) { + geth.RemoveWhisperFilter(idFilter) } -//export clearWhisperFilters -func clearWhisperFilters() { - - doClearWhisperFilters() +//export ClearWhisperFilters +func ClearWhisperFilters() { + geth.ClearWhisperFilters() } diff --git a/src/main.go b/cmd/status/main.go similarity index 100% rename from src/main.go rename to cmd/status/main.go diff --git a/common/utils.go b/common/utils.go deleted file mode 100644 index 23354ee0e..000000000 --- a/common/utils.go +++ /dev/null @@ -1,26 +0,0 @@ -package common - -import ( - "io" - "os" -) - -func copyFile(dst, src string) error { - s, err := os.Open(src) - if err != nil { - return err - } - defer s.Close() - - d, err := os.Create(dst) - if err != nil { - return err - } - defer d.Close() - - if _, err := io.Copy(d, s); err != nil { - return err - } - - return nil -} diff --git a/src/data/static-nodes.json b/data/static-nodes.json similarity index 100% rename from src/data/static-nodes.json rename to data/static-nodes.json diff --git a/src/data/test-account.pk b/data/test-account.pk similarity index 100% rename from src/data/test-account.pk rename to data/test-account.pk diff --git a/extkeys/mnemonic_test.go b/extkeys/mnemonic_test.go index ca25ba168..6ac93f242 100644 --- a/extkeys/mnemonic_test.go +++ b/extkeys/mnemonic_test.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "testing" + "github.com/status-im/status-go/extkeys" ) diff --git a/src/gethdep.go b/geth/accounts.go similarity index 59% rename from src/gethdep.go rename to geth/accounts.go index f200eaf17..a5bf351ba 100644 --- a/src/gethdep.go +++ b/geth/accounts.go @@ -1,30 +1,16 @@ -package main - -/* -#include -#include -extern bool GethServiceSignalEvent( const char *jsonEvent ); -*/ -import "C" +package geth import ( - "encoding/json" "errors" "fmt" "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/les/status" - "github.com/ethereum/go-ethereum/p2p/discover" - errextra "github.com/pkg/errors" - "github.com/status-im/status-go/src/extkeys" + "github.com/status-im/status-go/extkeys" ) var ( - ErrInvalidGethNode = errors.New("no running node detected for account unlock") - ErrInvalidWhisperService = errors.New("whisper service is unavailable") - ErrInvalidAccountManager = errors.New("could not retrieve account manager") ErrAddressToAccountMappingFailure = errors.New("cannot retreive a valid account for a given address") ErrAccountToKeyMappingFailure = errors.New("cannot retreive a valid key for a given account") ErrUnlockCalled = errors.New("no need to unlock accounts, login instead") @@ -32,32 +18,25 @@ var ( ErrWhisperClearIdentitiesFailure = errors.New("failed to clear whisper identities") ErrWhisperNoIdentityFound = errors.New("failed to locate identity previously injected into Whisper") ErrNoAccountSelected = errors.New("no account has been selected, please login") + ErrInvalidMasterKeyCreated = errors.New("can not create master extended key") ) // createAccount creates an internal geth account // BIP44-compatible keys are generated: CKD#1 is stored as account key, CKD#2 stored as sub-account root // Public key of CKD#1 is returned, with CKD#2 securely encoded into account key file (to be used for // sub-account derivations) -func createAccount(password string) (address, pubKey, mnemonic string, err error) { - if currentNode == nil { - return "", "", "", ErrInvalidGethNode - } - - if accountManager == nil { - return "", "", "", ErrInvalidAccountManager - } - +func CreateAccount(password string) (address, pubKey, mnemonic string, err error) { // generate mnemonic phrase - m := extkeys.NewMnemonic() + m := extkeys.NewMnemonic(extkeys.Salt) mnemonic, err = m.MnemonicPhrase(128, extkeys.EnglishLanguage) if err != nil { - return "", "", "", errextra.Wrap(err, "Can not create mnemonic seed") + return "", "", "", fmt.Errorf("can not create mnemonic seed: %v", err) } // generate extended master key (see BIP32) extKey, err := extkeys.NewMaster(m.MnemonicSeed(mnemonic, password), []byte(extkeys.Salt)) if err != nil { - return "", "", "", errextra.Wrap(err, "Can not create master extended key") + return "", "", "", fmt.Errorf("can not create master extended key: %v", err) } // import created key into account keystore @@ -72,17 +51,15 @@ func createAccount(password string) (address, pubKey, mnemonic string, err error // createChildAccount creates sub-account for an account identified by parent address. // CKD#2 is used as root for master accounts (when parentAddress is ""). // Otherwise (when parentAddress != ""), child is derived directly from parent. -func createChildAccount(parentAddress, password string) (address, pubKey string, err error) { - if currentNode == nil { - return "", "", ErrInvalidGethNode - } - - if accountManager == nil { - return "", "", ErrInvalidAccountManager +func CreateChildAccount(parentAddress, password string) (address, pubKey string, err error) { + nodeManager := GetNodeManager() + accountManager, err := nodeManager.AccountManager() + if err != nil { + return "", "", err } if parentAddress == "" { // by default derive from currently selected account - parentAddress = selectedAddress + parentAddress = nodeManager.SelectedAddress } if parentAddress == "" { @@ -123,20 +100,12 @@ func createChildAccount(parentAddress, password string) (address, pubKey string, // recoverAccount re-creates master key using given details. // Once master key is re-generated, it is inserted into keystore (if not already there). -func recoverAccount(password, mnemonic string) (address, pubKey string, err error) { - if currentNode == nil { - return "", "", ErrInvalidGethNode - } - - if accountManager == nil { - return "", "", ErrInvalidAccountManager - } - +func RecoverAccount(password, mnemonic string) (address, pubKey string, err error) { // re-create extended key (see BIP32) - m := extkeys.NewMnemonic() + m := extkeys.NewMnemonic(extkeys.Salt) extKey, err := extkeys.NewMaster(m.MnemonicSeed(mnemonic, password), []byte(extkeys.Salt)) if err != nil { - return "", "", errextra.Wrap(err, "Can not create master extended key") + return "", "", ErrInvalidMasterKeyCreated } // import re-created key into account keystore @@ -151,14 +120,13 @@ func recoverAccount(password, mnemonic string) (address, pubKey string, err erro // selectAccount selects current account, by verifying that address has corresponding account which can be decrypted // using provided password. Once verification is done, decrypted key is injected into Whisper (as a single identity, // all previous identities are removed). -func selectAccount(address, password string) error { - if currentNode == nil { - return ErrInvalidGethNode +func SelectAccount(address, password string) error { + nodeManager := GetNodeManager() + accountManager, err := nodeManager.AccountManager() + if err != nil { + return err } - if accountManager == nil { - return ErrInvalidAccountManager - } account, err := utils.MakeAddress(accountManager, address) if err != nil { return ErrAddressToAccountMappingFailure @@ -169,34 +137,35 @@ func selectAccount(address, password string) error { return fmt.Errorf("%s: %v", ErrAccountToKeyMappingFailure.Error(), err) } - if whisperService == nil { - return ErrInvalidWhisperService + whisperService, err := nodeManager.WhisperService() + if err != nil { + return err } + if err := whisperService.InjectIdentity(accountKey.PrivateKey); err != nil { return ErrWhisperIdentityInjectionFailure } // persist address for easier recovery of currently selected key (from Whisper) - selectedAddress = address + nodeManager.SelectedAddress = address return nil } // logout clears whisper identities -func logout() error { - if currentNode == nil { - return ErrInvalidGethNode - } - if whisperService == nil { - return ErrInvalidWhisperService +func Logout() error { + nodeManager := GetNodeManager() + whisperService, err := nodeManager.WhisperService() + if err != nil { + return err } - err := whisperService.ClearIdentities() + err = whisperService.ClearIdentities() if err != nil { return fmt.Errorf("%s: %v", ErrWhisperClearIdentitiesFailure, err) } - selectedAddress = "" + nodeManager.SelectedAddress = "" return nil } @@ -204,85 +173,31 @@ func logout() error { // unlockAccount unlocks an existing account for a certain duration and // inject the account as a whisper identity if the account was created as // a whisper enabled account -func unlockAccount(address, password string, seconds int) error { - if currentNode == nil { - return ErrInvalidGethNode - } - +func UnlockAccount(address, password string, seconds int) error { return ErrUnlockCalled } // importExtendedKey processes incoming extended key, extracts required info and creates corresponding account key. // Once account key is formed, that key is put (if not already) into keystore i.e. key is *encoded* into key file. func importExtendedKey(extKey *extkeys.ExtendedKey, password string) (address, pubKey string, err error) { + accountManager, err := GetNodeManager().AccountManager() + if err != nil { + return "", "", err + } + // imports extended key, create key file (if necessary) account, err := accountManager.ImportExtendedKey(extKey, password) if err != nil { - return "", "", errextra.Wrap(err, "Account manager could not create the account") + return "", "", err } address = fmt.Sprintf("%x", account.Address) // obtain public key to return account, key, err := accountManager.AccountDecryptedKey(account, password) if err != nil { - return address, "", errextra.Wrap(err, "Could not recover the key") + return address, "", err } pubKey = common.ToHex(crypto.FromECDSAPub(&key.PrivateKey.PublicKey)) return } - -// createAndStartNode creates a node entity and starts the -// node running locally -func createAndStartNode(inputDir string) error { - - currentNode = MakeNode(inputDir) - if currentNode != nil { - RunNode(currentNode) - return nil - } - - return errors.New("Could not create the in-memory node object") - -} - -func doAddPeer(url string) (bool, error) { - server := currentNode.Server() - if server == nil { - return false, errors.New("node not started") - } - // Try to add the url as a static peer and return - node, err := discover.ParseNode(url) - if err != nil { - return false, fmt.Errorf("invalid enode: %v", err) - } - server.AddPeer(node) - return true, nil -} - -func onSendTransactionRequest(queuedTx status.QueuedTx) { - event := GethEvent{ - Type: "sendTransactionQueued", - Event: SendTransactionEvent{ - Id: string(queuedTx.Id), - Args: queuedTx.Args, - }, - } - - body, _ := json.Marshal(&event) - C.GethServiceSignalEvent(C.CString(string(body))) -} - -func completeTransaction(id, password string) (common.Hash, error) { - if currentNode != nil { - if lightEthereum != nil { - backend := lightEthereum.StatusBackend - - return backend.CompleteQueuedTransaction(status.QueuedTxId(id), password) - } - - return common.Hash{}, errors.New("can not retrieve LES service") - } - - return common.Hash{}, errors.New("can not complete transaction: no running node detected") -} diff --git a/geth/accounts_test.go b/geth/accounts_test.go new file mode 100644 index 000000000..2892d6a72 --- /dev/null +++ b/geth/accounts_test.go @@ -0,0 +1,308 @@ +package geth_test + +import ( + "errors" + "fmt" + "reflect" + "testing" + + "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "github.com/status-im/status-go/geth" +) + +func TestCreateChildAccount(t *testing.T) { + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + + accountManager, err := geth.GetNodeManager().AccountManager() + if err != nil { + t.Error(err) + return + } + + // create an account + address, pubKey, mnemonic, err := geth.CreateAccount(newAccountPassword) + if err != nil { + t.Errorf("could not create account: %v", err) + return + } + glog.V(logger.Info).Infof("Account created: {address: %s, key: %s, mnemonic:%s}", address, pubKey, mnemonic) + + account, err := utils.MakeAddress(accountManager, address) + if err != nil { + t.Errorf("can not get account from address: %v", err) + return + } + + // obtain decrypted key, and make sure that extended key (which will be used as root for sub-accounts) is present + account, key, err := accountManager.AccountDecryptedKey(account, newAccountPassword) + if err != nil { + t.Errorf("can not obtain decrypted account key: %v", err) + return + } + + if key.ExtendedKey == nil { + t.Error("CKD#2 has not been generated for new account") + return + } + + // try creating sub-account, w/o selecting main account i.e. w/o login to main account + _, _, err = geth.CreateChildAccount("", newAccountPassword) + if !reflect.DeepEqual(err, geth.ErrNoAccountSelected) { + t.Errorf("expected error is not returned (tried to create sub-account w/o login): %v", err) + return + } + + err = geth.SelectAccount(address, newAccountPassword) + if err != nil { + t.Errorf("Test failed: could not select account: %v", err) + return + } + + // try to create sub-account with wrong password + _, _, err = geth.CreateChildAccount("", "wrong password") + if !reflect.DeepEqual(err, errors.New("cannot retreive a valid key for a given account: could not decrypt key with given passphrase")) { + t.Errorf("expected error is not returned (tried to create sub-account with wrong password): %v", err) + return + } + + // create sub-account (from implicit parent) + subAccount1, subPubKey1, err := geth.CreateChildAccount("", newAccountPassword) + if err != nil { + t.Errorf("cannot create sub-account: %v", err) + return + } + + // make sure that sub-account index automatically progresses + subAccount2, subPubKey2, err := geth.CreateChildAccount("", newAccountPassword) + if err != nil { + t.Errorf("cannot create sub-account: %v", err) + } + if subAccount1 == subAccount2 || subPubKey1 == subPubKey2 { + t.Error("sub-account index auto-increament failed") + return + } + + // create sub-account (from explicit parent) + subAccount3, subPubKey3, err := geth.CreateChildAccount(subAccount2, newAccountPassword) + if err != nil { + t.Errorf("cannot create sub-account: %v", err) + } + if subAccount1 == subAccount3 || subPubKey1 == subPubKey3 || subAccount2 == subAccount3 || subPubKey2 == subPubKey3 { + t.Error("sub-account index auto-increament failed") + return + } +} + +func TestRecoverAccount(t *testing.T) { + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + + accountManager, _ := geth.GetNodeManager().AccountManager() + + // create an account + address, pubKey, mnemonic, err := geth.CreateAccount(newAccountPassword) + if err != nil { + t.Errorf("could not create account: %v", err) + return + } + glog.V(logger.Info).Infof("Account created: {address: %s, key: %s, mnemonic:%s}", address, pubKey, mnemonic) + + // try recovering using password + mnemonic + addressCheck, pubKeyCheck, err := geth.RecoverAccount(newAccountPassword, mnemonic) + if err != nil { + t.Errorf("recover account failed: %v", err) + return + } + if address != addressCheck || pubKey != pubKeyCheck { + t.Error("recover account details failed to pull the correct details") + } + + // now test recovering, but make sure that account/key file is removed i.e. simulate recovering on a new device + account, err := utils.MakeAddress(accountManager, address) + if err != nil { + t.Errorf("can not get account from address: %v", err) + } + + account, key, err := accountManager.AccountDecryptedKey(account, newAccountPassword) + if err != nil { + t.Errorf("can not obtain decrypted account key: %v", err) + return + } + extChild2String := key.ExtendedKey.String() + + if err := accountManager.DeleteAccount(account, newAccountPassword); err != nil { + t.Errorf("cannot remove account: %v", err) + } + + addressCheck, pubKeyCheck, err = geth.RecoverAccount(newAccountPassword, mnemonic) + if err != nil { + t.Errorf("recover account failed (for non-cached account): %v", err) + return + } + if address != addressCheck || pubKey != pubKeyCheck { + t.Error("recover account details failed to pull the correct details (for non-cached account)") + } + + // make sure that extended key exists and is imported ok too + account, key, err = accountManager.AccountDecryptedKey(account, newAccountPassword) + if err != nil { + t.Errorf("can not obtain decrypted account key: %v", err) + return + } + if extChild2String != key.ExtendedKey.String() { + t.Errorf("CKD#2 key mismatch, expected: %s, got: %s", extChild2String, key.ExtendedKey.String()) + } + + // make sure that calling import several times, just returns from cache (no error is expected) + addressCheck, pubKeyCheck, err = geth.RecoverAccount(newAccountPassword, mnemonic) + if err != nil { + t.Errorf("recover account failed (for non-cached account): %v", err) + return + } + if address != addressCheck || pubKey != pubKeyCheck { + t.Error("recover account details failed to pull the correct details (for non-cached account)") + } + + // time to login with recovered data + whisperService, err := geth.GetNodeManager().WhisperService() + if err != nil { + t.Errorf("whisper service not running: %v", err) + } + + // make sure that identity is not (yet injected) + if whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKeyCheck))) { + t.Error("identity already present in whisper") + } + err = geth.SelectAccount(addressCheck, newAccountPassword) + if err != nil { + t.Errorf("Test failed: could not select account: %v", err) + return + } + if !whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKeyCheck))) { + t.Errorf("identity not injected into whisper: %v", err) + } +} + +func TestAccountSelect(t *testing.T) { + + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + + // test to see if the account was injected in whisper + whisperService, err := geth.GetNodeManager().WhisperService() + if err != nil { + t.Errorf("whisper service not running: %v", err) + } + + // create an account + address1, pubKey1, _, err := geth.CreateAccount(newAccountPassword) + if err != nil { + t.Errorf("could not create account: %v", err) + return + } + glog.V(logger.Info).Infof("Account created: {address: %s, key: %s}", address1, pubKey1) + + address2, pubKey2, _, err := geth.CreateAccount(newAccountPassword) + if err != nil { + fmt.Println(err.Error()) + t.Error("Test failed: could not create account") + return + } + glog.V(logger.Info).Infof("Account created: {address: %s, key: %s}", address2, pubKey2) + + // make sure that identity is not (yet injected) + if whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKey1))) { + t.Error("identity already present in whisper") + } + + // try selecting with wrong password + err = geth.SelectAccount(address1, "wrongPassword") + if err == nil { + t.Error("select account is expected to throw error: wrong password used") + return + } + err = geth.SelectAccount(address1, newAccountPassword) + if err != nil { + t.Errorf("Test failed: could not select account: %v", err) + return + } + if !whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKey1))) { + t.Errorf("identity not injected into whisper: %v", err) + } + + // select another account, make sure that previous account is wiped out from Whisper cache + if whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKey2))) { + t.Error("identity already present in whisper") + } + err = geth.SelectAccount(address2, newAccountPassword) + if err != nil { + t.Errorf("Test failed: could not select account: %v", err) + return + } + if !whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKey2))) { + t.Errorf("identity not injected into whisper: %v", err) + } + if whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKey1))) { + t.Error("identity should be removed, but it is still present in whisper") + } +} + +func TestAccountLogout(t *testing.T) { + + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + + whisperService, err := geth.GetNodeManager().WhisperService() + if err != nil { + t.Errorf("whisper service not running: %v", err) + } + + // create an account + address, pubKey, _, err := geth.CreateAccount(newAccountPassword) + if err != nil { + t.Errorf("could not create account: %v", err) + return + } + + // make sure that identity doesn't exist (yet) in Whisper + if whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKey))) { + t.Error("identity already present in whisper") + } + + // select/login + err = geth.SelectAccount(address, newAccountPassword) + if err != nil { + t.Errorf("Test failed: could not select account: %v", err) + return + } + if !whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKey))) { + t.Error("identity not injected into whisper") + } + + err = geth.Logout() + if err != nil { + t.Errorf("cannot logout: %v", err) + } + + // now, logout and check if identity is removed indeed + if whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKey))) { + t.Error("identity not cleared from whisper") + } +} diff --git a/geth/node.go b/geth/node.go new file mode 100644 index 000000000..7fbde6b32 --- /dev/null +++ b/geth/node.go @@ -0,0 +1,281 @@ +package geth + +import ( + "errors" + "flag" + "fmt" + "runtime" + "sync" + + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/les" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/release" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rpc" + "github.com/ethereum/go-ethereum/whisper" + "gopkg.in/urfave/cli.v1" +) + +const ( + clientIdentifier = "Geth" // Client identifier to advertise over the network + versionMajor = 1 // Major version component of the current release + versionMinor = 5 // Minor version component of the current release + versionPatch = 0 // Patch version component of the current release + versionMeta = "unstable" // Version metadata to append to the version string + + versionOracle = "0xfa7b9770ca4cb04296cac84f37736d4041251cdf" // Ethereum address of the Geth release oracle + + RPCPort = 8545 // RPC port (replaced in unit tests) +) + +var ( + ErrDataDirPreprocessingFailed = errors.New("failed to pre-process data directory") + ErrInvalidGethNode = errors.New("no running geth node detected") + ErrInvalidAccountManager = errors.New("could not retrieve account manager") + ErrInvalidWhisperService = errors.New("whisper service is unavailable") + ErrInvalidLightEthereumService = errors.New("can not retrieve LES service") + ErrInvalidClient = errors.New("RPC client is not properly initialized") + ErrNodeStartFailure = errors.New("could not create the in-memory node object") +) + +type NodeNotificationHandler func(jsonEvent string) + +type NodeManager struct { + currentNode *node.Node // currently running geth node + ctx *cli.Context // the CLI context used to start the geth node + lightEthereum *les.LightEthereum // LES service + accountManager *accounts.Manager // the account manager attached to the currentNode + SelectedAddress string // address of the account that was processed during the last call to SelectAccount() + whisperService *whisper.Whisper // Whisper service + client *rpc.ClientRestartWrapper // RPC client + notificationHandler NodeNotificationHandler // internal signal handler (used in tests) +} + +var ( + nodeManagerInstance *NodeManager + createOnce sync.Once +) + +func NewNodeManager(datadir string, rpcport int) *NodeManager { + createOnce.Do(func() { + nodeManagerInstance = &NodeManager{} + nodeManagerInstance.MakeNode(datadir, rpcport) + nodeManagerInstance.SetNotificationHandler(func(jsonEvent string) { + glog.V(logger.Info).Infof("internal notification received: %s\n", jsonEvent) + }) + }) + + return nodeManagerInstance +} + +func GetNodeManager() *NodeManager { + return nodeManagerInstance +} + +// createAndStartNode creates a node entity and starts the +// node running locally +func CreateAndRunNode(datadir string, rpcport int) error { + nodeManager := NewNodeManager(datadir, rpcport) + + if nodeManager.HasNode() { + nodeManager.RunNode() + return nil + } + + return ErrNodeStartFailure +} + +// MakeNode create a geth node entity +func (m *NodeManager) MakeNode(datadir string, rpcport int) *node.Node { + // TODO remove admin rpcapi flag + set := flag.NewFlagSet("test", 0) + set.Bool("lightkdf", true, "Reduce key-derivation RAM & CPU usage at some expense of KDF strength") + set.Bool("shh", true, "whisper") + set.Bool("light", true, "disable eth") + set.Bool("testnet", true, "light test network") + set.Bool("rpc", true, "enable rpc") + set.String("rpcaddr", "localhost", "host for RPC") + set.Int("rpcport", rpcport, "rpc port") + set.String("rpccorsdomain", "*", "allow all domains") + set.String("verbosity", "3", "verbosity level") + set.String("rpcapi", "db,eth,net,web3,shh,personal,admin", "rpc api(s)") + set.String("datadir", datadir, "data directory for geth") + set.String("logdir", datadir, "log dir for glog") + m.ctx = cli.NewContext(nil, set, nil) + + // Construct the textual version string from the individual components + vString := fmt.Sprintf("%d.%d.%d", versionMajor, versionMinor, versionPatch) + + // Construct the version release oracle configuration + var rConfig release.Config + rConfig.Oracle = common.HexToAddress(versionOracle) + + rConfig.Major = uint32(versionMajor) + rConfig.Minor = uint32(versionMinor) + rConfig.Patch = uint32(versionPatch) + + utils.DebugSetup(m.ctx) + + // create node and start requested protocols + m.currentNode = utils.MakeNode(m.ctx, clientIdentifier, vString) + utils.RegisterEthService(m.ctx, m.currentNode, rConfig, makeDefaultExtra()) + + // Whisper must be explicitly enabled, but is auto-enabled in --dev mode. + shhEnabled := m.ctx.GlobalBool(utils.WhisperEnabledFlag.Name) + shhAutoEnabled := !m.ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && m.ctx.GlobalIsSet(utils.DevModeFlag.Name) + if shhEnabled || shhAutoEnabled { + utils.RegisterShhService(m.currentNode) + } + + m.accountManager = m.currentNode.AccountManager() + + return m.currentNode +} + +// StartNode starts a geth node entity +func (m *NodeManager) RunNode() { + utils.StartNode(m.currentNode) + + if m.currentNode.AccountManager() == nil { + glog.V(logger.Warn).Infoln("cannot get account manager") + } + if err := m.currentNode.Service(&m.whisperService); err != nil { + glog.V(logger.Warn).Infoln("cannot get whisper service:", err) + } + if err := m.currentNode.Service(&m.lightEthereum); err != nil { + glog.V(logger.Warn).Infoln("cannot get light ethereum service:", err) + } + m.lightEthereum.StatusBackend.SetTransactionQueueHandler(onSendTransactionRequest) + + m.client = rpc.NewClientRestartWrapper(func() *rpc.Client { + client, err := m.currentNode.Attach() + if err != nil { + return nil + } + return client + }) + m.currentNode.Wait() +} + +func (m *NodeManager) AddPeer(url string) (bool, error) { + if m == nil || !m.HasNode() { + return false, ErrInvalidGethNode + } + + server := m.currentNode.Server() + if server == nil { + return false, errors.New("node not started") + } + // Try to add the url as a static peer and return + parsedNode, err := discover.ParseNode(url) + if err != nil { + return false, fmt.Errorf("invalid enode: %v", err) + } + server.AddPeer(parsedNode) + + return true, nil +} + +func (m *NodeManager) HasNode() bool { + return m != nil && m.currentNode != nil +} + +func (m *NodeManager) HasAccountManager() bool { + return m.accountManager != nil +} + +func (m *NodeManager) AccountManager() (*accounts.Manager, error) { + if m == nil || !m.HasNode() { + return nil, ErrInvalidGethNode + } + + if !m.HasAccountManager() { + return nil, ErrInvalidAccountManager + } + + return m.accountManager, nil +} + +func (m *NodeManager) HasWhisperService() bool { + return m.whisperService != nil +} + +func (m *NodeManager) WhisperService() (*whisper.Whisper, error) { + if m == nil || !m.HasNode() { + return nil, ErrInvalidGethNode + } + + if !m.HasWhisperService() { + return nil, ErrInvalidWhisperService + } + + return m.whisperService, nil +} + +func (m *NodeManager) HasLightEthereumService() bool { + return m.lightEthereum != nil +} + +func (m *NodeManager) LightEthereumService() (*les.LightEthereum, error) { + if m == nil || !m.HasNode() { + return nil, ErrInvalidGethNode + } + + if !m.HasLightEthereumService() { + return nil, ErrInvalidLightEthereumService + } + + return m.lightEthereum, nil +} + +func (m *NodeManager) HasClientRestartWrapper() bool { + return m.client != nil +} + +func (m *NodeManager) ClientRestartWrapper() (*rpc.ClientRestartWrapper, error) { + if m == nil || !m.HasNode() { + return nil, ErrInvalidGethNode + } + + if !m.HasClientRestartWrapper() { + return nil, ErrInvalidClient + } + + return m.client, nil +} + +func (m *NodeManager) SetNotificationHandler(fn NodeNotificationHandler) { + m.notificationHandler = fn +} + +func (m *NodeManager) NotificationHandler() NodeNotificationHandler { + return m.notificationHandler +} + +func makeDefaultExtra() []byte { + var clientInfo = struct { + Version uint + Name string + GoVersion string + Os string + }{uint(versionMajor<<16 | versionMinor<<8 | versionPatch), clientIdentifier, runtime.Version(), runtime.GOOS} + extra, err := rlp.EncodeToBytes(clientInfo) + if err != nil { + glog.V(logger.Warn).Infoln("error setting canonical miner information:", err) + } + + if uint64(len(extra)) > params.MaximumExtraDataSize.Uint64() { + glog.V(logger.Warn).Infoln("error setting canonical miner information: extra exceeds", params.MaximumExtraDataSize) + glog.V(logger.Debug).Infof("extra: %x\n", extra) + return nil + } + + return extra +} diff --git a/geth/node_test.go b/geth/node_test.go new file mode 100644 index 000000000..aa0c7b86a --- /dev/null +++ b/geth/node_test.go @@ -0,0 +1,26 @@ +package geth_test + +import ( + "github.com/status-im/status-go/geth" + "testing" +) + +const ( + testAddress = "0x89b50b2b26947ccad43accaef76c21d175ad85f4" + testAddressPassword = "asdf" + newAccountPassword = "badpassword" + + whisperMessage1 = "test message 1 (K1 -> K1)" + whisperMessage2 = "test message 2 (K1 -> '')" + whisperMessage3 = "test message 3 ('' -> '')" + whisperMessage4 = "test message 4 ('' -> K1)" + whisperMessage5 = "test message 5 (K2 -> K1)" +) + +func TestNodeSetup(t *testing.T) { + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } +} diff --git a/geth/signals.c b/geth/signals.c new file mode 100644 index 000000000..cb9a7c7e9 --- /dev/null +++ b/geth/signals.c @@ -0,0 +1,181 @@ +#if defined(IOS_DEPLOYMENT) +// ====================================================================================== +// iOS framework compilation using xgo +// ====================================================================================== + +#include +#include + +bool StatusServiceSignalEvent(const char *jsonEvent) { + // code for sending JSON notification up to iOS app + return true; +} + +#elif defined(ANDROID_DEPLOYMENT) +// ====================================================================================== +// Android archive compilation using xgo +// ====================================================================================== + +#include +#include +#include + +bool StatusServiceSignalEvent(const char *jsonEvent); + +static JavaVM *gJavaVM = NULL; +static jclass JavaClassPtr_StatusService = NULL; +static jmethodID JavaMethodPtr_signalEvent = NULL; + +static bool JniLibraryInit(JNIEnv *env); + +/*! + * @brief Get interface to JNI. + * + * @return true if thread should be detached from JNI. + */ +static bool JniAttach(JNIEnv **env) { + jint status; + + if (gJavaVM == NULL) { + env = NULL; + } + + status = (*gJavaVM)->GetEnv(gJavaVM, (void **)env, JNI_VERSION_1_6); + if (status == JNI_EDETACHED) { + // attach thread to JNI + //(*gJavaVM)->AttachCurrentThread( gJavaVM, (void **)env, NULL ); // Oracle JNI API + (*gJavaVM)->AttachCurrentThread(gJavaVM, env, NULL); // Android JNI API + return true; + } else if (status != JNI_OK) { + return false; + } + + return false; +} + +/*! + * @brief The VM calls JNI_OnLoad when the native library is loaded. + */ +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + bool detach; + JNIEnv *env; + int result = JNI_VERSION_1_6; + + gJavaVM = vm; + + // attach thread to JNI + detach = JniAttach(&env); + if (env == NULL) { + // failed + gJavaVM = NULL; + return 0; + } + + if (!JniLibraryInit(env)) { + // fail loading of JNI library + result = 0; + } + + if (detach) { + // detach thread from JNI + (*gJavaVM)->DetachCurrentThread(gJavaVM); + } + + if (result != JNI_VERSION_1_6) { + gJavaVM = NULL; + } + + return result; +} + +/*! + * @brief Initialize library. + */ +bool JniLibraryInit(JNIEnv *env) { + int i; + + JavaClassPtr_StatusService = (*env)->FindClass(env, "com/statusim/module/StatusService"); + if (JavaClassPtr_StatusService == NULL) return false; + + JavaClassPtr_StatusService = (jclass)(*env)->NewGlobalRef(env, JavaClassPtr_StatusService); + if (JavaClassPtr_StatusService == NULL) return false; + + struct { + bool bStatic; + jclass classPtr; + jmethodID *methodPtr; + const char *methodId; + const char *params; + } javaMethodDescriptors[] = { + { + true, + JavaClassPtr_StatusService, + &JavaMethodPtr_signalEvent, // &JavaMethodPtr_someNonStaticMethod + "signalEvent", // someNonStaticMethod + "(Ljava/lang/String;)V" + }, + }; + + for (i = 0; i < sizeof(javaMethodDescriptors) / sizeof(javaMethodDescriptors[0]); i++) { + if (javaMethodDescriptors[i].bStatic) { + *(javaMethodDescriptors[i].methodPtr) = (*env)->GetStaticMethodID( + env, javaMethodDescriptors[i].classPtr, javaMethodDescriptors[i].methodId, javaMethodDescriptors[i].params); + } else { + *(javaMethodDescriptors[i].methodPtr) = (*env)->GetMethodID( + env, javaMethodDescriptors[i].classPtr, javaMethodDescriptors[i].methodId, javaMethodDescriptors[i].params); + } + + if (*(javaMethodDescriptors[i].methodPtr) == NULL) return false; + } + + return true; +} + +/*! + * @brief Calls static method signalEvent of class com.statusim.module.StatusService. + * + * @param jsonEvent - UTF8 string + */ +bool StatusServiceSignalEvent(const char *jsonEvent) { + bool detach; + JNIEnv *env; + + // attach thread to JNI + detach = JniAttach( &env ); + if (env == NULL) { // failed + return false; + } + + jstring javaJsonEvent = NULL; + if (jsonEvent != NULL) { + javaJsonEvent = (*env)->NewStringUTF(env, jsonEvent); + } + + (*env)->CallStaticVoidMethod(env, JavaClassPtr_StatusService, JavaMethodPtr_signalEvent, javaJsonEvent); + + if (javaJsonEvent != NULL) (*env)->DeleteLocalRef(env, javaJsonEvent); + + if (detach) { // detach thread from JNI + (*gJavaVM)->DetachCurrentThread(gJavaVM); + } + + return true; +} + +#else +// ====================================================================================== +// cgo compilation (for local tests) +// ====================================================================================== + +#include +#include +#include +#include "_cgo_export.h" + +bool StatusServiceSignalEvent(const char *jsonEvent) { + NotifyNode((char *)jsonEvent); // re-send notification back to status node + + return true; +} + +#endif diff --git a/geth/txqueue.go b/geth/txqueue.go new file mode 100644 index 000000000..090ba2816 --- /dev/null +++ b/geth/txqueue.go @@ -0,0 +1,43 @@ +package geth + +/* +#include +#include +extern bool StatusServiceSignalEvent( const char *jsonEvent ); +*/ +import "C" + +import ( + "encoding/json" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/les/status" +) + +const ( + EventTransactionQueued = "transaction.queued" +) + +func onSendTransactionRequest(queuedTx status.QueuedTx) { + event := GethEvent{ + Type: EventTransactionQueued, + Event: SendTransactionEvent{ + Id: string(queuedTx.Id), + Args: queuedTx.Args, + }, + } + + body, _ := json.Marshal(&event) + C.StatusServiceSignalEvent(C.CString(string(body))) +} + +func CompleteTransaction(id, password string) (common.Hash, error) { + lightEthereum, err := GetNodeManager().LightEthereumService() + if err != nil { + return common.Hash{}, err + } + + backend := lightEthereum.StatusBackend + + return backend.CompleteQueuedTransaction(status.QueuedTxId(id), password) +} diff --git a/geth/txqueue_test.go b/geth/txqueue_test.go new file mode 100644 index 000000000..10c2fb520 --- /dev/null +++ b/geth/txqueue_test.go @@ -0,0 +1,149 @@ +package geth_test + +import ( + "encoding/json" + "math/big" + "reflect" + "testing" + "time" + + "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/les/status" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/rpc" + "github.com/status-im/status-go/geth" +) + +func TestQueuedTransactions(t *testing.T) { + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + + accountManager, err := geth.GetNodeManager().AccountManager() + if err != nil { + t.Errorf(err.Error()) + return + } + + // create an account + address, _, _, err := geth.CreateAccount(newAccountPassword) + if err != nil { + t.Errorf("could not create account: %v", err) + return + } + + // test transaction queueing + lightEthereum, err := geth.GetNodeManager().LightEthereumService() + if err != nil { + t.Errorf("Test failed: LES service is not running: %v", err) + return + } + backend := lightEthereum.StatusBackend + + // make sure you panic if transaction complete doesn't return + completeQueuedTransaction := make(chan bool, 1) + geth.PanicAfter(20*time.Second, completeQueuedTransaction) + + // replace transaction notification handler + var txHash = common.Hash{} + geth.GetNodeManager().SetNotificationHandler(func(jsonEvent string) { + var envelope geth.GethEvent + if err := json.Unmarshal([]byte(jsonEvent), &envelope); err != nil { + t.Errorf("cannot unmarshal event's JSON: %s", jsonEvent) + return + } + if envelope.Type == geth.EventTransactionQueued { + event := envelope.Event.(map[string]interface{}) + glog.V(logger.Info).Infof("Transaction queued (will be completed in 5 secs): {id: %s}\n", event["id"].(string)) + time.Sleep(5 * time.Second) + + if txHash, err = geth.CompleteTransaction(event["id"].(string), testAddressPassword); err != nil { + t.Errorf("cannot complete queued transation[%v]: %v", event["id"], err) + return + } + + glog.V(logger.Info).Infof("Transaction complete: https://testnet.etherscan.io/tx/%s", txHash.Hex()) + completeQueuedTransaction <- true // so that timeout is aborted + } + }) + + // try completing non-existing transaction + if _, err := geth.CompleteTransaction("some-bad-transaction-id", testAddressPassword); err == nil { + t.Error("error expected and not recieved") + return + } + + // send normal transaction + from, err := utils.MakeAddress(accountManager, testAddress) + if err != nil { + t.Errorf("could not retrieve account from address: %v", err) + return + } + + to, err := utils.MakeAddress(accountManager, address) + if err != nil { + t.Errorf("could not retrieve account from address: %v", err) + return + } + + // this call blocks, up until Complete Transaction is called + txHashCheck, err := backend.SendTransaction(nil, status.SendTxArgs{ + From: from.Address, + To: &to.Address, + Value: rpc.NewHexNumber(big.NewInt(1000000000000)), + }) + if err != nil { + t.Errorf("Test failed: cannot send transaction: %v", err) + } + + if !reflect.DeepEqual(txHash, txHashCheck) { + t.Error("Transaction hash returned from SendTransaction is invalid") + return + } + + time.Sleep(10 * time.Second) + + if reflect.DeepEqual(txHashCheck, common.Hash{}) { + t.Error("Test failed: transaction was never queued or completed") + return + } + + // now test eviction queue + txQueue := backend.TransactionQueue() + var i = 0 + backend.SetTransactionQueueHandler(func(queuedTx status.QueuedTx) { + //glog.V(logger.Info).Infof("%d. Transaction queued (queue size: %d): {id: %v}\n", i, txQueue.Count(), queuedTx.Id) + i++ + }) + + if txQueue.Count() != 0 { + t.Errorf("transaction count should be zero: %d", txQueue.Count()) + return + } + + for i := 0; i < 10; i++ { + go backend.SendTransaction(nil, status.SendTxArgs{}) + } + time.Sleep(3 * time.Second) + + t.Logf("Number of transactions queued: %d. Queue size (shouldn't be more than %d): %d", i, status.DefaultTxQueueCap, txQueue.Count()) + + if txQueue.Count() != 10 { + t.Errorf("transaction count should be 10: got %d", txQueue.Count()) + return + } + + for i := 0; i < status.DefaultTxQueueCap+5; i++ { // stress test by hitting with lots of goroutines + go backend.SendTransaction(nil, status.SendTxArgs{}) + } + time.Sleep(5 * time.Second) + + if txQueue.Count() != status.DefaultTxQueueCap && txQueue.Count() != (status.DefaultTxQueueCap-1) { + t.Errorf("transaction count should be %d (or %d): got %d", status.DefaultTxQueueCap, status.DefaultTxQueueCap-1, txQueue.Count()) + return + } +} diff --git a/common/types.go b/geth/types.go similarity index 94% rename from common/types.go rename to geth/types.go index d9d7c35ef..94a499d23 100644 --- a/common/types.go +++ b/geth/types.go @@ -1,4 +1,4 @@ -package common +package geth import ( "github.com/ethereum/go-ethereum/les/status" @@ -35,7 +35,7 @@ type WhisperMessageEvent struct { } type SendTransactionEvent struct { - Id string `json:"hash"` + Id string `json:"id"` Args status.SendTxArgs `json:"args"` } diff --git a/geth/utils.go b/geth/utils.go new file mode 100644 index 000000000..8e698e1e5 --- /dev/null +++ b/geth/utils.go @@ -0,0 +1,161 @@ +package geth + +import "C" +import ( + "bytes" + "io" + "os" + "path" + "path/filepath" + "sync" + "time" + + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" +) + +var muPrepareTestNode sync.Mutex + +const ( + testDataDir = "../.ethereumtest" + testNodeSyncSeconds = 300 +) + +//export NotifyNode +func NotifyNode(jsonEvent *C.char) { + GetNodeManager().NotificationHandler()(C.GoString(jsonEvent)) +} + +func CopyFile(dst, src string) error { + s, err := os.Open(src) + if err != nil { + return err + } + defer s.Close() + + d, err := os.Create(dst) + if err != nil { + return err + } + defer d.Close() + + if _, err := io.Copy(d, s); err != nil { + return err + } + + return nil +} + +// LoadFromFile is usefull for loading test data, from testdata/filename into a variable +func LoadFromFile(filename string) string { + f, err := os.Open(filename) + if err != nil { + return "" + } + + buf := bytes.NewBuffer(nil) + io.Copy(buf, f) + f.Close() + + return string(buf.Bytes()) +} + +func PrepareTestNode() (err error) { + muPrepareTestNode.Lock() + defer muPrepareTestNode.Unlock() + + manager := GetNodeManager() + if manager.HasNode() { + return nil + } + + syncRequired := false + if _, err := os.Stat(testDataDir); os.IsNotExist(err) { + syncRequired = true + } + + // prepare node directory + dataDir, err := PreprocessDataDir(testDataDir) + if err != nil { + glog.V(logger.Warn).Infoln("make node failed:", err) + return err + } + + // import test account (with test ether on it) + dst := filepath.Join(testDataDir, "testnet", "keystore", "test-account.pk") + if _, err := os.Stat(dst); os.IsNotExist(err) { + err = CopyFile(dst, filepath.Join("../data", "test-account.pk")) + if err != nil { + glog.V(logger.Warn).Infof("cannot copy test account PK: %v", err) + return err + } + } + + // start geth node and wait for it to initialize + // internally once.Do() is used, so call below is thread-safe + go CreateAndRunNode(dataDir, 8546) // to avoid conflicts with running react-native app, run on different port + time.Sleep(3 * time.Second) + + manager = GetNodeManager() + if !manager.HasNode() { + panic("could not obtain geth node") + } + + manager.AddPeer("enode://409772c7dea96fa59a912186ad5bcdb5e51b80556b3fe447d940f99d9eaadb51d4f0ffedb68efad232b52475dd7bd59b51cee99968b3cc79e2d5684b33c4090c@139.162.166.59:30303") + + if syncRequired { + glog.V(logger.Warn).Infof("Sync is required, it will take %d seconds", testNodeSyncSeconds) + time.Sleep(testNodeSyncSeconds * time.Second) // LES syncs headers, so that we are up do date when it is done + } else { + time.Sleep(5 * time.Second) + } + + return nil +} + +func RemoveTestNode() { + err := os.RemoveAll(testDataDir) + if err != nil { + glog.V(logger.Warn).Infof("could not clean up temporary datadir") + } +} + +func PreprocessDataDir(dataDir string) (string, error) { + testDataDir := path.Join(dataDir, "testnet", "keystore") + if _, err := os.Stat(testDataDir); os.IsNotExist(err) { + if err := os.MkdirAll(testDataDir, 0755); err != nil { + return dataDir, ErrDataDirPreprocessingFailed + } + } + + // copy over static peer nodes list (LES auto-discovery is not stable yet) + dst := filepath.Join(dataDir, "testnet", "static-nodes.json") + if _, err := os.Stat(dst); os.IsNotExist(err) { + src := filepath.Join("../data", "static-nodes.json") + if err := CopyFile(dst, src); err != nil { + return dataDir, err + } + } + + return dataDir, nil +} + +// PanicAfter throws panic() after waitSeconds, unless abort channel receives notification +func PanicAfter(waitSeconds time.Duration, abort chan bool) { + // panic if function takes too long + timeout := make(chan bool, 1) + + go func() { + time.Sleep(waitSeconds) + timeout <- true + }() + + go func() { + select { + case <-abort: + return + case <-timeout: + panic("function takes to long, which generally means we are stuck") + } + }() +} diff --git a/geth/whisper.go b/geth/whisper.go new file mode 100644 index 000000000..4548108e2 --- /dev/null +++ b/geth/whisper.go @@ -0,0 +1,69 @@ +package geth + +/* +#include +#include +extern bool StatusServiceSignalEvent( const char *jsonEvent ); +*/ +import "C" +import ( + "encoding/json" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/whisper" +) + +var ( + whisperFilters []int +) + +func onWhisperMessage(message *whisper.Message) { + event := GethEvent{ + Type: "whisper", + Event: WhisperMessageEvent{ + Payload: string(message.Payload), + From: common.ToHex(crypto.FromECDSAPub(message.Recover())), + To: common.ToHex(crypto.FromECDSAPub(message.To)), + Sent: message.Sent.Unix(), + TTL: int64(message.TTL / time.Second), + Hash: common.ToHex(message.Hash.Bytes()), + }, + } + body, _ := json.Marshal(&event) + C.StatusServiceSignalEvent(C.CString(string(body))) +} + +func AddWhisperFilter(args whisper.NewFilterArgs) int { + whisperService, err := GetNodeManager().WhisperService() + if err != nil { + return -1 + } + + filter := whisper.Filter{ + To: crypto.ToECDSAPub(common.FromHex(args.To)), + From: crypto.ToECDSAPub(common.FromHex(args.From)), + Topics: whisper.NewFilterTopics(args.Topics...), + Fn: onWhisperMessage, + } + + id := whisperService.Watch(filter) + whisperFilters = append(whisperFilters, id) + return id +} + +func RemoveWhisperFilter(idFilter int) { + whisperService, err := GetNodeManager().WhisperService() + if err != nil { + return + } + whisperService.Unwatch(idFilter) +} + +func ClearWhisperFilters() { + for _, idFilter := range whisperFilters { + RemoveWhisperFilter(idFilter) + } + whisperFilters = nil +} diff --git a/geth/whisper_test.go b/geth/whisper_test.go new file mode 100644 index 000000000..5e17e722b --- /dev/null +++ b/geth/whisper_test.go @@ -0,0 +1,164 @@ +package geth_test + +import ( + "fmt" + "testing" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/whisper" + "github.com/status-im/status-go/geth" +) + +func TestWhisperMessaging(t *testing.T) { + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + + whisperService, err := geth.GetNodeManager().WhisperService() + if err != nil { + t.Errorf("whisper service not running: %v", err) + } + + whisperAPI := whisper.NewPublicWhisperAPI(whisperService) + + // prepare message + postArgs := whisper.PostArgs{ + From: "", + To: "", + TTL: 10, + Topics: [][]byte{[]byte("test topic")}, + Payload: "test message", + } + + // create an accounts + address1, pubKey1, _, err := geth.CreateAccount(newAccountPassword) + if err != nil { + fmt.Println(err.Error()) + t.Error("Test failed: could not create account") + return + } + glog.V(logger.Info).Infof("Account created: {address: %s, key: %s}", address1, pubKey1) + + address2, pubKey2, _, err := geth.CreateAccount(newAccountPassword) + if err != nil { + fmt.Println(err.Error()) + t.Error("Test failed: could not create account") + return + } + glog.V(logger.Info).Infof("Account created: {address: %s, key: %s}", address2, pubKey2) + + // start watchers + var receivedMessages = map[string]bool{ + whisperMessage1: false, + whisperMessage2: false, + whisperMessage3: false, + whisperMessage4: false, + whisperMessage5: false, + } + whisperService.Watch(whisper.Filter{ + //From: crypto.ToECDSAPub(common.FromHex(pubKey1)), + //To: crypto.ToECDSAPub(common.FromHex(pubKey2)), + Fn: func(msg *whisper.Message) { + //glog.V(logger.Info).Infof("Whisper message received: %s", msg.Payload) + receivedMessages[string(msg.Payload)] = true + }, + }) + + // inject key of newly created account into Whisper, as identity + if whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKey1))) { + t.Error("identity already present in whisper") + } + err = geth.SelectAccount(address1, newAccountPassword) + if err != nil { + t.Errorf("Test failed: could not select account: %v", err) + return + } + identitySucceess := whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKey1))) + if !identitySucceess || err != nil { + t.Errorf("identity not injected into whisper: %v", err) + } + if whisperService.HasIdentity(crypto.ToECDSAPub(common.FromHex(pubKey2))) { // ensure that second id is not injected + t.Error("identity already present in whisper") + } + + // double selecting (shouldn't be a problem) + err = geth.SelectAccount(address1, newAccountPassword) + if err != nil { + t.Errorf("Test failed: could not select account: %v", err) + return + } + + // TEST 0: From != nil && To != nil: encrypted signed message (but we cannot decrypt it - so watchers will not report this) + postArgs.From = pubKey1 + postArgs.To = pubKey2 // owner of that public key will be able to decrypt it + postSuccess, err := whisperAPI.Post(postArgs) + if !postSuccess || err != nil { + t.Errorf("could not post to whisper: %v", err) + } + + // TEST 1: From != nil && To != nil: encrypted signed message (to self) + postArgs.From = pubKey1 + postArgs.To = pubKey1 + postArgs.Payload = whisperMessage1 + postSuccess, err = whisperAPI.Post(postArgs) + if !postSuccess || err != nil { + t.Errorf("could not post to whisper: %v", err) + } + + // send from account that is not in Whisper identity list + postArgs.From = pubKey2 + postSuccess, err = whisperAPI.Post(postArgs) + if err == nil || err.Error() != fmt.Sprintf("unknown identity to send from: %s", pubKey2) { + t.Error("expected error not voiced: we are sending from non-injected whisper identity") + } + + // TEST 2: From != nil && To == nil: signed broadcast (known sender) + postArgs.From = pubKey1 + postArgs.To = "" + postArgs.Payload = whisperMessage2 + postSuccess, err = whisperAPI.Post(postArgs) + if !postSuccess || err != nil { + t.Errorf("could not post to whisper: %v", err) + } + + // TEST 3: From == nil && To == nil: anonymous broadcast + postArgs.From = "" + postArgs.To = "" + postArgs.Payload = whisperMessage3 + postSuccess, err = whisperAPI.Post(postArgs) + if !postSuccess || err != nil { + t.Errorf("could not post to whisper: %v", err) + } + + // TEST 4: From == nil && To != nil: encrypted anonymous message + postArgs.From = "" + postArgs.To = pubKey1 + postArgs.Payload = whisperMessage4 + postSuccess, err = whisperAPI.Post(postArgs) + if !postSuccess || err != nil { + t.Errorf("could not post to whisper: %v", err) + } + + // TEST 5: From != nil && To != nil: encrypted and signed response + postArgs.From = "" + postArgs.To = pubKey1 + postArgs.Payload = whisperMessage5 + postSuccess, err = whisperAPI.Post(postArgs) + if !postSuccess || err != nil { + t.Errorf("could not post to whisper: %v", err) + } + + time.Sleep(2 * time.Second) // allow whisper to poll + for message, status := range receivedMessages { + if !status { + t.Errorf("Expected message not received: %s", message) + } + } + +} diff --git a/jail/jail.go b/jail/jail.go new file mode 100644 index 000000000..01ec53fdc --- /dev/null +++ b/jail/jail.go @@ -0,0 +1,259 @@ +package jail + +import ( + "encoding/json" + "errors" + "fmt" + "sync" + + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/rpc" + "github.com/robertkrimen/otto" + "github.com/status-im/status-go/geth" +) + +var ( + ErrInvalidJail = errors.New("jail environment is not properly initialized") +) + +type Jail struct { + client *rpc.ClientRestartWrapper // lazy inited on the first call to jail.ClientRestartWrapper() + VMs map[string]*otto.Otto + statusJS string +} + +var jailInstance *Jail +var once sync.Once + +func New() *Jail { + once.Do(func() { + jailInstance = &Jail{ + VMs: make(map[string]*otto.Otto), + } + }) + + return jailInstance +} + +func Init(js string) *Jail { + jailInstance = New() // singleton, we will always get the same reference + jailInstance.statusJS = js + + return jailInstance +} + +func GetInstance() *Jail { + return New() // singleton, we will always get the same reference +} + +func (jail *Jail) Parse(chatId string, js string) string { + if jail == nil { + return printError(ErrInvalidJail.Error()) + } + + vm := otto.New() + initJjs := jail.statusJS + ";" + jail.VMs[chatId] = vm + _, err := vm.Run(initJjs) + vm.Set("jeth", struct{}{}) + + jethObj, _ := vm.Get("jeth") + jethObj.Object().Set("send", jail.Send) + jethObj.Object().Set("sendAsync", jail.Send) + + jjs := Web3_JS + ` + var Web3 = require('web3'); + var web3 = new Web3(jeth); + var Bignumber = require("bignumber.js"); + function bn(val){ + return new Bignumber(val); + } + ` + js + "; var catalog = JSON.stringify(_status_catalog);" + vm.Run(jjs) + + res, _ := vm.Get("catalog") + + return printResult(res.String(), err) +} + +func (jail *Jail) Call(chatId string, path string, args string) string { + _, err := jail.ClientRestartWrapper() + if err != nil { + return printError(err.Error()) + } + + vm, ok := jail.VMs[chatId] + if !ok { + return printError(fmt.Sprintf("VM[%s] doesn't exist.", chatId)) + } + + res, err := vm.Call("call", nil, path, args) + + return printResult(res.String(), err) +} + +func (jail *Jail) GetVM(chatId string) (*otto.Otto, error) { + if jail == nil { + return nil, ErrInvalidJail + } + + vm, ok := jail.VMs[chatId] + if !ok { + return nil, fmt.Errorf("VM[%s] doesn't exist.", chatId) + } + + return vm, nil +} + +type jsonrpcCall struct { + Id int64 + Method string + Params []interface{} +} + +// Send will serialize the first argument, send it to the node and returns the response. +func (jail *Jail) Send(call otto.FunctionCall) (response otto.Value) { + clientFactory, err := jail.ClientRestartWrapper() + if err != nil { + return newErrorResponse(call, -32603, err.Error(), nil) + } + + // Remarshal the request into a Go value. + JSON, _ := call.Otto.Object("JSON") + reqVal, err := JSON.Call("stringify", call.Argument(0)) + if err != nil { + throwJSException(err.Error()) + } + var ( + rawReq = []byte(reqVal.String()) + reqs []jsonrpcCall + batch bool + ) + if rawReq[0] == '[' { + batch = true + json.Unmarshal(rawReq, &reqs) + } else { + batch = false + reqs = make([]jsonrpcCall, 1) + json.Unmarshal(rawReq, &reqs[0]) + } + + // Execute the requests. + resps, _ := call.Otto.Object("new Array()") + for _, req := range reqs { + resp, _ := call.Otto.Object(`({"jsonrpc":"2.0"})`) + resp.Set("id", req.Id) + var result json.RawMessage + + client := clientFactory.Client() + errc := make(chan error, 1) + errc2 := make(chan error) + go func() { + errc2 <- <-errc + }() + errc <- client.Call(&result, req.Method, req.Params...) + err = <-errc2 + + switch err := err.(type) { + case nil: + if result == nil { + // Special case null because it is decoded as an empty + // raw message for some reason. + resp.Set("result", otto.NullValue()) + } else { + resultVal, err := JSON.Call("parse", string(result)) + if err != nil { + resp = newErrorResponse(call, -32603, err.Error(), &req.Id).Object() + } else { + resp.Set("result", resultVal) + } + } + case rpc.Error: + resp.Set("error", map[string]interface{}{ + "code": err.ErrorCode(), + "message": err.Error(), + }) + default: + resp = newErrorResponse(call, -32603, err.Error(), &req.Id).Object() + } + resps.Call("push", resp) + } + + // Return the responses either to the callback (if supplied) + // or directly as the return value. + if batch { + response = resps.Value() + } else { + response, _ = resps.Get("0") + } + if fn := call.Argument(1); fn.Class() == "Function" { + fn.Call(otto.NullValue(), otto.NullValue(), response) + return otto.UndefinedValue() + } + return response +} + +func (jail *Jail) ClientRestartWrapper() (*rpc.ClientRestartWrapper, error) { + if jail == nil { + return nil, ErrInvalidJail + } + + if jail.client != nil { + return jail.client, nil + } + + nodeManager := geth.GetNodeManager() + if !nodeManager.HasNode() { + return nil, geth.ErrInvalidGethNode + } + + // obtain RPC client from running node + client, err := nodeManager.ClientRestartWrapper() + if err != nil { + return nil, err + } + jail.client = client + + return jail.client, nil +} + +func newErrorResponse(call otto.FunctionCall, code int, msg string, id interface{}) otto.Value { + // Bundle the error into a JSON RPC call response + m := map[string]interface{}{"version": "2.0", "id": id, "error": map[string]interface{}{"code": code, msg: msg}} + res, _ := json.Marshal(m) + val, _ := call.Otto.Run("(" + string(res) + ")") + return val +} + +// throwJSException panics on an otto.Value. The Otto VM will recover from the +// Go panic and throw msg as a JavaScript error. +func throwJSException(msg interface{}) otto.Value { + val, err := otto.ToValue(msg) + if err != nil { + glog.V(logger.Error).Infof("Failed to serialize JavaScript exception %v: %v", msg, err) + } + panic(val) +} + +func printError(error string) string { + str := geth.JSONError{ + Error: error, + } + outBytes, _ := json.Marshal(&str) + return string(outBytes) +} + +func printResult(res string, err error) string { + var out string + if err != nil { + out = printError(err.Error()) + } else { + if "undefined" == res { + res = "null" + } + out = fmt.Sprintf(`{"result": %s}`, res) + } + + return out +} diff --git a/jail/jail_test.go b/jail/jail_test.go new file mode 100644 index 000000000..58b74de3b --- /dev/null +++ b/jail/jail_test.go @@ -0,0 +1,242 @@ +package jail_test + +import ( + "reflect" + "testing" + + "github.com/status-im/status-go/geth" + "github.com/status-im/status-go/jail" +) + +const ( + TEST_ADDRESS = "0x89b50b2b26947ccad43accaef76c21d175ad85f4" + CHAT_ID_INIT = "CHAT_ID_INIT_TEST" + CHAT_ID_CALL = "CHAT_ID_CALL_TEST" + CHAT_ID_NON_EXISTENT = "CHAT_IDNON_EXISTENT" + + TESTDATA_STATUS_JS = "testdata/status.js" +) + +func TestJailUnInited(t *testing.T) { + errorWrapper := func(err error) string { + return `{"error":"` + err.Error() + `"}` + } + + expectedError := errorWrapper(jail.ErrInvalidJail) + + var jailInstance *jail.Jail + response := jailInstance.Parse(CHAT_ID_CALL, ``) + if response != expectedError { + t.Errorf("error expected, but got: %v", response) + } + + response = jailInstance.Call(CHAT_ID_CALL, `["commands", "testCommand"]`, `{"val": 12}`) + if response != expectedError { + t.Errorf("error expected, but got: %v", response) + } + + _, err := jailInstance.GetVM(CHAT_ID_CALL) + if err != jail.ErrInvalidJail { + t.Errorf("error expected, but got: %v", err) + } + + _, err = jailInstance.ClientRestartWrapper() + if err != jail.ErrInvalidJail { + t.Errorf("error expected, but got: %v", err) + } + + // now make sure that if Init is called, then Parse doesn't produce any error + jailInstance = jail.Init(``) + if jailInstance == nil { + t.Error("jail instance shouldn't be nil at this point") + return + } + statusJS := geth.LoadFromFile(TESTDATA_STATUS_JS) + `; + _status_catalog.commands["testCommand"] = function (params) { + return params.val * params.val; + };` + response = jailInstance.Parse(CHAT_ID_CALL, statusJS) + expectedResponse := `{"result": {"commands":{},"responses":{}}}` + if response != expectedResponse { + t.Errorf("unexpected response received: %v", response) + } + + // however, we still expect issue voiced if somebody tries to execute code with Call + response = jailInstance.Call(CHAT_ID_CALL, `["commands", "testCommand"]`, `{"val": 12}`) + if response != errorWrapper(geth.ErrInvalidGethNode) { + t.Errorf("error expected, but got: %v", response) + } + + // make sure that Call() succeeds when node is started + err = geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + response = jailInstance.Call(CHAT_ID_CALL, `["commands", "testCommand"]`, `{"val": 12}`) + expectedResponse = `{"result": 144}` + if response != expectedResponse { + t.Errorf("expected response is not returned: expected %s, got %s", expectedResponse, response) + return + } +} + +func TestJailInit(t *testing.T) { + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + + initCode := ` + var _status_catalog = { + foo: 'bar' + }; + ` + jailInstance := jail.Init(initCode) + + extraCode := ` + var extraFunc = function (x) { + return x * x; + }; + ` + response := jailInstance.Parse(CHAT_ID_INIT, extraCode) + + expectedResponse := `{"result": {"foo":"bar"}}` + + if !reflect.DeepEqual(expectedResponse, response) { + t.Error("Expected output not returned from jail.Parse()") + return + } +} + +func TestJailFunctionCall(t *testing.T) { + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + + jailInstance := jail.Init("") + + // load Status JS and add test command to it + statusJS := geth.LoadFromFile(TESTDATA_STATUS_JS) + `; + _status_catalog.commands["testCommand"] = function (params) { + return params.val * params.val; + };` + jailInstance.Parse(CHAT_ID_CALL, statusJS) + + // call with wrong chat id + response := jailInstance.Call(CHAT_ID_NON_EXISTENT, "", "") + expectedError := `{"error":"VM[CHAT_IDNON_EXISTENT] doesn't exist."}` + if response != expectedError { + t.Errorf("expected error is not returned: expected %s, got %s", expectedError, response) + return + } + + // call extraFunc() + response = jailInstance.Call(CHAT_ID_CALL, `["commands", "testCommand"]`, `{"val": 12}`) + expectedResponse := `{"result": 144}` + if response != expectedResponse { + t.Errorf("expected response is not returned: expected %s, got %s", expectedResponse, response) + return + } +} + +func TestJailRPCSend(t *testing.T) { + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + + jailInstance := jail.Init("") + + // load Status JS and add test command to it + statusJS := geth.LoadFromFile(TESTDATA_STATUS_JS) + jailInstance.Parse(CHAT_ID_CALL, statusJS) + + // obtain VM for a given chat (to send custom JS to jailed version of Send()) + vm, err := jailInstance.GetVM(CHAT_ID_CALL) + if err != nil { + t.Errorf("cannot get VM: %v", err) + return + } + + _, err = vm.Run(` + var data = {"jsonrpc":"2.0","method":"eth_getBalance","params":["` + TEST_ADDRESS + `", "latest"],"id":1}; + var sendResult = web3.currentProvider.send(data) + console.log(JSON.stringify(sendResult)) + var sendResult = web3.fromWei(sendResult.result, "ether") + `) + if err != nil { + t.Errorf("cannot run custom code on VM: %v", err) + return + } + + value, err := vm.Get("sendResult") + if err != nil { + t.Errorf("cannot obtain result of balance check operation: %v", err) + return + } + + balance, err := value.ToFloat() + if err != nil { + t.Errorf("cannot obtain result of balance check operation: %v", err) + return + } + + if balance < 90 || balance > 100 { + t.Error("wrong balance (there should be lots of test Ether on that account)") + return + } + + t.Logf("Balance of %.2f ETH found on '%s' account", balance, TEST_ADDRESS) +} + +func TestJailMultipleInitSingletonJail(t *testing.T) { + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + + jailInstance1 := jail.Init("") + jailInstance2 := jail.Init("") + jailInstance3 := jail.New() + jailInstance4 := jail.GetInstance() + + if !reflect.DeepEqual(jailInstance1, jailInstance2) { + t.Error("singleton property of jail instance is violated") + } + if !reflect.DeepEqual(jailInstance2, jailInstance3) { + t.Error("singleton property of jail instance is violated") + } + if !reflect.DeepEqual(jailInstance3, jailInstance4) { + t.Error("singleton property of jail instance is violated") + } +} + +func TestJailGetVM(t *testing.T) { + err := geth.PrepareTestNode() + if err != nil { + t.Error(err) + return + } + + jailInstance := jail.Init("") + + expectedError := `VM[` + CHAT_ID_NON_EXISTENT + `] doesn't exist.` + _, err = jailInstance.GetVM(CHAT_ID_NON_EXISTENT) + if err == nil || err.Error() != expectedError { + t.Error("expected error, but call succeeded") + } + + // now let's create VM.. + jailInstance.Parse(CHAT_ID_CALL, ``) + // ..and see if VM becomes available + _, err = jailInstance.GetVM(CHAT_ID_CALL) + if err != nil { + t.Errorf("unexpected error: %v", err) + } +} diff --git a/jail/testdata/commands.js b/jail/testdata/commands.js new file mode 100644 index 000000000..4a8b7eb21 --- /dev/null +++ b/jail/testdata/commands.js @@ -0,0 +1,320 @@ +status.command({ + name: "location", + description: "Send location", + color: "#9a5dcf", + preview: function (params) { + var text = status.components.text( + { + style: { + marginTop: 5, + marginHorizontal: 0, + fontSize: 14, + fontFamily: "font", + color: "black" + } + }, params.value); + var uri = "https://maps.googleapis.com/maps/api/staticmap?center=" + + params.value + + "&size=100x100&maptype=roadmap&key=AIzaSyBNsj1qoQEYPb3IllmWMAscuXW0eeuYqAA&language=en" + + "&markers=size:mid%7Ccolor:0xff0000%7Clabel:%7C" + + params.value; + + var image = status.components.image( + { + source: {uri: uri}, + style: { + width: 100, + height: 100 + } + } + ); + + return status.components.view({}, [text, image]); + } +}).param({ + name: "address", + type: status.types.TEXT, + placeholder: "Address" +}); + +var phones = [ + { + number: "89171111111", + description: "Number format 1" + }, + { + number: "89371111111", + description: "Number format 1" + }, + { + number: "+79171111111", + description: "Number format 2" + }, + { + number: "9171111111", + description: "Number format 3" + } +]; + +function suggestionsContainerStyle(suggestionsCount) { + return { + marginVertical: 1, + marginHorizontal: 0, + height: Math.min(150, (56 * suggestionsCount)), + backgroundColor: "white", + borderRadius: 5 + }; +} + +var suggestionContainerStyle = { + paddingLeft: 16, + backgroundColor: "white" +}; + +var suggestionSubContainerStyle = { + height: 56, + borderBottomWidth: 1, + borderBottomColor: "#0000001f" +}; + +var valueStyle = { + marginTop: 9, + fontSize: 14, + fontFamily: "font", + color: "#000000de" +}; + +var descriptionStyle = { + marginTop: 1.5, + fontSize: 14, + fontFamily: "font", + color: "#838c93de" +}; + +function startsWith(str1, str2) { + // String.startsWith(...) doesn't work in otto + return str1.lastIndexOf(str2, 0) == 0 && str1 != str2; +} + +function phoneSuggestions(params) { + var ph, suggestions; + if (!params.value || params.value == "") { + ph = phones; + } else { + ph = phones.filter(function (phone) { + return startsWith(phone.number, params.value); + }); + } + + if (ph.length == 0) { + return; + } + + suggestions = ph.map(function (phone) { + return status.components.touchable( + {onPress: [status.events.SET_VALUE, phone.number]}, + status.components.view(suggestionContainerStyle, + [status.components.view(suggestionSubContainerStyle, + [ + status.components.text( + {style: valueStyle}, + phone.number + ), + status.components.text( + {style: descriptionStyle}, + phone.description + ) + ])]) + ); + }); + + var view = status.components.scrollView( + suggestionsContainerStyle(ph.length), + suggestions + ); + + return {markup: view}; +} + +var phoneConfig = { + name: "phone", + description: "Send phone number", + color: "#5fc48d", + validator: function (params) { + return { + validationHandler: "phone", + parameters: [params.value] + }; + }, + params: [{ + name: "phone", + type: status.types.PHONE, + suggestions: phoneSuggestions, + placeholder: "Phone number" + }], + handler: function (params) { + return { + event: "sign-up", + params: [params.value] + }; + } +}; +status.response(phoneConfig); +status.command(phoneConfig); + +status.command({ + name: "help", + description: "Help", + color: "#7099e6", + /* Validator example + validator: function (params) { + if (params.value != "3") { + var error = status.components.view( + {backgroundColor: "red"}, + [status.components.text({}, "ooops :(")] + ); + return {errors: [error]} + } + },*/ + params: [{ + name: "query", + type: status.types.TEXT + }] +}); + +status.response({ + name: "confirmation-code", + color: "#7099e6", + description: "Confirmation code", + params: [{ + name: "code", + type: status.types.NUMBER + }], + handler: function (params) { + return { + event: "confirm-sign-up", + params: [params.value] + }; + }, + validator: function(params){ + if(!/^[\d]{4}$/.test(params.value)){ + var error = status.components.validationMessage( + "Confirmation code", + "Wrong format" + ); + + return {errors: [error]} + } + } +}); + +status.response({ + name: "keypair", + color: "#7099e6", + description: "Keypair password", + icon: "icon_lock_white", + params: [{ + name: "password", + type: status.types.PASSWORD + }], + handler: function (params) { + return { + event: "save-password", + params: [params.value] + }; + }, + preview: function (params) { + return status.components.text( + { + style: { + marginTop: 5, + marginHorizontal: 0, + fontSize: 14, + fontFamily: "font", + color: "black" + } + }, "*****"); + } +}); + +function walletView(params) { + if (params.value != "") { + var url = params.value; + if (!/^[a-zA-Z-_]+:/.test(url)) { + url = 'http://' + url; + } + + return {webViewUrl: url}; + } +} + +status.command({ + name: "browse", + description: "browser", + color: "#ffa500", + fullscreen: true, + suggestionsTrigger: 'on-send', + params: [{ + name: "webpage", + suggestions: walletView, + type: status.types.TEXT + }] +}); + +function validateBalance(params) { + try { + var val = web3.toWei(params.value, "ether"); + } catch (err) { + return { + errors: [ + status.components.validationMessage( + "Amount", + "Amount is not valid number"//err.message + ) + ] + }; + } + + var balance = web3.eth.getBalance(params.command.address); + if (bn(val).greaterThan(bn(balance))) { + return { + errors: [ + status.components.validationMessage( + "Amount", + "Not enough ETH on balance (" + + web3.fromWei(balance, "ether") + + " ETH)" + ) + ] + }; + } +} + +function sendTransaction(params) { + var data = { + from: params.command.from, + to: params.command.to, + value: web3.toWei(params.value, "ether") + }; + var hash = web3.eth.sendTransaction(data); + + return {"transaction-hash": hash}; +} + +status.command({ + name: "send", + color: "#5fc48d", + description: "Send transaction", + params: [{ + name: "amount", + type: status.types.NUMBER + }], + preview: function (params) { + return status.components.text( + {}, + params.value + " ETH" + ); + }, + handler: sendTransaction, + validator: validateBalance +}); diff --git a/jail/testdata/status.js b/jail/testdata/status.js new file mode 100644 index 000000000..7b75533ec --- /dev/null +++ b/jail/testdata/status.js @@ -0,0 +1,155 @@ +var _status_catalog = { + commands: {}, + responses: {} +}; + +function Command() { +} +function Response() { +} + +Command.prototype.addToCatalog = function () { + _status_catalog.commands[this.name] = this; +}; + +Command.prototype.param = function (parameter) { + this.params.push(parameter); + + return this; +}; + +Command.prototype.create = function (com) { + this.name = com.name; + this.description = com.description; + this.handler = com.handler; + this["has-handler"] = com.handler != null; + this.validator = com.validator; + this.color = com.color; + this.icon = com.icon; + this.params = com.params || []; + this.preview = com.preview; + this["suggestions-trigger"] = com.suggestionsTrigger || "on-change"; + this.fullscreen = com.fullscreen; + this.addToCatalog(); + + return this; +}; + + +Response.prototype = Object.create(Command.prototype); +Response.prototype.addToCatalog = function () { + _status_catalog.responses[this.name] = this; +}; +Response.prototype.onReceiveResponse = function (handler) { + this.onReceive = handler; +}; + +function call(pathStr, paramsStr) { + var params = JSON.parse(paramsStr), + path = JSON.parse(pathStr), + fn, res; + + fn = path.reduce(function (catalog, name) { + if (catalog && catalog[name]) { + return catalog[name]; + } + }, + _status_catalog + ); + + if (!fn) { + return null; + } + + res = fn(params); + + return JSON.stringify(res); +} + +function text(options, s) { + return ['text', options, s]; +} + +function view(options, elements) { + return ['view', options].concat(elements); +} + +function image(options) { + return ['image', options]; +} + +function touchable(options, element) { + return ['touchable', options, element]; +} + +function scrollView(options, elements) { + return ['scroll-view', options].concat(elements); +} + +function webView(url) { + return ['web-view', { + source: { + uri: url + }, + javaScriptEnabled: true + }]; +} + +function validationMessage(titleText, descriptionText) { + var titleStyle = { + color: "white", + fontSize: 12, + fontFamily: "sans-serif" + }; + var title = status.components.text(titleStyle, titleText); + + var descriptionStyle = { + color: "white", + fontSize: 12, + fontFamily: "sans-serif", + opacity: 0.9 + }; + var description = status.components.text(descriptionStyle, descriptionText); + + return status.components.view( + { + backgroundColor: "red", + height: 61, + paddingLeft: 16, + paddingTop: 14, + }, + [title, description] + ); +} + +var status = { + command: function (h) { + var command = new Command(); + return command.create(h); + }, + response: function (h) { + var response = new Response(); + return response.create(h); + }, + autorun: function (commandName) { + _status_catalog.autorun = commandName; + }, + types: { + TEXT: 'text', + NUMBER: 'number', + PHONE: 'phone', + PASSWORD: 'password' + }, + events: { + SET_VALUE: 'set-value' + }, + components: { + view: view, + text: text, + image: image, + touchable: touchable, + scrollView: scrollView, + webView: webView, + validationMessage: validationMessage + } +}; \ No newline at end of file diff --git a/src/web3.go b/jail/web3.go similarity index 99% rename from src/web3.go rename to jail/web3.go index 2ea7f0ab7..3e97eda37 100644 --- a/src/web3.go +++ b/jail/web3.go @@ -1,4 +1,4 @@ -package main +package jail const Web3_JS = ` require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o -#include - -#ifdef IOS_DEPLOYMENT -#else -#include -#endif - - - -bool GethServiceSignalEvent( const char *jsonEvent ); - -#ifdef IOS_DEPLOYMENT - -bool GethServiceSignalEvent( const char *jsonEvent ) -{ - return true; -} - -#else - -static JavaVM *gJavaVM = NULL; -static jclass JavaClassPtr_GethService = NULL; -static jmethodID JavaMethodPtr_signalEvent = NULL; - -static bool JniLibraryInit( JNIEnv *env ); - -/*! - * @brief Get interface to JNI. - * - * @return true if thread should be detached from JNI. - */ -static bool JniAttach( JNIEnv **env ) -{ - jint status; - - if (gJavaVM == NULL) - { - env = NULL; - } - - status = (*gJavaVM)->GetEnv( gJavaVM, (void **)env, JNI_VERSION_1_6); - if (status == JNI_EDETACHED) - { - // attach thread to JNI - //(*gJavaVM)->AttachCurrentThread( gJavaVM, (void **)env, NULL ); // Oracle JNI API - (*gJavaVM)->AttachCurrentThread( gJavaVM, env, NULL ); // Android JNI API - return true; - } - else if (status != JNI_OK) - { - return false; - } - - return false; -} - -/*! - * @brief The VM calls JNI_OnLoad when the native library is loaded. - */ -JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) -{ - bool detach; - JNIEnv *env; - int result = JNI_VERSION_1_6; - - gJavaVM = vm; - - // attach thread to JNI - detach = JniAttach( &env ); - if (env == NULL) - { - // failed - gJavaVM = NULL; - return 0; - } - - if (!JniLibraryInit( env )) - { - // fail loading of JNI library - result = 0; - } - - if (detach) - { - // detach thread from JNI - (*gJavaVM)->DetachCurrentThread( gJavaVM ); - } - - if (result != JNI_VERSION_1_6) - { - gJavaVM = NULL; - } - - return result; -} - -/*! - * @brief Initialize library. - */ -bool JniLibraryInit( JNIEnv *env ) -{ - int i; - - JavaClassPtr_GethService = (*env)->FindClass( env, "com/statusim/geth/service/GethService" ); - if (JavaClassPtr_GethService == NULL) return false; - JavaClassPtr_GethService = (jclass)(*env)->NewGlobalRef( env, JavaClassPtr_GethService ); - if (JavaClassPtr_GethService == NULL) return false; - - struct { bool bStatic; jclass classPtr; jmethodID *methodPtr; const char *methodId; const char *params; } javaMethodDescriptors[] = - { - { true, JavaClassPtr_GethService, &JavaMethodPtr_signalEvent, "signalEvent", "(Ljava/lang/String;)V" }, - -// { false, JavaClassPtr_GethService, &JavaMethodPtr_someNonStaticMethod, "someNonStaticMethod", "(Ljava/lang/String;)V" }, - }; - - for (i = 0; i < sizeof(javaMethodDescriptors) / sizeof(javaMethodDescriptors[0]); i++) - { - if (javaMethodDescriptors[i].bStatic) - { - *(javaMethodDescriptors[i].methodPtr) = (*env)->GetStaticMethodID( env, javaMethodDescriptors[i].classPtr, javaMethodDescriptors[i].methodId, javaMethodDescriptors[i].params ); - } - else - { - *(javaMethodDescriptors[i].methodPtr) = (*env)->GetMethodID( env, javaMethodDescriptors[i].classPtr, javaMethodDescriptors[i].methodId, javaMethodDescriptors[i].params ); - } - - if (*(javaMethodDescriptors[i].methodPtr) == NULL) return false; - } - - return true; -} - -/*! - * @brief Calls static method signalEvent of class com.statusim.GethService. - * - * @param jsonEvent - UTF8 string - */ -bool GethServiceSignalEvent( const char *jsonEvent ) -{ - bool detach; - JNIEnv *env; - - // attach thread to JNI - detach = JniAttach( &env ); - if (env == NULL) - { - // failed - return false; - } - - jstring javaJsonEvent = NULL; - if (jsonEvent != NULL) - { - javaJsonEvent = (*env)->NewStringUTF( env, jsonEvent ); - } - - (*env)->CallStaticVoidMethod( env, JavaClassPtr_GethService, JavaMethodPtr_signalEvent, javaJsonEvent ); - - if (javaJsonEvent != NULL) (*env)->DeleteLocalRef( env, javaJsonEvent ); - - if (detach) - { - // detach thread from JNI - (*gJavaVM)->DetachCurrentThread( gJavaVM ); - } - - return true; -} -#endif diff --git a/src/node.go b/src/node.go deleted file mode 100644 index c1af626c5..000000000 --- a/src/node.go +++ /dev/null @@ -1,162 +0,0 @@ -package main - -import ( - "errors" - "flag" - "fmt" - "os" - "path" - "path/filepath" - "runtime" - - "github.com/ethereum/go-ethereum/accounts" - "github.com/ethereum/go-ethereum/cmd/utils" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/les" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" - "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/release" - "github.com/ethereum/go-ethereum/rlp" - "github.com/ethereum/go-ethereum/rpc" - "github.com/ethereum/go-ethereum/whisper" - "gopkg.in/urfave/cli.v1" -) - -const ( - clientIdentifier = "Geth" // Client identifier to advertise over the network - versionMajor = 1 // Major version component of the current release - versionMinor = 5 // Minor version component of the current release - versionPatch = 0 // Patch version component of the current release - versionMeta = "unstable" // Version metadata to append to the version string - - versionOracle = "0xfa7b9770ca4cb04296cac84f37736d4041251cdf" // Ethereum address of the Geth release oracle -) - -var ( - vString string // Combined textual representation of the version - rConfig release.Config // Structured version information and release oracle config - currentNode *node.Node // currently running geth node - c *cli.Context // the CLI context used to start the geth node - lightEthereum *les.LightEthereum // LES service - accountManager *accounts.Manager // the account manager attached to the currentNode - selectedAddress string // address of the account that was processed during the last call to SelectAccount() - whisperService *whisper.Whisper // whisper service - datadir string // data directory for geth - rpcport int = 8545 // RPC port (replaced in unit tests) - client *rpc.Client -) - -var ( - ErrDataDirPreprocessingFailed = errors.New("Failed to pre-process data directory") -) - -// MakeNode create a geth node entity -func MakeNode(inputDir string) *node.Node { - - datadir := inputDir - - // TODO remove admin rpcapi flag - set := flag.NewFlagSet("test", 0) - set.Bool("lightkdf", true, "Reduce key-derivation RAM & CPU usage at some expense of KDF strength") - set.Bool("shh", true, "whisper") - set.Bool("light", true, "disable eth") - set.Bool("testnet", true, "light test network") - set.Bool("rpc", true, "enable rpc") - set.String("rpcaddr", "localhost", "host for RPC") - set.Int("rpcport", rpcport, "rpc port") - set.String("rpccorsdomain", "*", "allow all domains") - set.String("verbosity", "3", "verbosity level") - set.String("rpcapi", "db,eth,net,web3,shh,personal,admin", "rpc api(s)") - set.String("datadir", datadir, "data directory for geth") - set.String("logdir", datadir, "log dir for glog") - c = cli.NewContext(nil, set, nil) - - // Construct the textual version string from the individual components - vString = fmt.Sprintf("%d.%d.%d", versionMajor, versionMinor, versionPatch) - - // Construct the version release oracle configuration - rConfig.Oracle = common.HexToAddress(versionOracle) - - rConfig.Major = uint32(versionMajor) - rConfig.Minor = uint32(versionMinor) - rConfig.Patch = uint32(versionPatch) - - utils.DebugSetup(c) - currentNode = makeNode(c, clientIdentifier, vString) - - return currentNode - -} - -func makeNode(ctx *cli.Context, name, version string) *node.Node { - nodeIn := utils.MakeNode(ctx, name, version) - utils.RegisterEthService(ctx, nodeIn, rConfig, makeDefaultExtra()) - // Whisper must be explicitly enabled, but is auto-enabled in --dev mode. - shhEnabled := ctx.GlobalBool(utils.WhisperEnabledFlag.Name) - shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DevModeFlag.Name) - if shhEnabled || shhAutoEnabled { - utils.RegisterShhService(nodeIn) - } - return nodeIn -} - -// StartNode starts a geth node entity -func RunNode(nodeIn *node.Node) { - utils.StartNode(nodeIn) - - if err := nodeIn.Service(&accountManager); err != nil { - glog.V(logger.Warn).Infoln("cannot get account manager:", err) - } - if err := nodeIn.Service(&whisperService); err != nil { - glog.V(logger.Warn).Infoln("cannot get whisper service:", err) - } - if err := nodeIn.Service(&lightEthereum); err != nil { - glog.V(logger.Warn).Infoln("cannot get light ethereum service:", err) - } - lightEthereum.StatusBackend.SetTransactionQueueHandler(onSendTransactionRequest) - - client, _ = nodeIn.Attach() - nodeIn.Wait() -} - -func makeDefaultExtra() []byte { - var clientInfo = struct { - Version uint - Name string - GoVersion string - Os string - }{uint(versionMajor<<16 | versionMinor<<8 | versionPatch), clientIdentifier, runtime.Version(), runtime.GOOS} - extra, err := rlp.EncodeToBytes(clientInfo) - if err != nil { - glog.V(logger.Warn).Infoln("error setting canonical miner information:", err) - } - - if uint64(len(extra)) > params.MaximumExtraDataSize.Uint64() { - glog.V(logger.Warn).Infoln("error setting canonical miner information: extra exceeds", params.MaximumExtraDataSize) - glog.V(logger.Debug).Infof("extra: %x\n", extra) - return nil - } - return extra -} - -func preprocessDataDir(dataDir string) (string, error) { - testDataDir := path.Join(dataDir, "testnet", "keystore") - if _, err := os.Stat(testDataDir); os.IsNotExist(err) { - if err := os.MkdirAll(testDataDir, 0755); err != nil { - return dataDir, ErrDataDirPreprocessingFailed - } - } - - // copy over static peer nodes list (LES auto-discovery is not stable yet) - dst := filepath.Join(dataDir, "testnet", "static-nodes.json") - if _, err := os.Stat(dst); os.IsNotExist(err) { - src := filepath.Join("data", "static-nodes.json") - if err := copyFile(dst, src); err != nil { - return dataDir, err - } - } - - return dataDir, nil -} diff --git a/src/whisper.go b/src/whisper.go deleted file mode 100644 index 036194bf3..000000000 --- a/src/whisper.go +++ /dev/null @@ -1,62 +0,0 @@ -package main - -/* -#include -#include -extern bool GethServiceSignalEvent( const char *jsonEvent ); -*/ -import "C" -import ( - "encoding/json" - "time" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/whisper" -) - -var( - whisperFilters []int -) - - -func onWhisperMessage(message *whisper.Message) { - event := GethEvent{ - Type: "whisper", - Event: WhisperMessageEvent{ - Payload: string(message.Payload), - From: common.ToHex(crypto.FromECDSAPub(message.Recover())), - To: common.ToHex(crypto.FromECDSAPub(message.To)), - Sent: message.Sent.Unix(), - TTL: int64(message.TTL / time.Second), - Hash: common.ToHex(message.Hash.Bytes()), - }, - } - body, _ := json.Marshal(&event) - C.GethServiceSignalEvent(C.CString(string(body))) -} - -func doAddWhisperFilter(args whisper.NewFilterArgs) int { - var id int - filter := whisper.Filter{ - To: crypto.ToECDSAPub(common.FromHex(args.To)), - From: crypto.ToECDSAPub(common.FromHex(args.From)), - Topics: whisper.NewFilterTopics(args.Topics...), - Fn: onWhisperMessage, - } - - id = whisperService.Watch(filter) - whisperFilters = append(whisperFilters, id) - return id -} - -func doRemoveWhisperFilter(idFilter int) { - whisperService.Unwatch(idFilter) -} - -func doClearWhisperFilters() { - for _, idFilter := range whisperFilters { - doRemoveWhisperFilter(idFilter) - } - whisperFilters = nil -} \ No newline at end of file diff --git a/vendor/github.com/ethereum/go-ethereum/accounts/account_manager.go b/vendor/github.com/ethereum/go-ethereum/accounts/account_manager.go index da2862b17..a295bcee5 100644 --- a/vendor/github.com/ethereum/go-ethereum/accounts/account_manager.go +++ b/vendor/github.com/ethereum/go-ethereum/accounts/account_manager.go @@ -34,7 +34,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/status-im/status-go/src/extkeys" + "github.com/status-im/status-go/extkeys" ) var ( diff --git a/vendor/github.com/ethereum/go-ethereum/accounts/key.go b/vendor/github.com/ethereum/go-ethereum/accounts/key.go index f56d32eac..f01154311 100644 --- a/vendor/github.com/ethereum/go-ethereum/accounts/key.go +++ b/vendor/github.com/ethereum/go-ethereum/accounts/key.go @@ -33,7 +33,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/secp256k1" "github.com/pborman/uuid" - "github.com/status-im/status-go/src/extkeys" + "github.com/status-im/status-go/extkeys" ) const ( diff --git a/vendor/github.com/ethereum/go-ethereum/accounts/key_store_passphrase.go b/vendor/github.com/ethereum/go-ethereum/accounts/key_store_passphrase.go index a054f0006..700a4eadc 100644 --- a/vendor/github.com/ethereum/go-ethereum/accounts/key_store_passphrase.go +++ b/vendor/github.com/ethereum/go-ethereum/accounts/key_store_passphrase.go @@ -39,7 +39,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/randentropy" "github.com/pborman/uuid" - "github.com/status-im/status-go/src/extkeys" + "github.com/status-im/status-go/extkeys" "golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/scrypt" ) diff --git a/xgo/base/Dockerfile b/xgo/base/Dockerfile index 426c82640..3ddfc00ae 100644 --- a/xgo/base/Dockerfile +++ b/xgo/base/Dockerfile @@ -1,6 +1,6 @@ FROM karalabe/xgo-latest -# Inject the container entry point, the build script (patched for Status bindings conditional builds of library.c) +# Inject the container entry point, the build script (patched for Status bindings conditional builds of C code) ADD build.sh /build.sh ENV BUILD /build.sh RUN chmod +x $BUILD diff --git a/xgo/base/build.sh b/xgo/base/build.sh index ebe46681e..625e0e4f8 100644 --- a/xgo/base/build.sh +++ b/xgo/base/build.sh @@ -159,6 +159,7 @@ for TARGET in $TARGETS; do if [ "$PLATFORM" == "" ] || [ "$PLATFORM" == "." ] || [ "$PLATFORM" == "android" ]; then PLATFORM=16 # Jelly Bean 4.0.0 fi + CGO_STATUS_IM="-D ANDROID_DEPLOYMENT" if [ "$PLATFORM" -ge 16 ]; then CGO_CCPIE="-fPIE" CGO_LDPIE="-fPIE" @@ -190,11 +191,11 @@ for TARGET in $TARGETS; do if [ $XGOARCH == "." ] || [ $XGOARCH == "arm" ]; then CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK - CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go build $V $X "${T[@]}" --ldflags="$V $EXT_LDPIE $EXT_LDAMD $LD" $BM -o "/build/$NAME-android-$PLATFORM-arm`extension android`" ./$PACK + CGO_CFLAGS="-D ANDROID_DEPLOYMENT" CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE $CGO_STATUS_IM" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go build $V $X "${T[@]}" --ldflags="$V $EXT_LDPIE $EXT_LDAMD $LD" $BM -o "/build/$NAME-android-$PLATFORM-arm`extension android`" ./$PACK fi if [ $XGOARCH == "." ] || [ $XGOARCH == "aar" ]; then CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK - CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $EXT_LDAMD $LD" --buildmode=c-shared -o "/build-android-aar/$NAME-android-$PLATFORM-arm.so" ./$PACK + CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++ GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="$CGO_STATUS_IM" go build $V $X "${T[@]}" --ldflags="$V $EXT_LDAMD $LD" --buildmode=c-shared -o "/build-android-aar/$NAME-android-$PLATFORM-arm.so" ./$PACK fi fi fi @@ -214,11 +215,11 @@ for TARGET in $TARGETS; do if [ $XGOARCH == "." ] || [ $XGOARCH == "386" ]; then CC=i686-linux-android-gcc CXX=i686-linux-android-g++ GOOS=android GOARCH=386 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK - CC=i686-linux-android-gcc CXX=i686-linux-android-g++ GOOS=android GOARCH=386 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go build $V $X "${T[@]}" --ldflags="$V $EXT_LDPIE $LD" $BM -o "/build/$NAME-android-$PLATFORM-386`extension android`" ./$PACK + CC=i686-linux-android-gcc CXX=i686-linux-android-g++ GOOS=android GOARCH=386 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE $CGO_STATUS_IM" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go build $V $X "${T[@]}" --ldflags="$V $EXT_LDPIE $LD" $BM -o "/build/$NAME-android-$PLATFORM-386`extension android`" ./$PACK fi if [ $XGOARCH == "." ] || [ $XGOARCH == "aar" ]; then CC=i686-linux-android-gcc CXX=i686-linux-android-g++ GOOS=android GOARCH=386 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK - CC=i686-linux-android-gcc CXX=i686-linux-android-g++ GOOS=android GOARCH=386 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $LD" --buildmode=c-shared -o "/build-android-aar/$NAME-android-$PLATFORM-386.so" ./$PACK + CC=i686-linux-android-gcc CXX=i686-linux-android-g++ GOOS=android GOARCH=386 CGO_ENABLED=1 CGO_CFLAGS="$CGO_STATUS_IM" go build $V $X "${T[@]}" --ldflags="$V $LD" --buildmode=c-shared -o "/build-android-aar/$NAME-android-$PLATFORM-386.so" ./$PACK fi fi if [ "$PLATFORM" -ge 21 ] && ([ $XGOARCH == "." ] || [ $XGOARCH == "arm64" ] || [ $XGOARCH == "aar" ]); then @@ -234,14 +235,15 @@ for TARGET in $TARGETS; do if [ $XGOARCH == "." ] || [ $XGOARCH == "arm64" ]; then CC=aarch64-linux-android-gcc CXX=aarch64-linux-android-g++ GOOS=android GOARCH=arm64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK - CC=aarch64-linux-android-gcc CXX=aarch64-linux-android-g++ GOOS=android GOARCH=arm64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go build $V $X "${T[@]}" --ldflags="$V $EXT_LDPIE $LD" $BM -o "/build/$NAME-android-$PLATFORM-arm64`extension android`" ./$PACK + CC=aarch64-linux-android-gcc CXX=aarch64-linux-android-g++ GOOS=android GOARCH=arm64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_CCPIE $CGO_STATUS_IM" CGO_CXXFLAGS="$CGO_CCPIE" CGO_LDFLAGS="$CGO_LDPIE" go build $V $X "${T[@]}" --ldflags="$V $EXT_LDPIE $LD" $BM -o "/build/$NAME-android-$PLATFORM-arm64`extension android`" ./$PACK fi if [ $XGOARCH == "." ] || [ $XGOARCH == "aar" ]; then CC=aarch64-linux-android-gcc CXX=aarch64-linux-android-g++ GOOS=android GOARCH=arm64 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$V $LD" -d ./$PACK - CC=aarch64-linux-android-gcc CXX=aarch64-linux-android-g++ GOOS=android GOARCH=arm64 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$V $LD" --buildmode=c-shared -o "/build-android-aar/$NAME-android-$PLATFORM-arm64.so" ./$PACK + CC=aarch64-linux-android-gcc CXX=aarch64-linux-android-g++ GOOS=android GOARCH=arm64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_STATUS_IM" go build $V $X "${T[@]}" --ldflags="$V $LD" --buildmode=c-shared -o "/build-android-aar/$NAME-android-$PLATFORM-arm64.so" ./$PACK fi fi fi + unset CGO_STATUS_IM # good to let that extra var go away # Assemble the Android Archive from the built shared libraries if [ $XGOARCH == "." ] || [ $XGOARCH == "aar" ]; then title=${NAME^} @@ -491,7 +493,7 @@ for TARGET in $TARGETS; do if [ "$GO_VERSION" -lt 160 ]; then LDSTRIP="-s" fi - STATUS_IM_CFLAGS="-D IOS_DEPLOYMENT" + CGO_STATUS_IM="-D IOS_DEPLOYMENT" # Cross compile to all available iOS and simulator platforms if [ -d "$IOS_NDK_ARM_7" ] && ([ $XGOARCH == "." ] || [ $XGOARCH == "arm-7" ] || [ $XGOARCH == "framework" ]); then echo "Bootstrapping ios-$PLATFORM/arm-7..." @@ -505,7 +507,7 @@ for TARGET in $TARGETS; do CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-ios-$PLATFORM-armv7`extension darwin`" ./$PACK fi if [ $XGOARCH == "." ] || [ $XGOARCH == "framework" ]; then - CGO_CFLAGS="-D IOS_DEPLOYMENT" CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" --buildmode=c-archive -o "/build-ios-fw/$NAME-ios-$PLATFORM-armv7.a" ./$PACK + CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="$CGO_STATUS_IM" go build $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" --buildmode=c-archive -o "/build-ios-fw/$NAME-ios-$PLATFORM-armv7.a" ./$PACK fi echo "Cleaning up Go runtime for ios-$PLATFORM/arm-7..." rm -rf /usr/local/go/pkg/darwin_arm @@ -519,10 +521,10 @@ for TARGET in $TARGETS; do CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ HOST=arm-apple-darwin11 PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]} CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go get $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" -d ./$PACK if [ $XGOARCH == "." ] || [ $XGOARCH == "arm64" ]; then - CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-ios-$PLATFORM-arm64`extension darwin`" ./$PACK + CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_STATUS_IM" go build $V $X "${IOSTAGS[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-ios-$PLATFORM-arm64`extension darwin`" ./$PACK fi if [ $XGOARCH == "." ] || [ $XGOARCH == "framework" ]; then - CGO_CFLAGS="-D IOS_DEPLOYMENT" CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" --buildmode=c-archive -o "/build-ios-fw/$NAME-ios-$PLATFORM-arm64.a" ./$PACK + CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_STATUS_IM" go build $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" --buildmode=c-archive -o "/build-ios-fw/$NAME-ios-$PLATFORM-arm64.a" ./$PACK fi echo "Cleaning up Go runtime for ios-$PLATFORM/arm64..." rm -rf /usr/local/go/pkg/darwin_arm64 @@ -537,15 +539,16 @@ for TARGET in $TARGETS; do CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ HOST=arm-apple-darwin11 PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]} CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go get $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" -d ./$PACK if [ $XGOARCH == "." ] || [ $XGOARCH == "amd64" ]; then - CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-ios-$PLATFORM-x86_64`extension darwin`" ./$PACK + CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_STATUS_IM" go build $V $X "${IOSTAGS[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-ios-$PLATFORM-x86_64`extension darwin`" ./$PACK fi if [ $XGOARCH == "." ] || [ $XGOARCH == "framework" ]; then - CGO_CFLAGS="-D IOS_DEPLOYMENT" CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" --buildmode=c-archive -o "/build-ios-fw/$NAME-ios-$PLATFORM-x86_64.a" ./$PACK + CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 CGO_CFLAGS="$CGO_STATUS_IM" go build $V $X "${IOSTAGS[@]}" --ldflags="$V $LD" --buildmode=c-archive -o "/build-ios-fw/$NAME-ios-$PLATFORM-x86_64.a" ./$PACK fi echo "Cleaning up Go runtime for ios-$PLATFORM/amd64..." rm -rf /usr/local/go/pkg/darwin_amd64 mv /usr/local/go/pkg/darwin_amd64_bak /usr/local/go/pkg/darwin_amd64 fi + unset CGO_STATUS_IM # Assemble the iOS framework from the built binaries if [ $XGOARCH == "." ] || [ $XGOARCH == "framework" ]; then title=${NAME^} From b66188941da3751d923b3367a1321c8b765a5891 Mon Sep 17 00:00:00 2001 From: Victor Farazdagi Date: Thu, 15 Sep 2016 06:08:06 +0300 Subject: [PATCH 3/3] Non-blocking StartNode() --- cmd/status/library.go | 10 ----- geth/node.go | 100 +++++++++++++++++++++++++----------------- geth/node_test.go | 25 +++++++++-- geth/txqueue_test.go | 4 +- geth/utils.go | 40 ++++++++++++++--- 5 files changed, 117 insertions(+), 62 deletions(-) diff --git a/cmd/status/library.go b/cmd/status/library.go index 466d2a2d7..b56540409 100644 --- a/cmd/status/library.go +++ b/cmd/status/library.go @@ -1,10 +1,5 @@ package main -/* -#include -#include -extern bool StatusServiceSignalEvent(const char *jsonEvent); -*/ import "C" import ( "encoding/json" @@ -16,11 +11,6 @@ import ( "github.com/status-im/status-go/jail" ) -// export TriggerTestSignal -func TriggerTestSignal() { - C.StatusServiceSignalEvent(C.CString(`{"answer": 42}`)) -} - //export CreateAccount func CreateAccount(password *C.char) *C.char { // This is equivalent to creating an account from the command line, diff --git a/geth/node.go b/geth/node.go index 7fbde6b32..e35e0fda7 100644 --- a/geth/node.go +++ b/geth/node.go @@ -1,6 +1,13 @@ package geth +/* +#include +#include +extern bool StatusServiceSignalEvent( const char *jsonEvent ); +*/ +import "C" import ( + "encoding/json" "errors" "flag" "fmt" @@ -33,6 +40,8 @@ const ( versionOracle = "0xfa7b9770ca4cb04296cac84f37736d4041251cdf" // Ethereum address of the Geth release oracle RPCPort = 8545 // RPC port (replaced in unit tests) + + EventNodeStarted = "node.started" ) var ( @@ -45,17 +54,15 @@ var ( ErrNodeStartFailure = errors.New("could not create the in-memory node object") ) -type NodeNotificationHandler func(jsonEvent string) - type NodeManager struct { - currentNode *node.Node // currently running geth node - ctx *cli.Context // the CLI context used to start the geth node - lightEthereum *les.LightEthereum // LES service - accountManager *accounts.Manager // the account manager attached to the currentNode - SelectedAddress string // address of the account that was processed during the last call to SelectAccount() - whisperService *whisper.Whisper // Whisper service - client *rpc.ClientRestartWrapper // RPC client - notificationHandler NodeNotificationHandler // internal signal handler (used in tests) + currentNode *node.Node // currently running geth node + ctx *cli.Context // the CLI context used to start the geth node + lightEthereum *les.LightEthereum // LES service + accountManager *accounts.Manager // the account manager attached to the currentNode + SelectedAddress string // address of the account that was processed during the last call to SelectAccount() + whisperService *whisper.Whisper // Whisper service + client *rpc.ClientRestartWrapper // RPC client + nodeStarted chan struct{} // channel to wait for node to start } var ( @@ -67,9 +74,6 @@ func NewNodeManager(datadir string, rpcport int) *NodeManager { createOnce.Do(func() { nodeManagerInstance = &NodeManager{} nodeManagerInstance.MakeNode(datadir, rpcport) - nodeManagerInstance.SetNotificationHandler(func(jsonEvent string) { - glog.V(logger.Info).Infof("internal notification received: %s\n", jsonEvent) - }) }) return nodeManagerInstance @@ -80,12 +84,14 @@ func GetNodeManager() *NodeManager { } // createAndStartNode creates a node entity and starts the -// node running locally +// node running locally exposing given RPC port func CreateAndRunNode(datadir string, rpcport int) error { nodeManager := NewNodeManager(datadir, rpcport) if nodeManager.HasNode() { nodeManager.RunNode() + + <-nodeManager.nodeStarted // block until node is ready return nil } @@ -135,33 +141,53 @@ func (m *NodeManager) MakeNode(datadir string, rpcport int) *node.Node { } m.accountManager = m.currentNode.AccountManager() + m.nodeStarted = make(chan struct{}) return m.currentNode } // StartNode starts a geth node entity func (m *NodeManager) RunNode() { - utils.StartNode(m.currentNode) + go func() { + utils.StartNode(m.currentNode) - if m.currentNode.AccountManager() == nil { - glog.V(logger.Warn).Infoln("cannot get account manager") - } - if err := m.currentNode.Service(&m.whisperService); err != nil { - glog.V(logger.Warn).Infoln("cannot get whisper service:", err) - } - if err := m.currentNode.Service(&m.lightEthereum); err != nil { - glog.V(logger.Warn).Infoln("cannot get light ethereum service:", err) - } - m.lightEthereum.StatusBackend.SetTransactionQueueHandler(onSendTransactionRequest) - - m.client = rpc.NewClientRestartWrapper(func() *rpc.Client { - client, err := m.currentNode.Attach() - if err != nil { - return nil + if m.currentNode.AccountManager() == nil { + glog.V(logger.Warn).Infoln("cannot get account manager") } - return client - }) - m.currentNode.Wait() + if err := m.currentNode.Service(&m.whisperService); err != nil { + glog.V(logger.Warn).Infoln("cannot get whisper service:", err) + } + if err := m.currentNode.Service(&m.lightEthereum); err != nil { + glog.V(logger.Warn).Infoln("cannot get light ethereum service:", err) + } + m.lightEthereum.StatusBackend.SetTransactionQueueHandler(onSendTransactionRequest) + + m.client = rpc.NewClientRestartWrapper(func() *rpc.Client { + client, err := m.currentNode.Attach() + if err != nil { + return nil + } + return client + }) + + m.onNodeStarted() // node started, notify listeners + m.currentNode.Wait() + }() +} + +func (m *NodeManager) onNodeStarted() { + // notify local listener + m.nodeStarted <- struct{}{} + close(m.nodeStarted) + + // send signal up to native app + event := GethEvent{ + Type: EventNodeStarted, + Event: struct{}{}, + } + + body, _ := json.Marshal(&event) + C.StatusServiceSignalEvent(C.CString(string(body))) } func (m *NodeManager) AddPeer(url string) (bool, error) { @@ -251,14 +277,6 @@ func (m *NodeManager) ClientRestartWrapper() (*rpc.ClientRestartWrapper, error) return m.client, nil } -func (m *NodeManager) SetNotificationHandler(fn NodeNotificationHandler) { - m.notificationHandler = fn -} - -func (m *NodeManager) NotificationHandler() NodeNotificationHandler { - return m.notificationHandler -} - func makeDefaultExtra() []byte { var clientInfo = struct { Version uint diff --git a/geth/node_test.go b/geth/node_test.go index aa0c7b86a..a9959d425 100644 --- a/geth/node_test.go +++ b/geth/node_test.go @@ -1,8 +1,11 @@ package geth_test import ( - "github.com/status-im/status-go/geth" + "os" "testing" + "time" + + "github.com/status-im/status-go/geth" ) const ( @@ -17,10 +20,26 @@ const ( whisperMessage5 = "test message 5 (K2 -> K1)" ) -func TestNodeSetup(t *testing.T) { +func TestMain(m *testing.M) { + // make sure you panic if node start signal is not received + signalRecieved := make(chan struct{}, 1) + abortPanic := make(chan bool, 1) + geth.PanicAfter(10*time.Second, abortPanic, "TestNodeSetup") + + geth.SetDefaultNodeNotificationHandler(func(jsonEvent string) { + if jsonEvent == `{"type":"node.started","event":{}}` { + signalRecieved <- struct{}{} + } + }) + err := geth.PrepareTestNode() if err != nil { - t.Error(err) + panic(err) return } + + <-signalRecieved // block and wait for either panic or successful signal + abortPanic <- true + + os.Exit(m.Run()) } diff --git a/geth/txqueue_test.go b/geth/txqueue_test.go index 10c2fb520..4f3d229fd 100644 --- a/geth/txqueue_test.go +++ b/geth/txqueue_test.go @@ -46,11 +46,11 @@ func TestQueuedTransactions(t *testing.T) { // make sure you panic if transaction complete doesn't return completeQueuedTransaction := make(chan bool, 1) - geth.PanicAfter(20*time.Second, completeQueuedTransaction) + geth.PanicAfter(20*time.Second, completeQueuedTransaction, "TestQueuedTransactions") // replace transaction notification handler var txHash = common.Hash{} - geth.GetNodeManager().SetNotificationHandler(func(jsonEvent string) { + geth.SetDefaultNodeNotificationHandler(func(jsonEvent string) { var envelope geth.GethEvent if err := json.Unmarshal([]byte(jsonEvent), &envelope); err != nil { t.Errorf("cannot unmarshal event's JSON: %s", jsonEvent) diff --git a/geth/utils.go b/geth/utils.go index 8e698e1e5..4feeaaccb 100644 --- a/geth/utils.go +++ b/geth/utils.go @@ -1,5 +1,10 @@ package geth +/* +#include +#include +extern bool StatusServiceSignalEvent(const char *jsonEvent); +*/ import "C" import ( "bytes" @@ -21,9 +26,24 @@ const ( testNodeSyncSeconds = 300 ) +type NodeNotificationHandler func(jsonEvent string) + +var notificationHandler NodeNotificationHandler = func(jsonEvent string) { // internal signal handler (used in tests) + glog.V(logger.Info).Infof("notification received (default notification handler): %s\n", jsonEvent) +} + +func SetDefaultNodeNotificationHandler(fn NodeNotificationHandler) { + notificationHandler = fn +} + //export NotifyNode func NotifyNode(jsonEvent *C.char) { - GetNodeManager().NotificationHandler()(C.GoString(jsonEvent)) + notificationHandler(C.GoString(jsonEvent)) +} + +// export TriggerTestSignal +func TriggerTestSignal() { + C.StatusServiceSignalEvent(C.CString(`{"answer": 42}`)) } func CopyFile(dst, src string) error { @@ -93,12 +113,20 @@ func PrepareTestNode() (err error) { // start geth node and wait for it to initialize // internally once.Do() is used, so call below is thread-safe - go CreateAndRunNode(dataDir, 8546) // to avoid conflicts with running react-native app, run on different port - time.Sleep(3 * time.Second) + CreateAndRunNode(dataDir, 8546) // to avoid conflicts with running react-native app, run on different port manager = GetNodeManager() if !manager.HasNode() { - panic("could not obtain geth node") + panic(ErrInvalidGethNode) + } + if !manager.HasClientRestartWrapper() { + panic(ErrInvalidGethNode) + } + if !manager.HasWhisperService() { + panic(ErrInvalidGethNode) + } + if !manager.HasLightEthereumService() { + panic(ErrInvalidGethNode) } manager.AddPeer("enode://409772c7dea96fa59a912186ad5bcdb5e51b80556b3fe447d940f99d9eaadb51d4f0ffedb68efad232b52475dd7bd59b51cee99968b3cc79e2d5684b33c4090c@139.162.166.59:30303") @@ -141,7 +169,7 @@ func PreprocessDataDir(dataDir string) (string, error) { } // PanicAfter throws panic() after waitSeconds, unless abort channel receives notification -func PanicAfter(waitSeconds time.Duration, abort chan bool) { +func PanicAfter(waitSeconds time.Duration, abort chan bool, desc string) { // panic if function takes too long timeout := make(chan bool, 1) @@ -155,7 +183,7 @@ func PanicAfter(waitSeconds time.Duration, abort chan bool) { case <-abort: return case <-timeout: - panic("function takes to long, which generally means we are stuck") + panic("whatever you were doing takes toooo long: " + desc) } }() }