├── .gitignore ├── README.md ├── myp2p ├── Godeps │ ├── Godeps.json │ ├── Readme │ └── _workspace │ │ ├── .gitignore │ │ └── src │ │ └── github.com │ │ └── ethereum │ │ └── go-ethereum │ │ ├── common │ │ ├── big.go │ │ ├── bitutil │ │ │ ├── bitutil.go │ │ │ ├── bitutil_test.go │ │ │ ├── compress.go │ │ │ ├── compress_fuzz.go │ │ │ └── compress_test.go │ │ ├── bytes.go │ │ ├── bytes_test.go │ │ ├── compiler │ │ │ ├── solidity.go │ │ │ └── solidity_test.go │ │ ├── debug.go │ │ ├── fdlimit │ │ │ ├── fdlimit_freebsd.go │ │ │ ├── fdlimit_test.go │ │ │ ├── fdlimit_unix.go │ │ │ └── fdlimit_windows.go │ │ ├── format.go │ │ ├── hexutil │ │ │ ├── hexutil.go │ │ │ ├── hexutil_test.go │ │ │ ├── json.go │ │ │ ├── json_example_test.go │ │ │ └── json_test.go │ │ ├── main_test.go │ │ ├── math │ │ │ ├── big.go │ │ │ ├── big_test.go │ │ │ ├── integer.go │ │ │ └── integer_test.go │ │ ├── mclock │ │ │ └── mclock.go │ │ ├── number │ │ │ ├── int.go │ │ │ └── uint_test.go │ │ ├── path.go │ │ ├── size.go │ │ ├── size_test.go │ │ ├── test_utils.go │ │ ├── types.go │ │ ├── types_template.go │ │ └── types_test.go │ │ ├── crypto │ │ ├── bn256 │ │ │ ├── bn256.go │ │ │ ├── bn256_test.go │ │ │ ├── constants.go │ │ │ ├── curve.go │ │ │ ├── example_test.go │ │ │ ├── gfp12.go │ │ │ ├── gfp2.go │ │ │ ├── gfp6.go │ │ │ ├── main_test.go │ │ │ ├── optate.go │ │ │ └── twist.go │ │ ├── crypto.go │ │ ├── crypto_test.go │ │ ├── ecies │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README │ │ │ ├── ecies.go │ │ │ ├── ecies_test.go │ │ │ └── params.go │ │ ├── randentropy │ │ │ └── rand_entropy.go │ │ ├── secp256k1 │ │ │ ├── .gitignore │ │ │ ├── curve.go │ │ │ ├── ext.h │ │ │ ├── libsecp256k1 │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── COPYING │ │ │ │ ├── Makefile.am │ │ │ │ ├── README.md │ │ │ │ ├── TODO │ │ │ │ ├── autogen.sh │ │ │ │ ├── build-aux │ │ │ │ │ └── m4 │ │ │ │ │ │ ├── ax_jni_include_dir.m4 │ │ │ │ │ │ ├── ax_prog_cc_for_build.m4 │ │ │ │ │ │ └── bitcoin_secp.m4 │ │ │ │ ├── configure.ac │ │ │ │ ├── contrib │ │ │ │ │ ├── lax_der_parsing.c │ │ │ │ │ ├── lax_der_parsing.h │ │ │ │ │ ├── lax_der_privatekey_parsing.c │ │ │ │ │ └── lax_der_privatekey_parsing.h │ │ │ │ ├── include │ │ │ │ │ ├── secp256k1.h │ │ │ │ │ ├── secp256k1_ecdh.h │ │ │ │ │ └── secp256k1_recovery.h │ │ │ │ ├── libsecp256k1.pc.in │ │ │ │ ├── obj │ │ │ │ │ └── .gitignore │ │ │ │ ├── sage │ │ │ │ │ ├── group_prover.sage │ │ │ │ │ ├── secp256k1.sage │ │ │ │ │ └── weierstrass_prover.sage │ │ │ │ └── src │ │ │ │ │ ├── asm │ │ │ │ │ └── field_10x26_arm.s │ │ │ │ │ ├── basic-config.h │ │ │ │ │ ├── bench.h │ │ │ │ │ ├── bench_ecdh.c │ │ │ │ │ ├── bench_internal.c │ │ │ │ │ ├── bench_recover.c │ │ │ │ │ ├── bench_schnorr_verify.c │ │ │ │ │ ├── bench_sign.c │ │ │ │ │ ├── bench_verify.c │ │ │ │ │ ├── ecdsa.h │ │ │ │ │ ├── ecdsa_impl.h │ │ │ │ │ ├── eckey.h │ │ │ │ │ ├── eckey_impl.h │ │ │ │ │ ├── ecmult.h │ │ │ │ │ ├── ecmult_const.h │ │ │ │ │ ├── ecmult_const_impl.h │ │ │ │ │ ├── ecmult_gen.h │ │ │ │ │ ├── ecmult_gen_impl.h │ │ │ │ │ ├── ecmult_impl.h │ │ │ │ │ ├── field.h │ │ │ │ │ ├── field_10x26.h │ │ │ │ │ ├── field_10x26_impl.h │ │ │ │ │ ├── field_5x52.h │ │ │ │ │ ├── field_5x52_asm_impl.h │ │ │ │ │ ├── field_5x52_impl.h │ │ │ │ │ ├── field_5x52_int128_impl.h │ │ │ │ │ ├── field_impl.h │ │ │ │ │ ├── gen_context.c │ │ │ │ │ ├── group.h │ │ │ │ │ ├── group_impl.h │ │ │ │ │ ├── hash.h │ │ │ │ │ ├── hash_impl.h │ │ │ │ │ ├── java │ │ │ │ │ ├── org │ │ │ │ │ │ └── bitcoin │ │ │ │ │ │ │ ├── NativeSecp256k1.java │ │ │ │ │ │ │ ├── NativeSecp256k1Test.java │ │ │ │ │ │ │ ├── NativeSecp256k1Util.java │ │ │ │ │ │ │ └── Secp256k1Context.java │ │ │ │ │ ├── org_bitcoin_NativeSecp256k1.c │ │ │ │ │ ├── org_bitcoin_NativeSecp256k1.h │ │ │ │ │ ├── org_bitcoin_Secp256k1Context.c │ │ │ │ │ └── org_bitcoin_Secp256k1Context.h │ │ │ │ │ ├── modules │ │ │ │ │ ├── ecdh │ │ │ │ │ │ ├── Makefile.am.include │ │ │ │ │ │ ├── main_impl.h │ │ │ │ │ │ └── tests_impl.h │ │ │ │ │ └── recovery │ │ │ │ │ │ ├── Makefile.am.include │ │ │ │ │ │ ├── main_impl.h │ │ │ │ │ │ └── tests_impl.h │ │ │ │ │ ├── num.h │ │ │ │ │ ├── num_gmp.h │ │ │ │ │ ├── num_gmp_impl.h │ │ │ │ │ ├── num_impl.h │ │ │ │ │ ├── scalar.h │ │ │ │ │ ├── scalar_4x64.h │ │ │ │ │ ├── scalar_4x64_impl.h │ │ │ │ │ ├── scalar_8x32.h │ │ │ │ │ ├── scalar_8x32_impl.h │ │ │ │ │ ├── scalar_impl.h │ │ │ │ │ ├── scalar_low.h │ │ │ │ │ ├── scalar_low_impl.h │ │ │ │ │ ├── secp256k1.c │ │ │ │ │ ├── testrand.h │ │ │ │ │ ├── testrand_impl.h │ │ │ │ │ ├── tests.c │ │ │ │ │ ├── tests_exhaustive.c │ │ │ │ │ └── util.h │ │ │ ├── panic_cb.go │ │ │ ├── secp256.go │ │ │ └── secp256_test.go │ │ ├── sha3 │ │ │ ├── LICENSE │ │ │ ├── PATENTS │ │ │ ├── doc.go │ │ │ ├── hashes.go │ │ │ ├── keccakf.go │ │ │ ├── keccakf_amd64.go │ │ │ ├── keccakf_amd64.s │ │ │ ├── register.go │ │ │ ├── sha3.go │ │ │ ├── sha3_test.go │ │ │ ├── shake.go │ │ │ ├── testdata │ │ │ │ └── keccakKats.json.deflate │ │ │ ├── xor.go │ │ │ ├── xor_generic.go │ │ │ └── xor_unaligned.go │ │ ├── signature_cgo.go │ │ ├── signature_nocgo.go │ │ └── signature_test.go │ │ ├── event │ │ ├── event.go │ │ ├── event_test.go │ │ ├── example_feed_test.go │ │ ├── example_scope_test.go │ │ ├── example_subscription_test.go │ │ ├── example_test.go │ │ ├── feed.go │ │ ├── feed_test.go │ │ ├── filter │ │ │ ├── filter.go │ │ │ ├── filter_test.go │ │ │ └── generic_filter.go │ │ ├── subscription.go │ │ └── subscription_test.go │ │ ├── log │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── README.md │ │ ├── README_ETHEREUM.md │ │ ├── doc.go │ │ ├── format.go │ │ ├── handler.go │ │ ├── handler_glog.go │ │ ├── handler_go13.go │ │ ├── handler_go14.go │ │ ├── logger.go │ │ ├── root.go │ │ ├── syslog.go │ │ └── term │ │ │ ├── LICENSE │ │ │ ├── terminal_appengine.go │ │ │ ├── terminal_darwin.go │ │ │ ├── terminal_freebsd.go │ │ │ ├── terminal_linux.go │ │ │ ├── terminal_netbsd.go │ │ │ ├── terminal_notwindows.go │ │ │ ├── terminal_openbsd.go │ │ │ ├── terminal_solaris.go │ │ │ └── terminal_windows.go │ │ ├── metrics │ │ ├── disk.go │ │ ├── disk_linux.go │ │ ├── disk_nop.go │ │ └── metrics.go │ │ ├── p2p │ │ ├── dial.go │ │ ├── dial_test.go │ │ ├── discover │ │ │ ├── database.go │ │ │ ├── database_test.go │ │ │ ├── node.go │ │ │ ├── node_test.go │ │ │ ├── ntp.go │ │ │ ├── table.go │ │ │ ├── table_test.go │ │ │ ├── udp.go │ │ │ └── udp_test.go │ │ ├── discv5 │ │ │ ├── database.go │ │ │ ├── database_test.go │ │ │ ├── net.go │ │ │ ├── net_test.go │ │ │ ├── node.go │ │ │ ├── node_test.go │ │ │ ├── nodeevent_string.go │ │ │ ├── ntp.go │ │ │ ├── sim_run_test.go │ │ │ ├── sim_test.go │ │ │ ├── sim_testmain_test.go │ │ │ ├── table.go │ │ │ ├── table_test.go │ │ │ ├── ticket.go │ │ │ ├── topic.go │ │ │ ├── topic_test.go │ │ │ ├── udp.go │ │ │ └── udp_test.go │ │ ├── enr │ │ │ ├── enr.go │ │ │ ├── enr_test.go │ │ │ └── entries.go │ │ ├── message.go │ │ ├── message_test.go │ │ ├── metrics.go │ │ ├── nat │ │ │ ├── nat.go │ │ │ ├── nat_test.go │ │ │ ├── natpmp.go │ │ │ ├── natupnp.go │ │ │ └── natupnp_test.go │ │ ├── netutil │ │ │ ├── error.go │ │ │ ├── error_test.go │ │ │ ├── net.go │ │ │ ├── net_test.go │ │ │ ├── toobig_notwindows.go │ │ │ └── toobig_windows.go │ │ ├── peer.go │ │ ├── peer_error.go │ │ ├── peer_test.go │ │ ├── protocol.go │ │ ├── rlpx.go │ │ ├── rlpx_test.go │ │ ├── server.go │ │ ├── server_test.go │ │ └── simulations │ │ │ ├── README.md │ │ │ ├── adapters │ │ │ ├── docker.go │ │ │ ├── exec.go │ │ │ ├── inproc.go │ │ │ ├── state.go │ │ │ └── types.go │ │ │ ├── events.go │ │ │ ├── examples │ │ │ ├── README.md │ │ │ ├── ping-pong.go │ │ │ └── ping-pong.sh │ │ │ ├── http.go │ │ │ ├── http_test.go │ │ │ ├── mocker.go │ │ │ ├── mocker_test.go │ │ │ ├── network.go │ │ │ ├── network_test.go │ │ │ └── simulation.go │ │ ├── rlp │ │ ├── decode.go │ │ ├── decode_tail_test.go │ │ ├── decode_test.go │ │ ├── doc.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── encoder_example_test.go │ │ ├── raw.go │ │ ├── raw_test.go │ │ └── typecache.go │ │ └── vendor │ │ ├── github.com │ │ ├── aristanetworks │ │ │ └── goarista │ │ │ │ └── monotime │ │ │ │ ├── issue15006.s │ │ │ │ └── nanotime.go │ │ ├── go-stack │ │ │ └── stack │ │ │ │ ├── LICENSE.md │ │ │ │ ├── README.md │ │ │ │ └── stack.go │ │ ├── golang │ │ │ └── snappy │ │ │ │ ├── AUTHORS │ │ │ │ ├── CONTRIBUTORS │ │ │ │ ├── LICENSE │ │ │ │ ├── README │ │ │ │ ├── decode.go │ │ │ │ ├── decode_amd64.go │ │ │ │ ├── decode_amd64.s │ │ │ │ ├── decode_other.go │ │ │ │ ├── encode.go │ │ │ │ ├── encode_amd64.go │ │ │ │ ├── encode_amd64.s │ │ │ │ ├── encode_other.go │ │ │ │ └── snappy.go │ │ ├── huin │ │ │ └── goupnp │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── dcps │ │ │ │ ├── internetgateway1 │ │ │ │ │ └── internetgateway1.go │ │ │ │ └── internetgateway2 │ │ │ │ │ └── internetgateway2.go │ │ │ │ ├── device.go │ │ │ │ ├── goupnp.go │ │ │ │ ├── httpu │ │ │ │ ├── httpu.go │ │ │ │ └── serve.go │ │ │ │ ├── scpd │ │ │ │ └── scpd.go │ │ │ │ ├── service_client.go │ │ │ │ ├── soap │ │ │ │ ├── soap.go │ │ │ │ └── types.go │ │ │ │ └── ssdp │ │ │ │ ├── registry.go │ │ │ │ └── ssdp.go │ │ ├── jackpal │ │ │ └── go-nat-pmp │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── natpmp.go │ │ │ │ ├── network.go │ │ │ │ └── recorder.go │ │ ├── rcrowley │ │ │ └── go-metrics │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── counter.go │ │ │ │ ├── debug.go │ │ │ │ ├── ewma.go │ │ │ │ ├── exp │ │ │ │ └── exp.go │ │ │ │ ├── gauge.go │ │ │ │ ├── gauge_float64.go │ │ │ │ ├── graphite.go │ │ │ │ ├── healthcheck.go │ │ │ │ ├── histogram.go │ │ │ │ ├── json.go │ │ │ │ ├── log.go │ │ │ │ ├── memory.md │ │ │ │ ├── meter.go │ │ │ │ ├── metrics.go │ │ │ │ ├── opentsdb.go │ │ │ │ ├── registry.go │ │ │ │ ├── runtime.go │ │ │ │ ├── runtime_cgo.go │ │ │ │ ├── runtime_gccpufraction.go │ │ │ │ ├── runtime_no_cgo.go │ │ │ │ ├── runtime_no_gccpufraction.go │ │ │ │ ├── sample.go │ │ │ │ ├── syslog.go │ │ │ │ ├── timer.go │ │ │ │ ├── validate.sh │ │ │ │ └── writer.go │ │ └── syndtr │ │ │ └── goleveldb │ │ │ └── leveldb │ │ │ ├── batch.go │ │ │ ├── cache │ │ │ ├── cache.go │ │ │ └── lru.go │ │ │ ├── comparer.go │ │ │ ├── comparer │ │ │ ├── bytes_comparer.go │ │ │ └── comparer.go │ │ │ ├── db.go │ │ │ ├── db_compaction.go │ │ │ ├── db_iter.go │ │ │ ├── db_snapshot.go │ │ │ ├── db_state.go │ │ │ ├── db_transaction.go │ │ │ ├── db_util.go │ │ │ ├── db_write.go │ │ │ ├── doc.go │ │ │ ├── errors.go │ │ │ ├── errors │ │ │ └── errors.go │ │ │ ├── filter.go │ │ │ ├── filter │ │ │ ├── bloom.go │ │ │ └── filter.go │ │ │ ├── iterator │ │ │ ├── array_iter.go │ │ │ ├── indexed_iter.go │ │ │ ├── iter.go │ │ │ └── merged_iter.go │ │ │ ├── journal │ │ │ └── journal.go │ │ │ ├── key.go │ │ │ ├── memdb │ │ │ └── memdb.go │ │ │ ├── opt │ │ │ └── options.go │ │ │ ├── options.go │ │ │ ├── session.go │ │ │ ├── session_compaction.go │ │ │ ├── session_record.go │ │ │ ├── session_util.go │ │ │ ├── storage │ │ │ ├── file_storage.go │ │ │ ├── file_storage_nacl.go │ │ │ ├── file_storage_plan9.go │ │ │ ├── file_storage_solaris.go │ │ │ ├── file_storage_unix.go │ │ │ ├── file_storage_windows.go │ │ │ ├── mem_storage.go │ │ │ └── storage.go │ │ │ ├── table.go │ │ │ ├── table │ │ │ ├── reader.go │ │ │ ├── table.go │ │ │ └── writer.go │ │ │ ├── util.go │ │ │ ├── util │ │ │ ├── buffer.go │ │ │ ├── buffer_pool.go │ │ │ ├── crc32.go │ │ │ ├── hash.go │ │ │ ├── range.go │ │ │ └── util.go │ │ │ └── version.go │ │ └── golang.org │ │ └── x │ │ ├── net │ │ └── html │ │ │ ├── atom │ │ │ ├── atom.go │ │ │ ├── gen.go │ │ │ └── table.go │ │ │ ├── charset │ │ │ └── charset.go │ │ │ ├── const.go │ │ │ ├── doc.go │ │ │ ├── doctype.go │ │ │ ├── entity.go │ │ │ ├── escape.go │ │ │ ├── foreign.go │ │ │ ├── node.go │ │ │ ├── parse.go │ │ │ ├── render.go │ │ │ └── token.go │ │ └── text │ │ ├── encoding │ │ ├── charmap │ │ │ ├── charmap.go │ │ │ ├── maketables.go │ │ │ └── tables.go │ │ ├── encoding.go │ │ ├── htmlindex │ │ │ ├── gen.go │ │ │ ├── htmlindex.go │ │ │ ├── map.go │ │ │ └── tables.go │ │ ├── internal │ │ │ ├── identifier │ │ │ │ ├── gen.go │ │ │ │ ├── identifier.go │ │ │ │ └── mib.go │ │ │ └── internal.go │ │ ├── japanese │ │ │ ├── all.go │ │ │ ├── eucjp.go │ │ │ ├── iso2022jp.go │ │ │ ├── maketables.go │ │ │ ├── shiftjis.go │ │ │ └── tables.go │ │ ├── korean │ │ │ ├── euckr.go │ │ │ ├── maketables.go │ │ │ └── tables.go │ │ ├── simplifiedchinese │ │ │ ├── all.go │ │ │ ├── gbk.go │ │ │ ├── hzgb2312.go │ │ │ ├── maketables.go │ │ │ └── tables.go │ │ ├── traditionalchinese │ │ │ ├── big5.go │ │ │ ├── maketables.go │ │ │ └── tables.go │ │ └── unicode │ │ │ ├── override.go │ │ │ └── unicode.go │ │ ├── internal │ │ ├── tag │ │ │ └── tag.go │ │ └── utf8internal │ │ │ └── utf8internal.go │ │ ├── language │ │ ├── Makefile │ │ ├── common.go │ │ ├── coverage.go │ │ ├── gen_common.go │ │ ├── gen_index.go │ │ ├── go1_1.go │ │ ├── go1_2.go │ │ ├── index.go │ │ ├── language.go │ │ ├── lookup.go │ │ ├── maketables.go │ │ ├── match.go │ │ ├── parse.go │ │ ├── tables.go │ │ └── tags.go │ │ ├── runes │ │ ├── cond.go │ │ └── runes.go │ │ └── transform │ │ └── transform.go └── main.go ├── peers └── main.go └── server └── main.go /.gitignore: -------------------------------------------------------------------------------- 1 | peers/.nfs* 2 | peers/peers 3 | server/server 4 | upnpdemo/upnpdemo 5 | /myp2p/myp2p 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [udp打洞原理](http://qjpcpu.github.io/blog/2018/01/26/p2pzhi-udpda-dong/) 2 | -------------------------------------------------------------------------------- /myp2p/Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/.gitignore: -------------------------------------------------------------------------------- 1 | /pkg 2 | /bin 3 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package common 18 | 19 | import "math/big" 20 | 21 | // Common big integers often used 22 | var ( 23 | Big1 = big.NewInt(1) 24 | Big2 = big.NewInt(2) 25 | Big3 = big.NewInt(3) 26 | Big0 = big.NewInt(0) 27 | Big32 = big.NewInt(32) 28 | Big256 = big.NewInt(0xff) 29 | Big257 = big.NewInt(257) 30 | ) 31 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/bitutil/compress_fuzz.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | // +build gofuzz 18 | 19 | package bitutil 20 | 21 | import "bytes" 22 | 23 | // Fuzz implements a go-fuzz fuzzer method to test various encoding method 24 | // invocations. 25 | func Fuzz(data []byte) int { 26 | if len(data) == 0 { 27 | return -1 28 | } 29 | if data[0]%2 == 0 { 30 | return fuzzEncode(data[1:]) 31 | } 32 | return fuzzDecode(data[1:]) 33 | } 34 | 35 | // fuzzEncode implements a go-fuzz fuzzer method to test the bitset encoding and 36 | // decoding algorithm. 37 | func fuzzEncode(data []byte) int { 38 | proc, _ := bitsetDecodeBytes(bitsetEncodeBytes(data), len(data)) 39 | if !bytes.Equal(data, proc) { 40 | panic("content mismatch") 41 | } 42 | return 0 43 | } 44 | 45 | // fuzzDecode implements a go-fuzz fuzzer method to test the bit decoding and 46 | // reencoding algorithm. 47 | func fuzzDecode(data []byte) int { 48 | blob, err := bitsetDecodeBytes(data, 1024) 49 | if err != nil { 50 | return 0 51 | } 52 | if comp := bitsetEncodeBytes(blob); !bytes.Equal(comp, data) { 53 | panic("content mismatch") 54 | } 55 | return 0 56 | } 57 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/compiler/solidity_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package compiler 18 | 19 | import ( 20 | "os/exec" 21 | "testing" 22 | ) 23 | 24 | const ( 25 | testSource = ` 26 | contract test { 27 | /// @notice Will multiply ` + "`a`" + ` by 7. 28 | function multiply(uint a) returns(uint d) { 29 | return a * 7; 30 | } 31 | } 32 | ` 33 | ) 34 | 35 | func skipWithoutSolc(t *testing.T) { 36 | if _, err := exec.LookPath("solc"); err != nil { 37 | t.Skip(err) 38 | } 39 | } 40 | 41 | func TestCompiler(t *testing.T) { 42 | skipWithoutSolc(t) 43 | 44 | contracts, err := CompileSolidityString("", testSource) 45 | if err != nil { 46 | t.Fatalf("error compiling source. result %v: %v", contracts, err) 47 | } 48 | if len(contracts) != 1 { 49 | t.Errorf("one contract expected, got %d", len(contracts)) 50 | } 51 | c, ok := contracts["test"] 52 | if !ok { 53 | c, ok = contracts[":test"] 54 | if !ok { 55 | t.Fatal("info for contract 'test' not present in result") 56 | } 57 | } 58 | if c.Code == "" { 59 | t.Error("empty code") 60 | } 61 | if c.Info.Source != testSource { 62 | t.Error("wrong source") 63 | } 64 | if c.Info.CompilerVersion == "" { 65 | t.Error("empty version") 66 | } 67 | } 68 | 69 | func TestCompileError(t *testing.T) { 70 | skipWithoutSolc(t) 71 | 72 | contracts, err := CompileSolidityString("", testSource[4:]) 73 | if err == nil { 74 | t.Errorf("error expected compiling source. got none. result %v", contracts) 75 | } 76 | t.Logf("error: %v", err) 77 | } 78 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package common 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | "runtime" 23 | "runtime/debug" 24 | "strings" 25 | ) 26 | 27 | // Report gives off a warning requesting the user to submit an issue to the github tracker. 28 | func Report(extra ...interface{}) { 29 | fmt.Fprintln(os.Stderr, "You've encountered a sought after, hard to reproduce bug. Please report this to the developers <3 https://github.com/ethereum/go-ethereum/issues") 30 | fmt.Fprintln(os.Stderr, extra...) 31 | 32 | _, file, line, _ := runtime.Caller(1) 33 | fmt.Fprintf(os.Stderr, "%v:%v\n", file, line) 34 | 35 | debug.PrintStack() 36 | 37 | fmt.Fprintln(os.Stderr, "#### BUG! PLEASE REPORT ####") 38 | } 39 | 40 | // PrintDepricationWarning prinst the given string in a box using fmt.Println. 41 | func PrintDepricationWarning(str string) { 42 | line := strings.Repeat("#", len(str)+4) 43 | emptyLine := strings.Repeat(" ", len(str)) 44 | fmt.Printf(` 45 | %s 46 | # %s # 47 | # %s # 48 | # %s # 49 | %s 50 | 51 | `, line, emptyLine, str, emptyLine, line) 52 | } 53 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/fdlimit/fdlimit_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of go-ethereum. 3 | // 4 | // go-ethereum is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // go-ethereum is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with go-ethereum. If not, see . 16 | 17 | // +build freebsd 18 | 19 | package fdlimit 20 | 21 | import "syscall" 22 | 23 | // This file is largely identical to fdlimit_unix.go, 24 | // but Rlimit fields have type int64 on FreeBSD so it needs 25 | // an extra conversion. 26 | 27 | // Raise tries to maximize the file descriptor allowance of this process 28 | // to the maximum hard-limit allowed by the OS. 29 | func Raise(max uint64) error { 30 | // Get the current limit 31 | var limit syscall.Rlimit 32 | if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { 33 | return err 34 | } 35 | // Try to update the limit to the max allowance 36 | limit.Cur = limit.Max 37 | if limit.Cur > int64(max) { 38 | limit.Cur = int64(max) 39 | } 40 | if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { 41 | return err 42 | } 43 | return nil 44 | } 45 | 46 | // Current retrieves the number of file descriptors allowed to be opened by this 47 | // process. 48 | func Current() (int, error) { 49 | var limit syscall.Rlimit 50 | if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { 51 | return 0, err 52 | } 53 | return int(limit.Cur), nil 54 | } 55 | 56 | // Maximum retrieves the maximum number of file descriptors this process is 57 | // allowed to request for itself. 58 | func Maximum() (int, error) { 59 | var limit syscall.Rlimit 60 | if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { 61 | return 0, err 62 | } 63 | return int(limit.Max), nil 64 | } 65 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/fdlimit/fdlimit_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of go-ethereum. 3 | // 4 | // go-ethereum is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // go-ethereum is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with go-ethereum. If not, see . 16 | 17 | package fdlimit 18 | 19 | import ( 20 | "fmt" 21 | "testing" 22 | ) 23 | 24 | // TestFileDescriptorLimits simply tests whether the file descriptor allowance 25 | // per this process can be retrieved. 26 | func TestFileDescriptorLimits(t *testing.T) { 27 | target := 4096 28 | hardlimit, err := Maximum() 29 | if err != nil { 30 | t.Fatal(err) 31 | } 32 | if hardlimit < target { 33 | t.Skip(fmt.Sprintf("system limit is less than desired test target: %d < %d", hardlimit, target)) 34 | } 35 | 36 | if limit, err := Current(); err != nil || limit <= 0 { 37 | t.Fatalf("failed to retrieve file descriptor limit (%d): %v", limit, err) 38 | } 39 | if err := Raise(uint64(target)); err != nil { 40 | t.Fatalf("failed to raise file allowance") 41 | } 42 | if limit, err := Current(); err != nil || limit < target { 43 | t.Fatalf("failed to retrieve raised descriptor limit (have %v, want %v): %v", limit, target, err) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/fdlimit/fdlimit_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of go-ethereum. 3 | // 4 | // go-ethereum is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // go-ethereum is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with go-ethereum. If not, see . 16 | 17 | // +build linux darwin netbsd openbsd solaris 18 | 19 | package fdlimit 20 | 21 | import "syscall" 22 | 23 | // Raise tries to maximize the file descriptor allowance of this process 24 | // to the maximum hard-limit allowed by the OS. 25 | func Raise(max uint64) error { 26 | // Get the current limit 27 | var limit syscall.Rlimit 28 | if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { 29 | return err 30 | } 31 | // Try to update the limit to the max allowance 32 | limit.Cur = limit.Max 33 | if limit.Cur > max { 34 | limit.Cur = max 35 | } 36 | if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { 37 | return err 38 | } 39 | return nil 40 | } 41 | 42 | // Current retrieves the number of file descriptors allowed to be opened by this 43 | // process. 44 | func Current() (int, error) { 45 | var limit syscall.Rlimit 46 | if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { 47 | return 0, err 48 | } 49 | return int(limit.Cur), nil 50 | } 51 | 52 | // Maximum retrieves the maximum number of file descriptors this process is 53 | // allowed to request for itself. 54 | func Maximum() (int, error) { 55 | var limit syscall.Rlimit 56 | if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { 57 | return 0, err 58 | } 59 | return int(limit.Max), nil 60 | } 61 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/fdlimit/fdlimit_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of go-ethereum. 3 | // 4 | // go-ethereum is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // go-ethereum is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with go-ethereum. If not, see . 16 | 17 | package fdlimit 18 | 19 | import "errors" 20 | 21 | // Raise tries to maximize the file descriptor allowance of this process 22 | // to the maximum hard-limit allowed by the OS. 23 | func Raise(max uint64) error { 24 | // This method is NOP by design: 25 | // * Linux/Darwin counterparts need to manually increase per process limits 26 | // * On Windows Go uses the CreateFile API, which is limited to 16K files, non 27 | // changeable from within a running process 28 | // This way we can always "request" raising the limits, which will either have 29 | // or not have effect based on the platform we're running on. 30 | if max > 16384 { 31 | return errors.New("file descriptor limit (16384) reached") 32 | } 33 | return nil 34 | } 35 | 36 | // Current retrieves the number of file descriptors allowed to be opened by this 37 | // process. 38 | func Current() (int, error) { 39 | // Please see Raise for the reason why we use hard coded 16K as the limit 40 | return 16384, nil 41 | } 42 | 43 | // Maximum retrieves the maximum number of file descriptors this process is 44 | // allowed to request for itself. 45 | func Maximum() (int, error) { 46 | return Current() 47 | } 48 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/format.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package common 18 | 19 | import ( 20 | "fmt" 21 | "regexp" 22 | "strings" 23 | "time" 24 | ) 25 | 26 | // PrettyDuration is a pretty printed version of a time.Duration value that cuts 27 | // the unnecessary precision off from the formatted textual representation. 28 | type PrettyDuration time.Duration 29 | 30 | var prettyDurationRe = regexp.MustCompile(`\.[0-9]+`) 31 | 32 | // String implements the Stringer interface, allowing pretty printing of duration 33 | // values rounded to three decimals. 34 | func (d PrettyDuration) String() string { 35 | label := fmt.Sprintf("%v", time.Duration(d)) 36 | if match := prettyDurationRe.FindString(label); len(match) > 4 { 37 | label = strings.Replace(label, match, match[:4], 1) 38 | } 39 | return label 40 | } 41 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/hexutil/json_example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package hexutil_test 18 | 19 | import ( 20 | "encoding/json" 21 | "fmt" 22 | 23 | "github.com/ethereum/go-ethereum/common/hexutil" 24 | ) 25 | 26 | type MyType [5]byte 27 | 28 | func (v *MyType) UnmarshalText(input []byte) error { 29 | return hexutil.UnmarshalFixedText("MyType", input, v[:]) 30 | } 31 | 32 | func (v MyType) String() string { 33 | return hexutil.Bytes(v[:]).String() 34 | } 35 | 36 | func ExampleUnmarshalFixedText() { 37 | var v1, v2 MyType 38 | fmt.Println("v1 error:", json.Unmarshal([]byte(`"0x01"`), &v1)) 39 | fmt.Println("v2 error:", json.Unmarshal([]byte(`"0x0101010101"`), &v2)) 40 | fmt.Println("v2:", v2) 41 | // Output: 42 | // v1 error: hex string has length 2, want 10 for MyType 43 | // v2 error: 44 | // v2: 0x0101010101 45 | } 46 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package common 18 | 19 | import ( 20 | "testing" 21 | 22 | checker "gopkg.in/check.v1" 23 | ) 24 | 25 | func Test(t *testing.T) { checker.TestingT(t) } 26 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/mclock/mclock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | // package mclock is a wrapper for a monotonic clock source 18 | package mclock 19 | 20 | import ( 21 | "time" 22 | 23 | "github.com/aristanetworks/goarista/monotime" 24 | ) 25 | 26 | type AbsTime time.Duration // absolute monotonic time 27 | 28 | func Now() AbsTime { 29 | return AbsTime(monotime.Now()) 30 | } 31 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/path.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package common 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | "path/filepath" 23 | "runtime" 24 | ) 25 | 26 | // MakeName creates a node name that follows the ethereum convention 27 | // for such names. It adds the operation system name and Go runtime version 28 | // the name. 29 | func MakeName(name, version string) string { 30 | return fmt.Sprintf("%s/v%s/%s/%s", name, version, runtime.GOOS, runtime.Version()) 31 | } 32 | 33 | func FileExist(filePath string) bool { 34 | _, err := os.Stat(filePath) 35 | if err != nil && os.IsNotExist(err) { 36 | return false 37 | } 38 | 39 | return true 40 | } 41 | 42 | func AbsolutePath(Datadir string, filename string) string { 43 | if filepath.IsAbs(filename) { 44 | return filename 45 | } 46 | return filepath.Join(Datadir, filename) 47 | } 48 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/size.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package common 18 | 19 | import ( 20 | "fmt" 21 | ) 22 | 23 | type StorageSize float64 24 | 25 | func (self StorageSize) String() string { 26 | if self > 1000000 { 27 | return fmt.Sprintf("%.2f mB", self/1000000) 28 | } else if self > 1000 { 29 | return fmt.Sprintf("%.2f kB", self/1000) 30 | } else { 31 | return fmt.Sprintf("%.2f B", self) 32 | } 33 | } 34 | 35 | func (self StorageSize) Int64() int64 { 36 | return int64(self) 37 | } 38 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/size_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package common 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func TestStorageSizeString(t *testing.T) { 24 | tests := []struct { 25 | size StorageSize 26 | str string 27 | }{ 28 | {2381273, "2.38 mB"}, 29 | {2192, "2.19 kB"}, 30 | {12, "12.00 B"}, 31 | } 32 | 33 | for _, test := range tests { 34 | if test.size.String() != test.str { 35 | t.Errorf("%f: got %q, want %q", float64(test.size), test.size.String(), test.str) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/test_utils.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package common 18 | 19 | import ( 20 | "encoding/json" 21 | "fmt" 22 | "io/ioutil" 23 | ) 24 | 25 | // LoadJSON reads the given file and unmarshals its content. 26 | func LoadJSON(file string, val interface{}) error { 27 | content, err := ioutil.ReadFile(file) 28 | if err != nil { 29 | return err 30 | } 31 | if err := json.Unmarshal(content, val); err != nil { 32 | if syntaxerr, ok := err.(*json.SyntaxError); ok { 33 | line := findLine(content, syntaxerr.Offset) 34 | return fmt.Errorf("JSON syntax error at %v:%v: %v", file, line, err) 35 | } 36 | return fmt.Errorf("JSON unmarshal error in %v: %v", file, err) 37 | } 38 | return nil 39 | } 40 | 41 | // findLine returns the line number for the given offset into data. 42 | func findLine(data []byte, offset int64) (line int) { 43 | line = 1 44 | for i, r := range string(data) { 45 | if int64(i) >= offset { 46 | return 47 | } 48 | if r == '\n' { 49 | line++ 50 | } 51 | } 52 | return 53 | } 54 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/common/types_template.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | // +build none 18 | //sed -e 's/_N_/Hash/g' -e 's/_S_/32/g' -e '1d' types_template.go | gofmt -w hash.go 19 | 20 | package common 21 | 22 | import "math/big" 23 | 24 | type _N_ [_S_]byte 25 | 26 | func BytesTo_N_(b []byte) _N_ { 27 | var h _N_ 28 | h.SetBytes(b) 29 | return h 30 | } 31 | func StringTo_N_(s string) _N_ { return BytesTo_N_([]byte(s)) } 32 | func BigTo_N_(b *big.Int) _N_ { return BytesTo_N_(b.Bytes()) } 33 | func HexTo_N_(s string) _N_ { return BytesTo_N_(FromHex(s)) } 34 | 35 | // Don't use the default 'String' method in case we want to overwrite 36 | 37 | // Get the string representation of the underlying hash 38 | func (h _N_) Str() string { return string(h[:]) } 39 | func (h _N_) Bytes() []byte { return h[:] } 40 | func (h _N_) Big() *big.Int { return new(big.Int).SetBytes(h[:]) } 41 | func (h _N_) Hex() string { return "0x" + Bytes2Hex(h[:]) } 42 | 43 | // Sets the hash to the value of b. If b is larger than len(h) it will panic 44 | func (h *_N_) SetBytes(b []byte) { 45 | // Use the right most bytes 46 | if len(b) > len(h) { 47 | b = b[len(b)-_S_:] 48 | } 49 | 50 | // Reverse the loop 51 | for i := len(b) - 1; i >= 0; i-- { 52 | h[_S_-len(b)+i] = b[i] 53 | } 54 | } 55 | 56 | // Set string `s` to h. If s is larger than len(h) it will panic 57 | func (h *_N_) SetString(s string) { h.SetBytes([]byte(s)) } 58 | 59 | // Sets h to other 60 | func (h *_N_) Set(other _N_) { 61 | for i, v := range other { 62 | h[i] = v 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/bn256/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package bn256 6 | 7 | import ( 8 | "math/big" 9 | ) 10 | 11 | func bigFromBase10(s string) *big.Int { 12 | n, _ := new(big.Int).SetString(s, 10) 13 | return n 14 | } 15 | 16 | // u is the BN parameter that determines the prime: 1868033³. 17 | var u = bigFromBase10("4965661367192848881") 18 | 19 | // p is a prime over which we form a basic field: 36u⁴+36u³+24u²+6u+1. 20 | var P = bigFromBase10("21888242871839275222246405745257275088696311157297823662689037894645226208583") 21 | 22 | // Order is the number of elements in both G₁ and G₂: 36u⁴+36u³+18u²+6u+1. 23 | var Order = bigFromBase10("21888242871839275222246405745257275088548364400416034343698204186575808495617") 24 | 25 | // xiToPMinus1Over6 is ξ^((p-1)/6) where ξ = i+9. 26 | var xiToPMinus1Over6 = &gfP2{bigFromBase10("16469823323077808223889137241176536799009286646108169935659301613961712198316"), bigFromBase10("8376118865763821496583973867626364092589906065868298776909617916018768340080")} 27 | 28 | // xiToPMinus1Over3 is ξ^((p-1)/3) where ξ = i+9. 29 | var xiToPMinus1Over3 = &gfP2{bigFromBase10("10307601595873709700152284273816112264069230130616436755625194854815875713954"), bigFromBase10("21575463638280843010398324269430826099269044274347216827212613867836435027261")} 30 | 31 | // xiToPMinus1Over2 is ξ^((p-1)/2) where ξ = i+9. 32 | var xiToPMinus1Over2 = &gfP2{bigFromBase10("3505843767911556378687030309984248845540243509899259641013678093033130930403"), bigFromBase10("2821565182194536844548159561693502659359617185244120367078079554186484126554")} 33 | 34 | // xiToPSquaredMinus1Over3 is ξ^((p²-1)/3) where ξ = i+9. 35 | var xiToPSquaredMinus1Over3 = bigFromBase10("21888242871839275220042445260109153167277707414472061641714758635765020556616") 36 | 37 | // xiTo2PSquaredMinus2Over3 is ξ^((2p²-2)/3) where ξ = i+9 (a cubic root of unity, mod p). 38 | var xiTo2PSquaredMinus2Over3 = bigFromBase10("2203960485148121921418603742825762020974279258880205651966") 39 | 40 | // xiToPSquaredMinus1Over6 is ξ^((1p²-1)/6) where ξ = i+9 (a cubic root of -1, mod p). 41 | var xiToPSquaredMinus1Over6 = bigFromBase10("21888242871839275220042445260109153167277707414472061641714758635765020556617") 42 | 43 | // xiTo2PMinus2Over3 is ξ^((2p-2)/3) where ξ = i+9. 44 | var xiTo2PMinus2Over3 = &gfP2{bigFromBase10("19937756971775647987995932169929341994314640652964949448313374472400716661030"), bigFromBase10("2581911344467009335267311115468803099551665605076196740867805258568234346338")} 45 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/bn256/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package bn256 6 | 7 | import ( 8 | "crypto/rand" 9 | ) 10 | 11 | func ExamplePair() { 12 | // This implements the tripartite Diffie-Hellman algorithm from "A One 13 | // Round Protocol for Tripartite Diffie-Hellman", A. Joux. 14 | // http://www.springerlink.com/content/cddc57yyva0hburb/fulltext.pdf 15 | 16 | // Each of three parties, a, b and c, generate a private value. 17 | a, _ := rand.Int(rand.Reader, Order) 18 | b, _ := rand.Int(rand.Reader, Order) 19 | c, _ := rand.Int(rand.Reader, Order) 20 | 21 | // Then each party calculates g₁ and g₂ times their private value. 22 | pa := new(G1).ScalarBaseMult(a) 23 | qa := new(G2).ScalarBaseMult(a) 24 | 25 | pb := new(G1).ScalarBaseMult(b) 26 | qb := new(G2).ScalarBaseMult(b) 27 | 28 | pc := new(G1).ScalarBaseMult(c) 29 | qc := new(G2).ScalarBaseMult(c) 30 | 31 | // Now each party exchanges its public values with the other two and 32 | // all parties can calculate the shared key. 33 | k1 := Pair(pb, qc) 34 | k1.ScalarMult(k1, a) 35 | 36 | k2 := Pair(pc, qa) 37 | k2.ScalarMult(k2, b) 38 | 39 | k3 := Pair(pa, qb) 40 | k3.ScalarMult(k3, c) 41 | 42 | // k1, k2 and k3 will all be equal. 43 | } 44 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/bn256/main_test.go: -------------------------------------------------------------------------------- 1 | package bn256 2 | 3 | import ( 4 | "testing" 5 | 6 | "crypto/rand" 7 | ) 8 | 9 | func TestRandomG2Marshal(t *testing.T) { 10 | for i := 0; i < 10; i++ { 11 | n, g2, err := RandomG2(rand.Reader) 12 | if err != nil { 13 | t.Error(err) 14 | continue 15 | } 16 | t.Logf("%d: %x\n", n, g2.Marshal()) 17 | } 18 | } 19 | 20 | func TestPairings(t *testing.T) { 21 | a1 := new(G1).ScalarBaseMult(bigFromBase10("1")) 22 | a2 := new(G1).ScalarBaseMult(bigFromBase10("2")) 23 | a37 := new(G1).ScalarBaseMult(bigFromBase10("37")) 24 | an1 := new(G1).ScalarBaseMult(bigFromBase10("21888242871839275222246405745257275088548364400416034343698204186575808495616")) 25 | 26 | b0 := new(G2).ScalarBaseMult(bigFromBase10("0")) 27 | b1 := new(G2).ScalarBaseMult(bigFromBase10("1")) 28 | b2 := new(G2).ScalarBaseMult(bigFromBase10("2")) 29 | b27 := new(G2).ScalarBaseMult(bigFromBase10("27")) 30 | b999 := new(G2).ScalarBaseMult(bigFromBase10("999")) 31 | bn1 := new(G2).ScalarBaseMult(bigFromBase10("21888242871839275222246405745257275088548364400416034343698204186575808495616")) 32 | 33 | p1 := Pair(a1, b1) 34 | pn1 := Pair(a1, bn1) 35 | np1 := Pair(an1, b1) 36 | if pn1.String() != np1.String() { 37 | t.Error("Pairing mismatch: e(a, -b) != e(-a, b)") 38 | } 39 | if !PairingCheck([]*G1{a1, an1}, []*G2{b1, b1}) { 40 | t.Error("MultiAte check gave false negative!") 41 | } 42 | p0 := new(GT).Add(p1, pn1) 43 | p0_2 := Pair(a1, b0) 44 | if p0.String() != p0_2.String() { 45 | t.Error("Pairing mismatch: e(a, b) * e(a, -b) != 1") 46 | } 47 | p0_3 := new(GT).ScalarMult(p1, bigFromBase10("21888242871839275222246405745257275088548364400416034343698204186575808495617")) 48 | if p0.String() != p0_3.String() { 49 | t.Error("Pairing mismatch: e(a, b) has wrong order") 50 | } 51 | p2 := Pair(a2, b1) 52 | p2_2 := Pair(a1, b2) 53 | p2_3 := new(GT).ScalarMult(p1, bigFromBase10("2")) 54 | if p2.String() != p2_2.String() { 55 | t.Error("Pairing mismatch: e(a, b * 2) != e(a * 2, b)") 56 | } 57 | if p2.String() != p2_3.String() { 58 | t.Error("Pairing mismatch: e(a, b * 2) != e(a, b) ** 2") 59 | } 60 | if p2.String() == p1.String() { 61 | t.Error("Pairing is degenerate!") 62 | } 63 | if PairingCheck([]*G1{a1, a1}, []*G2{b1, b1}) { 64 | t.Error("MultiAte check gave false positive!") 65 | } 66 | p999 := Pair(a37, b27) 67 | p999_2 := Pair(a1, b999) 68 | if p999.String() != p999_2.String() { 69 | t.Error("Pairing mismatch: e(a * 37, b * 27) != e(a, b * 999)") 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/ecies/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | 24 | *~ 25 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/ecies/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Kyle Isom 2 | Copyright (c) 2012 The Go Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/randentropy/rand_entropy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package randentropy 18 | 19 | import ( 20 | crand "crypto/rand" 21 | "io" 22 | ) 23 | 24 | var Reader io.Reader = &randEntropy{} 25 | 26 | type randEntropy struct { 27 | } 28 | 29 | func (*randEntropy) Read(bytes []byte) (n int, err error) { 30 | readBytes := GetEntropyCSPRNG(len(bytes)) 31 | copy(bytes, readBytes) 32 | return len(bytes), nil 33 | } 34 | 35 | func GetEntropyCSPRNG(n int) []byte { 36 | mainBuff := make([]byte, n) 37 | _, err := io.ReadFull(crand.Reader, mainBuff) 38 | if err != nil { 39 | panic("reading from crypto/rand failed: " + err.Error()) 40 | } 41 | return mainBuff 42 | } 43 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | 24 | *~ 25 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/.gitignore: -------------------------------------------------------------------------------- 1 | bench_inv 2 | bench_ecdh 3 | bench_sign 4 | bench_verify 5 | bench_schnorr_verify 6 | bench_recover 7 | bench_internal 8 | tests 9 | exhaustive_tests 10 | gen_context 11 | *.exe 12 | *.so 13 | *.a 14 | !.gitignore 15 | 16 | Makefile 17 | configure 18 | .libs/ 19 | Makefile.in 20 | aclocal.m4 21 | autom4te.cache/ 22 | config.log 23 | config.status 24 | *.tar.gz 25 | *.la 26 | libtool 27 | .deps/ 28 | .dirstamp 29 | *.lo 30 | *.o 31 | *~ 32 | src/libsecp256k1-config.h 33 | src/libsecp256k1-config.h.in 34 | src/ecmult_static_context.h 35 | build-aux/config.guess 36 | build-aux/config.sub 37 | build-aux/depcomp 38 | build-aux/install-sh 39 | build-aux/ltmain.sh 40 | build-aux/m4/libtool.m4 41 | build-aux/m4/lt~obsolete.m4 42 | build-aux/m4/ltoptions.m4 43 | build-aux/m4/ltsugar.m4 44 | build-aux/m4/ltversion.m4 45 | build-aux/missing 46 | build-aux/compile 47 | build-aux/test-driver 48 | src/stamp-h1 49 | libsecp256k1.pc 50 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Pieter Wuille 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/TODO: -------------------------------------------------------------------------------- 1 | * Unit tests for fieldelem/groupelem, including ones intended to 2 | trigger fieldelem's boundary cases. 3 | * Complete constant-time operations for signing/keygen 4 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | autoreconf -if --warnings=all 4 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/secp256k1_ecdh.h: -------------------------------------------------------------------------------- 1 | #ifndef _SECP256K1_ECDH_ 2 | # define _SECP256K1_ECDH_ 3 | 4 | # include "secp256k1.h" 5 | 6 | # ifdef __cplusplus 7 | extern "C" { 8 | # endif 9 | 10 | /** Compute an EC Diffie-Hellman secret in constant time 11 | * Returns: 1: exponentiation was successful 12 | * 0: scalar was invalid (zero or overflow) 13 | * Args: ctx: pointer to a context object (cannot be NULL) 14 | * Out: result: a 32-byte array which will be populated by an ECDH 15 | * secret computed from the point and scalar 16 | * In: pubkey: a pointer to a secp256k1_pubkey containing an 17 | * initialized public key 18 | * privkey: a 32-byte scalar with which to multiply the point 19 | */ 20 | SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdh( 21 | const secp256k1_context* ctx, 22 | unsigned char *result, 23 | const secp256k1_pubkey *pubkey, 24 | const unsigned char *privkey 25 | ) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); 26 | 27 | # ifdef __cplusplus 28 | } 29 | # endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/libsecp256k1.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libsecp256k1 7 | Description: Optimized C library for EC operations on curve secp256k1 8 | URL: https://github.com/bitcoin-core/secp256k1 9 | Version: @PACKAGE_VERSION@ 10 | Cflags: -I${includedir} 11 | Libs.private: @SECP_LIBS@ 12 | Libs: -L${libdir} -lsecp256k1 13 | 14 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/obj/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjpcpu/p2pbyudp/b332348a0b01f796319d326b3e2eb401b6cdeb06/myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/obj/.gitignore -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/basic-config.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_BASIC_CONFIG_ 8 | #define _SECP256K1_BASIC_CONFIG_ 9 | 10 | #ifdef USE_BASIC_CONFIG 11 | 12 | #undef USE_ASM_X86_64 13 | #undef USE_ENDOMORPHISM 14 | #undef USE_FIELD_10X26 15 | #undef USE_FIELD_5X52 16 | #undef USE_FIELD_INV_BUILTIN 17 | #undef USE_FIELD_INV_NUM 18 | #undef USE_NUM_GMP 19 | #undef USE_NUM_NONE 20 | #undef USE_SCALAR_4X64 21 | #undef USE_SCALAR_8X32 22 | #undef USE_SCALAR_INV_BUILTIN 23 | #undef USE_SCALAR_INV_NUM 24 | 25 | #define USE_NUM_NONE 1 26 | #define USE_FIELD_INV_BUILTIN 1 27 | #define USE_SCALAR_INV_BUILTIN 1 28 | #define USE_FIELD_10X26 1 29 | #define USE_SCALAR_8X32 1 30 | 31 | #endif // USE_BASIC_CONFIG 32 | #endif // _SECP256K1_BASIC_CONFIG_ 33 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_BENCH_H_ 8 | #define _SECP256K1_BENCH_H_ 9 | 10 | #include 11 | #include 12 | #include "sys/time.h" 13 | 14 | static double gettimedouble(void) { 15 | struct timeval tv; 16 | gettimeofday(&tv, NULL); 17 | return tv.tv_usec * 0.000001 + tv.tv_sec; 18 | } 19 | 20 | void print_number(double x) { 21 | double y = x; 22 | int c = 0; 23 | if (y < 0.0) { 24 | y = -y; 25 | } 26 | while (y < 100.0) { 27 | y *= 10.0; 28 | c++; 29 | } 30 | printf("%.*f", c, x); 31 | } 32 | 33 | void run_benchmark(char *name, void (*benchmark)(void*), void (*setup)(void*), void (*teardown)(void*), void* data, int count, int iter) { 34 | int i; 35 | double min = HUGE_VAL; 36 | double sum = 0.0; 37 | double max = 0.0; 38 | for (i = 0; i < count; i++) { 39 | double begin, total; 40 | if (setup != NULL) { 41 | setup(data); 42 | } 43 | begin = gettimedouble(); 44 | benchmark(data); 45 | total = gettimedouble() - begin; 46 | if (teardown != NULL) { 47 | teardown(data); 48 | } 49 | if (total < min) { 50 | min = total; 51 | } 52 | if (total > max) { 53 | max = total; 54 | } 55 | sum += total; 56 | } 57 | printf("%s: min ", name); 58 | print_number(min * 1000000.0 / iter); 59 | printf("us / avg "); 60 | print_number((sum / count) * 1000000.0 / iter); 61 | printf("us / max "); 62 | print_number(max * 1000000.0 / iter); 63 | printf("us\n"); 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_ecdh.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #include 8 | 9 | #include "include/secp256k1.h" 10 | #include "include/secp256k1_ecdh.h" 11 | #include "util.h" 12 | #include "bench.h" 13 | 14 | typedef struct { 15 | secp256k1_context *ctx; 16 | secp256k1_pubkey point; 17 | unsigned char scalar[32]; 18 | } bench_ecdh_t; 19 | 20 | static void bench_ecdh_setup(void* arg) { 21 | int i; 22 | bench_ecdh_t *data = (bench_ecdh_t*)arg; 23 | const unsigned char point[] = { 24 | 0x03, 25 | 0x54, 0x94, 0xc1, 0x5d, 0x32, 0x09, 0x97, 0x06, 26 | 0xc2, 0x39, 0x5f, 0x94, 0x34, 0x87, 0x45, 0xfd, 27 | 0x75, 0x7c, 0xe3, 0x0e, 0x4e, 0x8c, 0x90, 0xfb, 28 | 0xa2, 0xba, 0xd1, 0x84, 0xf8, 0x83, 0xc6, 0x9f 29 | }; 30 | 31 | /* create a context with no capabilities */ 32 | data->ctx = secp256k1_context_create(SECP256K1_FLAGS_TYPE_CONTEXT); 33 | for (i = 0; i < 32; i++) { 34 | data->scalar[i] = i + 1; 35 | } 36 | CHECK(secp256k1_ec_pubkey_parse(data->ctx, &data->point, point, sizeof(point)) == 1); 37 | } 38 | 39 | static void bench_ecdh(void* arg) { 40 | int i; 41 | unsigned char res[32]; 42 | bench_ecdh_t *data = (bench_ecdh_t*)arg; 43 | 44 | for (i = 0; i < 20000; i++) { 45 | CHECK(secp256k1_ecdh(data->ctx, res, &data->point, data->scalar) == 1); 46 | } 47 | } 48 | 49 | int main(void) { 50 | bench_ecdh_t data; 51 | 52 | run_benchmark("ecdh", bench_ecdh, bench_ecdh_setup, NULL, &data, 10, 20000); 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_recover.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014-2015 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #include "include/secp256k1.h" 8 | #include "include/secp256k1_recovery.h" 9 | #include "util.h" 10 | #include "bench.h" 11 | 12 | typedef struct { 13 | secp256k1_context *ctx; 14 | unsigned char msg[32]; 15 | unsigned char sig[64]; 16 | } bench_recover_t; 17 | 18 | void bench_recover(void* arg) { 19 | int i; 20 | bench_recover_t *data = (bench_recover_t*)arg; 21 | secp256k1_pubkey pubkey; 22 | unsigned char pubkeyc[33]; 23 | 24 | for (i = 0; i < 20000; i++) { 25 | int j; 26 | size_t pubkeylen = 33; 27 | secp256k1_ecdsa_recoverable_signature sig; 28 | CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(data->ctx, &sig, data->sig, i % 2)); 29 | CHECK(secp256k1_ecdsa_recover(data->ctx, &pubkey, &sig, data->msg)); 30 | CHECK(secp256k1_ec_pubkey_serialize(data->ctx, pubkeyc, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED)); 31 | for (j = 0; j < 32; j++) { 32 | data->sig[j + 32] = data->msg[j]; /* Move former message to S. */ 33 | data->msg[j] = data->sig[j]; /* Move former R to message. */ 34 | data->sig[j] = pubkeyc[j + 1]; /* Move recovered pubkey X coordinate to R (which must be a valid X coordinate). */ 35 | } 36 | } 37 | } 38 | 39 | void bench_recover_setup(void* arg) { 40 | int i; 41 | bench_recover_t *data = (bench_recover_t*)arg; 42 | 43 | for (i = 0; i < 32; i++) { 44 | data->msg[i] = 1 + i; 45 | } 46 | for (i = 0; i < 64; i++) { 47 | data->sig[i] = 65 + i; 48 | } 49 | } 50 | 51 | int main(void) { 52 | bench_recover_t data; 53 | 54 | data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY); 55 | 56 | run_benchmark("ecdsa_recover", bench_recover, bench_recover_setup, NULL, &data, 10, 20000); 57 | 58 | secp256k1_context_destroy(data.ctx); 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/bench_sign.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #include "include/secp256k1.h" 8 | #include "util.h" 9 | #include "bench.h" 10 | 11 | typedef struct { 12 | secp256k1_context* ctx; 13 | unsigned char msg[32]; 14 | unsigned char key[32]; 15 | } bench_sign_t; 16 | 17 | static void bench_sign_setup(void* arg) { 18 | int i; 19 | bench_sign_t *data = (bench_sign_t*)arg; 20 | 21 | for (i = 0; i < 32; i++) { 22 | data->msg[i] = i + 1; 23 | } 24 | for (i = 0; i < 32; i++) { 25 | data->key[i] = i + 65; 26 | } 27 | } 28 | 29 | static void bench_sign(void* arg) { 30 | int i; 31 | bench_sign_t *data = (bench_sign_t*)arg; 32 | 33 | unsigned char sig[74]; 34 | for (i = 0; i < 20000; i++) { 35 | size_t siglen = 74; 36 | int j; 37 | secp256k1_ecdsa_signature signature; 38 | CHECK(secp256k1_ecdsa_sign(data->ctx, &signature, data->msg, data->key, NULL, NULL)); 39 | CHECK(secp256k1_ecdsa_signature_serialize_der(data->ctx, sig, &siglen, &signature)); 40 | for (j = 0; j < 32; j++) { 41 | data->msg[j] = sig[j]; 42 | data->key[j] = sig[j + 32]; 43 | } 44 | } 45 | } 46 | 47 | int main(void) { 48 | bench_sign_t data; 49 | 50 | data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); 51 | 52 | run_benchmark("ecdsa_sign", bench_sign, bench_sign_setup, NULL, &data, 10, 20000); 53 | 54 | secp256k1_context_destroy(data.ctx); 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecdsa.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_ECDSA_ 8 | #define _SECP256K1_ECDSA_ 9 | 10 | #include 11 | 12 | #include "scalar.h" 13 | #include "group.h" 14 | #include "ecmult.h" 15 | 16 | static int secp256k1_ecdsa_sig_parse(secp256k1_scalar *r, secp256k1_scalar *s, const unsigned char *sig, size_t size); 17 | static int secp256k1_ecdsa_sig_serialize(unsigned char *sig, size_t *size, const secp256k1_scalar *r, const secp256k1_scalar *s); 18 | static int secp256k1_ecdsa_sig_verify(const secp256k1_ecmult_context *ctx, const secp256k1_scalar* r, const secp256k1_scalar* s, const secp256k1_ge *pubkey, const secp256k1_scalar *message); 19 | static int secp256k1_ecdsa_sig_sign(const secp256k1_ecmult_gen_context *ctx, secp256k1_scalar* r, secp256k1_scalar* s, const secp256k1_scalar *seckey, const secp256k1_scalar *message, const secp256k1_scalar *nonce, int *recid); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/eckey.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_ECKEY_ 8 | #define _SECP256K1_ECKEY_ 9 | 10 | #include 11 | 12 | #include "group.h" 13 | #include "scalar.h" 14 | #include "ecmult.h" 15 | #include "ecmult_gen.h" 16 | 17 | static int secp256k1_eckey_pubkey_parse(secp256k1_ge *elem, const unsigned char *pub, size_t size); 18 | static int secp256k1_eckey_pubkey_serialize(secp256k1_ge *elem, unsigned char *pub, size_t *size, int compressed); 19 | 20 | static int secp256k1_eckey_privkey_tweak_add(secp256k1_scalar *key, const secp256k1_scalar *tweak); 21 | static int secp256k1_eckey_pubkey_tweak_add(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak); 22 | static int secp256k1_eckey_privkey_tweak_mul(secp256k1_scalar *key, const secp256k1_scalar *tweak); 23 | static int secp256k1_eckey_pubkey_tweak_mul(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_ECMULT_ 8 | #define _SECP256K1_ECMULT_ 9 | 10 | #include "num.h" 11 | #include "group.h" 12 | 13 | typedef struct { 14 | /* For accelerating the computation of a*P + b*G: */ 15 | secp256k1_ge_storage (*pre_g)[]; /* odd multiples of the generator */ 16 | #ifdef USE_ENDOMORPHISM 17 | secp256k1_ge_storage (*pre_g_128)[]; /* odd multiples of 2^128*generator */ 18 | #endif 19 | } secp256k1_ecmult_context; 20 | 21 | static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx); 22 | static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, const secp256k1_callback *cb); 23 | static void secp256k1_ecmult_context_clone(secp256k1_ecmult_context *dst, 24 | const secp256k1_ecmult_context *src, const secp256k1_callback *cb); 25 | static void secp256k1_ecmult_context_clear(secp256k1_ecmult_context *ctx); 26 | static int secp256k1_ecmult_context_is_built(const secp256k1_ecmult_context *ctx); 27 | 28 | /** Double multiply: R = na*A + ng*G */ 29 | static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_const.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2015 Andrew Poelstra * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_ECMULT_CONST_ 8 | #define _SECP256K1_ECMULT_CONST_ 9 | 10 | #include "scalar.h" 11 | #include "group.h" 12 | 13 | static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/ecmult_gen.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_ECMULT_GEN_ 8 | #define _SECP256K1_ECMULT_GEN_ 9 | 10 | #include "scalar.h" 11 | #include "group.h" 12 | 13 | typedef struct { 14 | /* For accelerating the computation of a*G: 15 | * To harden against timing attacks, use the following mechanism: 16 | * * Break up the multiplicand into groups of 4 bits, called n_0, n_1, n_2, ..., n_63. 17 | * * Compute sum(n_i * 16^i * G + U_i, i=0..63), where: 18 | * * U_i = U * 2^i (for i=0..62) 19 | * * U_i = U * (1-2^63) (for i=63) 20 | * where U is a point with no known corresponding scalar. Note that sum(U_i, i=0..63) = 0. 21 | * For each i, and each of the 16 possible values of n_i, (n_i * 16^i * G + U_i) is 22 | * precomputed (call it prec(i, n_i)). The formula now becomes sum(prec(i, n_i), i=0..63). 23 | * None of the resulting prec group elements have a known scalar, and neither do any of 24 | * the intermediate sums while computing a*G. 25 | */ 26 | secp256k1_ge_storage (*prec)[64][16]; /* prec[j][i] = 16^j * i * G + U_i */ 27 | secp256k1_scalar blind; 28 | secp256k1_gej initial; 29 | } secp256k1_ecmult_gen_context; 30 | 31 | static void secp256k1_ecmult_gen_context_init(secp256k1_ecmult_gen_context* ctx); 32 | static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context* ctx, const secp256k1_callback* cb); 33 | static void secp256k1_ecmult_gen_context_clone(secp256k1_ecmult_gen_context *dst, 34 | const secp256k1_ecmult_gen_context* src, const secp256k1_callback* cb); 35 | static void secp256k1_ecmult_gen_context_clear(secp256k1_ecmult_gen_context* ctx); 36 | static int secp256k1_ecmult_gen_context_is_built(const secp256k1_ecmult_gen_context* ctx); 37 | 38 | /** Multiply with the generator: R = a*G */ 39 | static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context* ctx, secp256k1_gej *r, const secp256k1_scalar *a); 40 | 41 | static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const unsigned char *seed32); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_FIELD_REPR_ 8 | #define _SECP256K1_FIELD_REPR_ 9 | 10 | #include 11 | 12 | typedef struct { 13 | /* X = sum(i=0..9, elem[i]*2^26) mod n */ 14 | uint32_t n[10]; 15 | #ifdef VERIFY 16 | int magnitude; 17 | int normalized; 18 | #endif 19 | } secp256k1_fe; 20 | 21 | /* Unpacks a constant into a overlapping multi-limbed FE element. */ 22 | #define SECP256K1_FE_CONST_INNER(d7, d6, d5, d4, d3, d2, d1, d0) { \ 23 | (d0) & 0x3FFFFFFUL, \ 24 | (((uint32_t)d0) >> 26) | (((uint32_t)(d1) & 0xFFFFFUL) << 6), \ 25 | (((uint32_t)d1) >> 20) | (((uint32_t)(d2) & 0x3FFFUL) << 12), \ 26 | (((uint32_t)d2) >> 14) | (((uint32_t)(d3) & 0xFFUL) << 18), \ 27 | (((uint32_t)d3) >> 8) | (((uint32_t)(d4) & 0x3UL) << 24), \ 28 | (((uint32_t)d4) >> 2) & 0x3FFFFFFUL, \ 29 | (((uint32_t)d4) >> 28) | (((uint32_t)(d5) & 0x3FFFFFUL) << 4), \ 30 | (((uint32_t)d5) >> 22) | (((uint32_t)(d6) & 0xFFFFUL) << 10), \ 31 | (((uint32_t)d6) >> 16) | (((uint32_t)(d7) & 0x3FFUL) << 16), \ 32 | (((uint32_t)d7) >> 10) \ 33 | } 34 | 35 | #ifdef VERIFY 36 | #define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)), 1, 1} 37 | #else 38 | #define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0))} 39 | #endif 40 | 41 | typedef struct { 42 | uint32_t n[8]; 43 | } secp256k1_fe_storage; 44 | 45 | #define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{ (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }} 46 | #define SECP256K1_FE_STORAGE_CONST_GET(d) d.n[7], d.n[6], d.n[5], d.n[4],d.n[3], d.n[2], d.n[1], d.n[0] 47 | #endif 48 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_5x52.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_FIELD_REPR_ 8 | #define _SECP256K1_FIELD_REPR_ 9 | 10 | #include 11 | 12 | typedef struct { 13 | /* X = sum(i=0..4, elem[i]*2^52) mod n */ 14 | uint64_t n[5]; 15 | #ifdef VERIFY 16 | int magnitude; 17 | int normalized; 18 | #endif 19 | } secp256k1_fe; 20 | 21 | /* Unpacks a constant into a overlapping multi-limbed FE element. */ 22 | #define SECP256K1_FE_CONST_INNER(d7, d6, d5, d4, d3, d2, d1, d0) { \ 23 | (d0) | (((uint64_t)(d1) & 0xFFFFFUL) << 32), \ 24 | ((uint64_t)(d1) >> 20) | (((uint64_t)(d2)) << 12) | (((uint64_t)(d3) & 0xFFUL) << 44), \ 25 | ((uint64_t)(d3) >> 8) | (((uint64_t)(d4) & 0xFFFFFFFUL) << 24), \ 26 | ((uint64_t)(d4) >> 28) | (((uint64_t)(d5)) << 4) | (((uint64_t)(d6) & 0xFFFFUL) << 36), \ 27 | ((uint64_t)(d6) >> 16) | (((uint64_t)(d7)) << 16) \ 28 | } 29 | 30 | #ifdef VERIFY 31 | #define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)), 1, 1} 32 | #else 33 | #define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0))} 34 | #endif 35 | 36 | typedef struct { 37 | uint64_t n[4]; 38 | } secp256k1_fe_storage; 39 | 40 | #define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{ \ 41 | (d0) | (((uint64_t)(d1)) << 32), \ 42 | (d2) | (((uint64_t)(d3)) << 32), \ 43 | (d4) | (((uint64_t)(d5)) << 32), \ 44 | (d6) | (((uint64_t)(d7)) << 32) \ 45 | }} 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/hash.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_HASH_ 8 | #define _SECP256K1_HASH_ 9 | 10 | #include 11 | #include 12 | 13 | typedef struct { 14 | uint32_t s[8]; 15 | uint32_t buf[16]; /* In big endian */ 16 | size_t bytes; 17 | } secp256k1_sha256_t; 18 | 19 | static void secp256k1_sha256_initialize(secp256k1_sha256_t *hash); 20 | static void secp256k1_sha256_write(secp256k1_sha256_t *hash, const unsigned char *data, size_t size); 21 | static void secp256k1_sha256_finalize(secp256k1_sha256_t *hash, unsigned char *out32); 22 | 23 | typedef struct { 24 | secp256k1_sha256_t inner, outer; 25 | } secp256k1_hmac_sha256_t; 26 | 27 | static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256_t *hash, const unsigned char *key, size_t size); 28 | static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256_t *hash, const unsigned char *data, size_t size); 29 | static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256_t *hash, unsigned char *out32); 30 | 31 | typedef struct { 32 | unsigned char v[32]; 33 | unsigned char k[32]; 34 | int retry; 35 | } secp256k1_rfc6979_hmac_sha256_t; 36 | 37 | static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256_t *rng, const unsigned char *key, size_t keylen); 38 | static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256_t *rng, unsigned char *out, size_t outlen); 39 | static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256_t *rng); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org/bitcoin/NativeSecp256k1Util.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the libsecp256k1 contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.bitcoin; 18 | 19 | public class NativeSecp256k1Util{ 20 | 21 | public static void assertEquals( int val, int val2, String message ) throws AssertFailException{ 22 | if( val != val2 ) 23 | throw new AssertFailException("FAIL: " + message); 24 | } 25 | 26 | public static void assertEquals( boolean val, boolean val2, String message ) throws AssertFailException{ 27 | if( val != val2 ) 28 | throw new AssertFailException("FAIL: " + message); 29 | else 30 | System.out.println("PASS: " + message); 31 | } 32 | 33 | public static void assertEquals( String val, String val2, String message ) throws AssertFailException{ 34 | if( !val.equals(val2) ) 35 | throw new AssertFailException("FAIL: " + message); 36 | else 37 | System.out.println("PASS: " + message); 38 | } 39 | 40 | public static class AssertFailException extends Exception { 41 | public AssertFailException(String message) { 42 | super( message ); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org/bitcoin/Secp256k1Context.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the libsecp256k1 contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.bitcoin; 18 | 19 | /** 20 | * This class holds the context reference used in native methods 21 | * to handle ECDSA operations. 22 | */ 23 | public class Secp256k1Context { 24 | private static final boolean enabled; //true if the library is loaded 25 | private static final long context; //ref to pointer to context obj 26 | 27 | static { //static initializer 28 | boolean isEnabled = true; 29 | long contextRef = -1; 30 | try { 31 | System.loadLibrary("secp256k1"); 32 | contextRef = secp256k1_init_context(); 33 | } catch (UnsatisfiedLinkError e) { 34 | System.out.println("UnsatisfiedLinkError: " + e.toString()); 35 | isEnabled = false; 36 | } 37 | enabled = isEnabled; 38 | context = contextRef; 39 | } 40 | 41 | public static boolean isEnabled() { 42 | return enabled; 43 | } 44 | 45 | public static long getContext() { 46 | if(!enabled) return -1; //sanity check 47 | return context; 48 | } 49 | 50 | private static native long secp256k1_init_context(); 51 | } 52 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_Secp256k1Context.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "org_bitcoin_Secp256k1Context.h" 4 | #include "include/secp256k1.h" 5 | 6 | SECP256K1_API jlong JNICALL Java_org_bitcoin_Secp256k1Context_secp256k1_1init_1context 7 | (JNIEnv* env, jclass classObject) 8 | { 9 | secp256k1_context *ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); 10 | 11 | (void)classObject;(void)env; 12 | 13 | return (uintptr_t)ctx; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/java/org_bitcoin_Secp256k1Context.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | #include "include/secp256k1.h" 4 | /* Header for class org_bitcoin_Secp256k1Context */ 5 | 6 | #ifndef _Included_org_bitcoin_Secp256k1Context 7 | #define _Included_org_bitcoin_Secp256k1Context 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | /* 12 | * Class: org_bitcoin_Secp256k1Context 13 | * Method: secp256k1_init_context 14 | * Signature: ()J 15 | */ 16 | SECP256K1_API jlong JNICALL Java_org_bitcoin_Secp256k1Context_secp256k1_1init_1context 17 | (JNIEnv *, jclass); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | #endif 23 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/Makefile.am.include: -------------------------------------------------------------------------------- 1 | include_HEADERS += include/secp256k1_ecdh.h 2 | noinst_HEADERS += src/modules/ecdh/main_impl.h 3 | noinst_HEADERS += src/modules/ecdh/tests_impl.h 4 | if USE_BENCHMARK 5 | noinst_PROGRAMS += bench_ecdh 6 | bench_ecdh_SOURCES = src/bench_ecdh.c 7 | bench_ecdh_LDADD = libsecp256k1.la $(SECP_LIBS) $(COMMON_LIB) 8 | endif 9 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/ecdh/main_impl.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2015 Andrew Poelstra * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_MODULE_ECDH_MAIN_ 8 | #define _SECP256K1_MODULE_ECDH_MAIN_ 9 | 10 | #include "include/secp256k1_ecdh.h" 11 | #include "ecmult_const_impl.h" 12 | 13 | int secp256k1_ecdh(const secp256k1_context* ctx, unsigned char *result, const secp256k1_pubkey *point, const unsigned char *scalar) { 14 | int ret = 0; 15 | int overflow = 0; 16 | secp256k1_gej res; 17 | secp256k1_ge pt; 18 | secp256k1_scalar s; 19 | VERIFY_CHECK(ctx != NULL); 20 | ARG_CHECK(result != NULL); 21 | ARG_CHECK(point != NULL); 22 | ARG_CHECK(scalar != NULL); 23 | 24 | secp256k1_pubkey_load(ctx, &pt, point); 25 | secp256k1_scalar_set_b32(&s, scalar, &overflow); 26 | if (overflow || secp256k1_scalar_is_zero(&s)) { 27 | ret = 0; 28 | } else { 29 | unsigned char x[32]; 30 | unsigned char y[1]; 31 | secp256k1_sha256_t sha; 32 | 33 | secp256k1_ecmult_const(&res, &pt, &s); 34 | secp256k1_ge_set_gej(&pt, &res); 35 | /* Compute a hash of the point in compressed form 36 | * Note we cannot use secp256k1_eckey_pubkey_serialize here since it does not 37 | * expect its output to be secret and has a timing sidechannel. */ 38 | secp256k1_fe_normalize(&pt.x); 39 | secp256k1_fe_normalize(&pt.y); 40 | secp256k1_fe_get_b32(x, &pt.x); 41 | y[0] = 0x02 | secp256k1_fe_is_odd(&pt.y); 42 | 43 | secp256k1_sha256_initialize(&sha); 44 | secp256k1_sha256_write(&sha, y, sizeof(y)); 45 | secp256k1_sha256_write(&sha, x, sizeof(x)); 46 | secp256k1_sha256_finalize(&sha, result); 47 | ret = 1; 48 | } 49 | 50 | secp256k1_scalar_clear(&s); 51 | return ret; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/Makefile.am.include: -------------------------------------------------------------------------------- 1 | include_HEADERS += include/secp256k1_recovery.h 2 | noinst_HEADERS += src/modules/recovery/main_impl.h 3 | noinst_HEADERS += src/modules/recovery/tests_impl.h 4 | if USE_BENCHMARK 5 | noinst_PROGRAMS += bench_recover 6 | bench_recover_SOURCES = src/bench_recover.c 7 | bench_recover_LDADD = libsecp256k1.la $(SECP_LIBS) $(COMMON_LIB) 8 | endif 9 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_gmp.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_NUM_REPR_ 8 | #define _SECP256K1_NUM_REPR_ 9 | 10 | #include 11 | 12 | #define NUM_LIMBS ((256+GMP_NUMB_BITS-1)/GMP_NUMB_BITS) 13 | 14 | typedef struct { 15 | mp_limb_t data[2*NUM_LIMBS]; 16 | int neg; 17 | int limbs; 18 | } secp256k1_num; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/num_impl.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_NUM_IMPL_H_ 8 | #define _SECP256K1_NUM_IMPL_H_ 9 | 10 | #if defined HAVE_CONFIG_H 11 | #include "libsecp256k1-config.h" 12 | #endif 13 | 14 | #include "num.h" 15 | 16 | #if defined(USE_NUM_GMP) 17 | #include "num_gmp_impl.h" 18 | #elif defined(USE_NUM_NONE) 19 | /* Nothing. */ 20 | #else 21 | #error "Please select num implementation" 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_4x64.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_SCALAR_REPR_ 8 | #define _SECP256K1_SCALAR_REPR_ 9 | 10 | #include 11 | 12 | /** A scalar modulo the group order of the secp256k1 curve. */ 13 | typedef struct { 14 | uint64_t d[4]; 15 | } secp256k1_scalar; 16 | 17 | #define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{((uint64_t)(d1)) << 32 | (d0), ((uint64_t)(d3)) << 32 | (d2), ((uint64_t)(d5)) << 32 | (d4), ((uint64_t)(d7)) << 32 | (d6)}} 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_8x32.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_SCALAR_REPR_ 8 | #define _SECP256K1_SCALAR_REPR_ 9 | 10 | #include 11 | 12 | /** A scalar modulo the group order of the secp256k1 curve. */ 13 | typedef struct { 14 | uint32_t d[8]; 15 | } secp256k1_scalar; 16 | 17 | #define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{(d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)}} 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/scalar_low.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2015 Andrew Poelstra * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_SCALAR_REPR_ 8 | #define _SECP256K1_SCALAR_REPR_ 9 | 10 | #include 11 | 12 | /** A scalar modulo the group order of the secp256k1 curve. */ 13 | typedef uint32_t secp256k1_scalar; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/testrand.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef _SECP256K1_TESTRAND_H_ 8 | #define _SECP256K1_TESTRAND_H_ 9 | 10 | #if defined HAVE_CONFIG_H 11 | #include "libsecp256k1-config.h" 12 | #endif 13 | 14 | /* A non-cryptographic RNG used only for test infrastructure. */ 15 | 16 | /** Seed the pseudorandom number generator for testing. */ 17 | SECP256K1_INLINE static void secp256k1_rand_seed(const unsigned char *seed16); 18 | 19 | /** Generate a pseudorandom number in the range [0..2**32-1]. */ 20 | static uint32_t secp256k1_rand32(void); 21 | 22 | /** Generate a pseudorandom number in the range [0..2**bits-1]. Bits must be 1 or 23 | * more. */ 24 | static uint32_t secp256k1_rand_bits(int bits); 25 | 26 | /** Generate a pseudorandom number in the range [0..range-1]. */ 27 | static uint32_t secp256k1_rand_int(uint32_t range); 28 | 29 | /** Generate a pseudorandom 32-byte array. */ 30 | static void secp256k1_rand256(unsigned char *b32); 31 | 32 | /** Generate a pseudorandom 32-byte array with long sequences of zero and one bits. */ 33 | static void secp256k1_rand256_test(unsigned char *b32); 34 | 35 | /** Generate pseudorandom bytes with long sequences of zero and one bits. */ 36 | static void secp256k1_rand_bytes_test(unsigned char *bytes, size_t len); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/secp256k1/panic_cb.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package secp256k1 18 | 19 | import "C" 20 | import "unsafe" 21 | 22 | // Callbacks for converting libsecp256k1 internal faults into 23 | // recoverable Go panics. 24 | 25 | //export secp256k1GoPanicIllegal 26 | func secp256k1GoPanicIllegal(msg *C.char, data unsafe.Pointer) { 27 | panic("illegal argument: " + C.GoString(msg)) 28 | } 29 | 30 | //export secp256k1GoPanicError 31 | func secp256k1GoPanicError(msg *C.char, data unsafe.Pointer) { 32 | panic("internal error: " + C.GoString(msg)) 33 | } 34 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/sha3/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/sha3/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/sha3/hashes.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package sha3 6 | 7 | // This file provides functions for creating instances of the SHA-3 8 | // and SHAKE hash functions, as well as utility functions for hashing 9 | // bytes. 10 | 11 | import ( 12 | "hash" 13 | ) 14 | 15 | // NewKeccak256 creates a new Keccak-256 hash. 16 | func NewKeccak256() hash.Hash { return &state{rate: 136, outputLen: 32, dsbyte: 0x01} } 17 | 18 | // NewKeccak512 creates a new Keccak-512 hash. 19 | func NewKeccak512() hash.Hash { return &state{rate: 72, outputLen: 64, dsbyte: 0x01} } 20 | 21 | // New224 creates a new SHA3-224 hash. 22 | // Its generic security strength is 224 bits against preimage attacks, 23 | // and 112 bits against collision attacks. 24 | func New224() hash.Hash { return &state{rate: 144, outputLen: 28, dsbyte: 0x06} } 25 | 26 | // New256 creates a new SHA3-256 hash. 27 | // Its generic security strength is 256 bits against preimage attacks, 28 | // and 128 bits against collision attacks. 29 | func New256() hash.Hash { return &state{rate: 136, outputLen: 32, dsbyte: 0x06} } 30 | 31 | // New384 creates a new SHA3-384 hash. 32 | // Its generic security strength is 384 bits against preimage attacks, 33 | // and 192 bits against collision attacks. 34 | func New384() hash.Hash { return &state{rate: 104, outputLen: 48, dsbyte: 0x06} } 35 | 36 | // New512 creates a new SHA3-512 hash. 37 | // Its generic security strength is 512 bits against preimage attacks, 38 | // and 256 bits against collision attacks. 39 | func New512() hash.Hash { return &state{rate: 72, outputLen: 64, dsbyte: 0x06} } 40 | 41 | // Sum224 returns the SHA3-224 digest of the data. 42 | func Sum224(data []byte) (digest [28]byte) { 43 | h := New224() 44 | h.Write(data) 45 | h.Sum(digest[:0]) 46 | return 47 | } 48 | 49 | // Sum256 returns the SHA3-256 digest of the data. 50 | func Sum256(data []byte) (digest [32]byte) { 51 | h := New256() 52 | h.Write(data) 53 | h.Sum(digest[:0]) 54 | return 55 | } 56 | 57 | // Sum384 returns the SHA3-384 digest of the data. 58 | func Sum384(data []byte) (digest [48]byte) { 59 | h := New384() 60 | h.Write(data) 61 | h.Sum(digest[:0]) 62 | return 63 | } 64 | 65 | // Sum512 returns the SHA3-512 digest of the data. 66 | func Sum512(data []byte) (digest [64]byte) { 67 | h := New512() 68 | h.Write(data) 69 | h.Sum(digest[:0]) 70 | return 71 | } 72 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/sha3/keccakf_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,!appengine,!gccgo 6 | 7 | package sha3 8 | 9 | // This function is implemented in keccakf_amd64.s. 10 | 11 | //go:noescape 12 | 13 | func keccakF1600(state *[25]uint64) 14 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/sha3/register.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package sha3 8 | 9 | import ( 10 | "crypto" 11 | ) 12 | 13 | func init() { 14 | crypto.RegisterHash(crypto.SHA3_224, New224) 15 | crypto.RegisterHash(crypto.SHA3_256, New256) 16 | crypto.RegisterHash(crypto.SHA3_384, New384) 17 | crypto.RegisterHash(crypto.SHA3_512, New512) 18 | } 19 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/sha3/shake.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package sha3 6 | 7 | // This file defines the ShakeHash interface, and provides 8 | // functions for creating SHAKE instances, as well as utility 9 | // functions for hashing bytes to arbitrary-length output. 10 | 11 | import ( 12 | "io" 13 | ) 14 | 15 | // ShakeHash defines the interface to hash functions that 16 | // support arbitrary-length output. 17 | type ShakeHash interface { 18 | // Write absorbs more data into the hash's state. It panics if input is 19 | // written to it after output has been read from it. 20 | io.Writer 21 | 22 | // Read reads more output from the hash; reading affects the hash's 23 | // state. (ShakeHash.Read is thus very different from Hash.Sum) 24 | // It never returns an error. 25 | io.Reader 26 | 27 | // Clone returns a copy of the ShakeHash in its current state. 28 | Clone() ShakeHash 29 | 30 | // Reset resets the ShakeHash to its initial state. 31 | Reset() 32 | } 33 | 34 | func (d *state) Clone() ShakeHash { 35 | return d.clone() 36 | } 37 | 38 | // NewShake128 creates a new SHAKE128 variable-output-length ShakeHash. 39 | // Its generic security strength is 128 bits against all attacks if at 40 | // least 32 bytes of its output are used. 41 | func NewShake128() ShakeHash { return &state{rate: 168, dsbyte: 0x1f} } 42 | 43 | // NewShake256 creates a new SHAKE128 variable-output-length ShakeHash. 44 | // Its generic security strength is 256 bits against all attacks if 45 | // at least 64 bytes of its output are used. 46 | func NewShake256() ShakeHash { return &state{rate: 136, dsbyte: 0x1f} } 47 | 48 | // ShakeSum128 writes an arbitrary-length digest of data into hash. 49 | func ShakeSum128(hash, data []byte) { 50 | h := NewShake128() 51 | h.Write(data) 52 | h.Read(hash) 53 | } 54 | 55 | // ShakeSum256 writes an arbitrary-length digest of data into hash. 56 | func ShakeSum256(hash, data []byte) { 57 | h := NewShake256() 58 | h.Write(data) 59 | h.Read(hash) 60 | } 61 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/sha3/testdata/keccakKats.json.deflate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qjpcpu/p2pbyudp/b332348a0b01f796319d326b3e2eb401b6cdeb06/myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/sha3/testdata/keccakKats.json.deflate -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/sha3/xor.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !amd64,!386,!ppc64le appengine 6 | 7 | package sha3 8 | 9 | var ( 10 | xorIn = xorInGeneric 11 | copyOut = copyOutGeneric 12 | xorInUnaligned = xorInGeneric 13 | copyOutUnaligned = copyOutGeneric 14 | ) 15 | 16 | const xorImplementationUnaligned = "generic" 17 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/sha3/xor_generic.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package sha3 6 | 7 | import "encoding/binary" 8 | 9 | // xorInGeneric xors the bytes in buf into the state; it 10 | // makes no non-portable assumptions about memory layout 11 | // or alignment. 12 | func xorInGeneric(d *state, buf []byte) { 13 | n := len(buf) / 8 14 | 15 | for i := 0; i < n; i++ { 16 | a := binary.LittleEndian.Uint64(buf) 17 | d.a[i] ^= a 18 | buf = buf[8:] 19 | } 20 | } 21 | 22 | // copyOutGeneric copies ulint64s to a byte buffer. 23 | func copyOutGeneric(d *state, b []byte) { 24 | for i := 0; len(b) >= 8; i++ { 25 | binary.LittleEndian.PutUint64(b, d.a[i]) 26 | b = b[8:] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/crypto/sha3/xor_unaligned.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64 386 ppc64le 6 | // +build !appengine 7 | 8 | package sha3 9 | 10 | import "unsafe" 11 | 12 | func xorInUnaligned(d *state, buf []byte) { 13 | bw := (*[maxRate / 8]uint64)(unsafe.Pointer(&buf[0])) 14 | n := len(buf) 15 | if n >= 72 { 16 | d.a[0] ^= bw[0] 17 | d.a[1] ^= bw[1] 18 | d.a[2] ^= bw[2] 19 | d.a[3] ^= bw[3] 20 | d.a[4] ^= bw[4] 21 | d.a[5] ^= bw[5] 22 | d.a[6] ^= bw[6] 23 | d.a[7] ^= bw[7] 24 | d.a[8] ^= bw[8] 25 | } 26 | if n >= 104 { 27 | d.a[9] ^= bw[9] 28 | d.a[10] ^= bw[10] 29 | d.a[11] ^= bw[11] 30 | d.a[12] ^= bw[12] 31 | } 32 | if n >= 136 { 33 | d.a[13] ^= bw[13] 34 | d.a[14] ^= bw[14] 35 | d.a[15] ^= bw[15] 36 | d.a[16] ^= bw[16] 37 | } 38 | if n >= 144 { 39 | d.a[17] ^= bw[17] 40 | } 41 | if n >= 168 { 42 | d.a[18] ^= bw[18] 43 | d.a[19] ^= bw[19] 44 | d.a[20] ^= bw[20] 45 | } 46 | } 47 | 48 | func copyOutUnaligned(d *state, buf []byte) { 49 | ab := (*[maxRate]uint8)(unsafe.Pointer(&d.a[0])) 50 | copy(buf, ab[:]) 51 | } 52 | 53 | var ( 54 | xorIn = xorInUnaligned 55 | copyOut = copyOutUnaligned 56 | ) 57 | 58 | const xorImplementationUnaligned = "unaligned" 59 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/event/example_feed_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package event_test 18 | 19 | import ( 20 | "fmt" 21 | 22 | "github.com/ethereum/go-ethereum/event" 23 | ) 24 | 25 | func ExampleFeed_acknowledgedEvents() { 26 | // This example shows how the return value of Send can be used for request/reply 27 | // interaction between event consumers and producers. 28 | var feed event.Feed 29 | type ackedEvent struct { 30 | i int 31 | ack chan<- struct{} 32 | } 33 | 34 | // Consumers wait for events on the feed and acknowledge processing. 35 | done := make(chan struct{}) 36 | defer close(done) 37 | for i := 0; i < 3; i++ { 38 | ch := make(chan ackedEvent, 100) 39 | sub := feed.Subscribe(ch) 40 | go func() { 41 | defer sub.Unsubscribe() 42 | for { 43 | select { 44 | case ev := <-ch: 45 | fmt.Println(ev.i) // "process" the event 46 | ev.ack <- struct{}{} 47 | case <-done: 48 | return 49 | } 50 | } 51 | }() 52 | } 53 | 54 | // The producer sends values of type ackedEvent with increasing values of i. 55 | // It waits for all consumers to acknowledge before sending the next event. 56 | for i := 0; i < 3; i++ { 57 | acksignal := make(chan struct{}) 58 | n := feed.Send(ackedEvent{i, acksignal}) 59 | for ack := 0; ack < n; ack++ { 60 | <-acksignal 61 | } 62 | } 63 | // Output: 64 | // 0 65 | // 0 66 | // 0 67 | // 1 68 | // 1 69 | // 1 70 | // 2 71 | // 2 72 | // 2 73 | } 74 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/event/example_subscription_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package event_test 18 | 19 | import ( 20 | "fmt" 21 | 22 | "github.com/ethereum/go-ethereum/event" 23 | ) 24 | 25 | func ExampleNewSubscription() { 26 | // Create a subscription that sends 10 integers on ch. 27 | ch := make(chan int) 28 | sub := event.NewSubscription(func(quit <-chan struct{}) error { 29 | for i := 0; i < 10; i++ { 30 | select { 31 | case ch <- i: 32 | case <-quit: 33 | fmt.Println("unsubscribed") 34 | return nil 35 | } 36 | } 37 | return nil 38 | }) 39 | 40 | // This is the consumer. It reads 5 integers, then aborts the subscription. 41 | // Note that Unsubscribe waits until the producer has shut down. 42 | for i := range ch { 43 | fmt.Println(i) 44 | if i == 4 { 45 | sub.Unsubscribe() 46 | break 47 | } 48 | } 49 | // Output: 50 | // 0 51 | // 1 52 | // 2 53 | // 3 54 | // 4 55 | // unsubscribed 56 | } 57 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/event/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package event 18 | 19 | import "fmt" 20 | 21 | func ExampleTypeMux() { 22 | type someEvent struct{ I int } 23 | type otherEvent struct{ S string } 24 | type yetAnotherEvent struct{ X, Y int } 25 | 26 | var mux TypeMux 27 | 28 | // Start a subscriber. 29 | done := make(chan struct{}) 30 | sub := mux.Subscribe(someEvent{}, otherEvent{}) 31 | go func() { 32 | for event := range sub.Chan() { 33 | fmt.Printf("Received: %#v\n", event.Data) 34 | } 35 | fmt.Println("done") 36 | close(done) 37 | }() 38 | 39 | // Post some events. 40 | mux.Post(someEvent{5}) 41 | mux.Post(yetAnotherEvent{X: 3, Y: 4}) 42 | mux.Post(someEvent{6}) 43 | mux.Post(otherEvent{"whoa"}) 44 | 45 | // Stop closes all subscription channels. 46 | // The subscriber goroutine will print "done" 47 | // and exit. 48 | mux.Stop() 49 | 50 | // Wait for subscriber to return. 51 | <-done 52 | 53 | // Output: 54 | // Received: event.someEvent{I:5} 55 | // Received: event.someEvent{I:6} 56 | // Received: event.otherEvent{S:"whoa"} 57 | // done 58 | } 59 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/event/filter/filter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | // Package filter implements event filters. 18 | package filter 19 | 20 | import "reflect" 21 | 22 | type Filter interface { 23 | Compare(Filter) bool 24 | Trigger(data interface{}) 25 | } 26 | 27 | type FilterEvent struct { 28 | filter Filter 29 | data interface{} 30 | } 31 | 32 | type Filters struct { 33 | id int 34 | watchers map[int]Filter 35 | ch chan FilterEvent 36 | 37 | quit chan struct{} 38 | } 39 | 40 | func New() *Filters { 41 | return &Filters{ 42 | ch: make(chan FilterEvent), 43 | watchers: make(map[int]Filter), 44 | quit: make(chan struct{}), 45 | } 46 | } 47 | 48 | func (self *Filters) Start() { 49 | go self.loop() 50 | } 51 | 52 | func (self *Filters) Stop() { 53 | close(self.quit) 54 | } 55 | 56 | func (self *Filters) Notify(filter Filter, data interface{}) { 57 | self.ch <- FilterEvent{filter, data} 58 | } 59 | 60 | func (self *Filters) Install(watcher Filter) int { 61 | self.watchers[self.id] = watcher 62 | self.id++ 63 | 64 | return self.id - 1 65 | } 66 | 67 | func (self *Filters) Uninstall(id int) { 68 | delete(self.watchers, id) 69 | } 70 | 71 | func (self *Filters) loop() { 72 | out: 73 | for { 74 | select { 75 | case <-self.quit: 76 | break out 77 | case event := <-self.ch: 78 | for _, watcher := range self.watchers { 79 | if reflect.TypeOf(watcher) == reflect.TypeOf(event.filter) { 80 | if watcher.Compare(event.filter) { 81 | watcher.Trigger(event.data) 82 | } 83 | } 84 | } 85 | } 86 | } 87 | } 88 | 89 | func (self *Filters) Match(a, b Filter) bool { 90 | return reflect.TypeOf(a) == reflect.TypeOf(b) && a.Compare(b) 91 | } 92 | 93 | func (self *Filters) Get(i int) Filter { 94 | return self.watchers[i] 95 | } 96 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/event/filter/filter_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package filter 18 | 19 | import ( 20 | "testing" 21 | "time" 22 | ) 23 | 24 | // Simple test to check if baseline matching/mismatching filtering works. 25 | func TestFilters(t *testing.T) { 26 | fm := New() 27 | fm.Start() 28 | 29 | // Register two filters to catch posted data 30 | first := make(chan struct{}) 31 | fm.Install(Generic{ 32 | Str1: "hello", 33 | Fn: func(data interface{}) { 34 | first <- struct{}{} 35 | }, 36 | }) 37 | second := make(chan struct{}) 38 | fm.Install(Generic{ 39 | Str1: "hello1", 40 | Str2: "hello", 41 | Fn: func(data interface{}) { 42 | second <- struct{}{} 43 | }, 44 | }) 45 | // Post an event that should only match the first filter 46 | fm.Notify(Generic{Str1: "hello"}, true) 47 | fm.Stop() 48 | 49 | // Ensure only the mathcing filters fire 50 | select { 51 | case <-first: 52 | case <-time.After(100 * time.Millisecond): 53 | t.Error("matching filter timed out") 54 | } 55 | select { 56 | case <-second: 57 | t.Error("mismatching filter fired") 58 | case <-time.After(100 * time.Millisecond): 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/event/filter/generic_filter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package filter 18 | 19 | type Generic struct { 20 | Str1, Str2, Str3 string 21 | Data map[string]struct{} 22 | 23 | Fn func(data interface{}) 24 | } 25 | 26 | // self = registered, f = incoming 27 | func (self Generic) Compare(f Filter) bool { 28 | var strMatch, dataMatch = true, true 29 | 30 | filter := f.(Generic) 31 | if (len(self.Str1) > 0 && filter.Str1 != self.Str1) || 32 | (len(self.Str2) > 0 && filter.Str2 != self.Str2) || 33 | (len(self.Str3) > 0 && filter.Str3 != self.Str3) { 34 | strMatch = false 35 | } 36 | 37 | for k := range self.Data { 38 | if _, ok := filter.Data[k]; !ok { 39 | return false 40 | } 41 | } 42 | 43 | return strMatch && dataMatch 44 | } 45 | 46 | func (self Generic) Trigger(data interface{}) { 47 | self.Fn(data) 48 | } 49 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Contributors to log15: 2 | 3 | - Aaron L 4 | - Alan Shreve 5 | - Chris Hines 6 | - Ciaran Downey 7 | - Dmitry Chestnykh 8 | - Evan Shaw 9 | - Péter Szilágyi 10 | - Trevor Gattis 11 | - Vincent Vanackere 12 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Alan Shreve 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/README_ETHEREUM.md: -------------------------------------------------------------------------------- 1 | This package is a fork of https://github.com/inconshreveable/log15, with some 2 | minor modifications required by the go-ethereum codebase: 3 | 4 | * Support for log level `trace` 5 | * Modified behavior to exit on `critical` failure 6 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/handler_go13.go: -------------------------------------------------------------------------------- 1 | // +build !go1.4 2 | 3 | package log 4 | 5 | import ( 6 | "sync/atomic" 7 | "unsafe" 8 | ) 9 | 10 | // swapHandler wraps another handler that may be swapped out 11 | // dynamically at runtime in a thread-safe fashion. 12 | type swapHandler struct { 13 | handler unsafe.Pointer 14 | } 15 | 16 | func (h *swapHandler) Log(r *Record) error { 17 | return h.Get().Log(r) 18 | } 19 | 20 | func (h *swapHandler) Get() Handler { 21 | return *(*Handler)(atomic.LoadPointer(&h.handler)) 22 | } 23 | 24 | func (h *swapHandler) Swap(newHandler Handler) { 25 | atomic.StorePointer(&h.handler, unsafe.Pointer(&newHandler)) 26 | } 27 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/handler_go14.go: -------------------------------------------------------------------------------- 1 | // +build go1.4 2 | 3 | package log 4 | 5 | import "sync/atomic" 6 | 7 | // swapHandler wraps another handler that may be swapped out 8 | // dynamically at runtime in a thread-safe fashion. 9 | type swapHandler struct { 10 | handler atomic.Value 11 | } 12 | 13 | func (h *swapHandler) Log(r *Record) error { 14 | return (*h.handler.Load().(*Handler)).Log(r) 15 | } 16 | 17 | func (h *swapHandler) Swap(newHandler Handler) { 18 | h.handler.Store(&newHandler) 19 | } 20 | 21 | func (h *swapHandler) Get() Handler { 22 | return *h.handler.Load().(*Handler) 23 | } 24 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/root.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "os" 5 | ) 6 | 7 | var ( 8 | root = &logger{[]interface{}{}, new(swapHandler)} 9 | StdoutHandler = StreamHandler(os.Stdout, LogfmtFormat()) 10 | StderrHandler = StreamHandler(os.Stderr, LogfmtFormat()) 11 | ) 12 | 13 | func init() { 14 | root.SetHandler(DiscardHandler()) 15 | } 16 | 17 | // New returns a new logger with the given context. 18 | // New is a convenient alias for Root().New 19 | func New(ctx ...interface{}) Logger { 20 | return root.New(ctx...) 21 | } 22 | 23 | // Root returns the root logger 24 | func Root() Logger { 25 | return root 26 | } 27 | 28 | // The following functions bypass the exported logger methods (logger.Debug, 29 | // etc.) to keep the call depth the same for all paths to logger.write so 30 | // runtime.Caller(2) always refers to the call site in client code. 31 | 32 | // Trace is a convenient alias for Root().Trace 33 | func Trace(msg string, ctx ...interface{}) { 34 | root.write(msg, LvlTrace, ctx) 35 | } 36 | 37 | // Debug is a convenient alias for Root().Debug 38 | func Debug(msg string, ctx ...interface{}) { 39 | root.write(msg, LvlDebug, ctx) 40 | } 41 | 42 | // Info is a convenient alias for Root().Info 43 | func Info(msg string, ctx ...interface{}) { 44 | root.write(msg, LvlInfo, ctx) 45 | } 46 | 47 | // Warn is a convenient alias for Root().Warn 48 | func Warn(msg string, ctx ...interface{}) { 49 | root.write(msg, LvlWarn, ctx) 50 | } 51 | 52 | // Error is a convenient alias for Root().Error 53 | func Error(msg string, ctx ...interface{}) { 54 | root.write(msg, LvlError, ctx) 55 | } 56 | 57 | // Crit is a convenient alias for Root().Crit 58 | func Crit(msg string, ctx ...interface{}) { 59 | root.write(msg, LvlCrit, ctx) 60 | os.Exit(1) 61 | } 62 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/syslog.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!plan9 2 | 3 | package log 4 | 5 | import ( 6 | "log/syslog" 7 | "strings" 8 | ) 9 | 10 | // SyslogHandler opens a connection to the system syslog daemon by calling 11 | // syslog.New and writes all records to it. 12 | func SyslogHandler(priority syslog.Priority, tag string, fmtr Format) (Handler, error) { 13 | wr, err := syslog.New(priority, tag) 14 | return sharedSyslog(fmtr, wr, err) 15 | } 16 | 17 | // SyslogNetHandler opens a connection to a log daemon over the network and writes 18 | // all log records to it. 19 | func SyslogNetHandler(net, addr string, priority syslog.Priority, tag string, fmtr Format) (Handler, error) { 20 | wr, err := syslog.Dial(net, addr, priority, tag) 21 | return sharedSyslog(fmtr, wr, err) 22 | } 23 | 24 | func sharedSyslog(fmtr Format, sysWr *syslog.Writer, err error) (Handler, error) { 25 | if err != nil { 26 | return nil, err 27 | } 28 | h := FuncHandler(func(r *Record) error { 29 | var syslogFn = sysWr.Info 30 | switch r.Lvl { 31 | case LvlCrit: 32 | syslogFn = sysWr.Crit 33 | case LvlError: 34 | syslogFn = sysWr.Err 35 | case LvlWarn: 36 | syslogFn = sysWr.Warning 37 | case LvlInfo: 38 | syslogFn = sysWr.Info 39 | case LvlDebug: 40 | syslogFn = sysWr.Debug 41 | case LvlTrace: 42 | syslogFn = func(m string) error { return nil } // There's no syslog level for trace 43 | } 44 | 45 | s := strings.TrimSpace(string(fmtr.Format(r))) 46 | return syslogFn(s) 47 | }) 48 | return LazyHandler(&closingHandler{sysWr, h}), nil 49 | } 50 | 51 | func (m muster) SyslogHandler(priority syslog.Priority, tag string, fmtr Format) Handler { 52 | return must(SyslogHandler(priority, tag, fmtr)) 53 | } 54 | 55 | func (m muster) SyslogNetHandler(net, addr string, priority syslog.Priority, tag string, fmtr Format) Handler { 56 | return must(SyslogNetHandler(net, addr, priority, tag, fmtr)) 57 | } 58 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/term/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/term/terminal_appengine.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build appengine 7 | 8 | package term 9 | 10 | // IsTty always returns false on AppEngine. 11 | func IsTty(fd uintptr) bool { 12 | return false 13 | } 14 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/term/terminal_darwin.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | // +build !appengine 6 | 7 | package term 8 | 9 | import "syscall" 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | type Termios syscall.Termios 14 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/term/terminal_freebsd.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | const ioctlReadTermios = syscall.TIOCGETA 8 | 9 | // Go 1.2 doesn't include Termios for FreeBSD. This should be added in 1.3 and this could be merged with terminal_darwin. 10 | type Termios struct { 11 | Iflag uint32 12 | Oflag uint32 13 | Cflag uint32 14 | Lflag uint32 15 | Cc [20]uint8 16 | Ispeed uint32 17 | Ospeed uint32 18 | } 19 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/term/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build !appengine 7 | 8 | package term 9 | 10 | import "syscall" 11 | 12 | const ioctlReadTermios = syscall.TCGETS 13 | 14 | type Termios syscall.Termios 15 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/term/terminal_netbsd.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import "syscall" 4 | 5 | const ioctlReadTermios = syscall.TIOCGETA 6 | 7 | type Termios syscall.Termios 8 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/term/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build linux,!appengine darwin freebsd openbsd netbsd 7 | 8 | package term 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // IsTty returns true if the given file descriptor is a terminal. 16 | func IsTty(fd uintptr) bool { 17 | var termios Termios 18 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 19 | return err == 0 20 | } 21 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/term/terminal_openbsd.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import "syscall" 4 | 5 | const ioctlReadTermios = syscall.TIOCGETA 6 | 7 | type Termios syscall.Termios 8 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/term/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import "golang.org/x/sys/unix" 4 | 5 | // IsTty returns true if the given file descriptor is a terminal. 6 | func IsTty(fd uintptr) bool { 7 | _, err := unix.IoctlGetTermios(int(fd), unix.TCGETA) 8 | return err == nil 9 | } 10 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/log/term/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows 7 | 8 | package term 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTty returns true if the given file descriptor is a terminal. 22 | func IsTty(fd uintptr) bool { 23 | var st uint32 24 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) 25 | return r != 0 && e == 0 26 | } 27 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/metrics/disk.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package metrics 18 | 19 | // DiskStats is the per process disk io stats. 20 | type DiskStats struct { 21 | ReadCount int64 // Number of read operations executed 22 | ReadBytes int64 // Total number of bytes read 23 | WriteCount int64 // Number of write operations executed 24 | WriteBytes int64 // Total number of byte written 25 | } 26 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/metrics/disk_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | // Contains the Linux implementation of process disk IO counter retrieval. 18 | 19 | package metrics 20 | 21 | import ( 22 | "bufio" 23 | "fmt" 24 | "io" 25 | "os" 26 | "strconv" 27 | "strings" 28 | ) 29 | 30 | // ReadDiskStats retrieves the disk IO stats belonging to the current process. 31 | func ReadDiskStats(stats *DiskStats) error { 32 | // Open the process disk IO counter file 33 | inf, err := os.Open(fmt.Sprintf("/proc/%d/io", os.Getpid())) 34 | if err != nil { 35 | return err 36 | } 37 | defer inf.Close() 38 | in := bufio.NewReader(inf) 39 | 40 | // Iterate over the IO counter, and extract what we need 41 | for { 42 | // Read the next line and split to key and value 43 | line, err := in.ReadString('\n') 44 | if err != nil { 45 | if err == io.EOF { 46 | return nil 47 | } 48 | return err 49 | } 50 | parts := strings.Split(line, ":") 51 | if len(parts) != 2 { 52 | continue 53 | } 54 | key := strings.TrimSpace(parts[0]) 55 | value, err := strconv.ParseInt(strings.TrimSpace(parts[1]), 10, 64) 56 | if err != nil { 57 | return err 58 | } 59 | 60 | // Update the counter based on the key 61 | switch key { 62 | case "syscr": 63 | stats.ReadCount = value 64 | case "syscw": 65 | stats.WriteCount = value 66 | case "rchar": 67 | stats.ReadBytes = value 68 | case "wchar": 69 | stats.WriteBytes = value 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/metrics/disk_nop.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | // +build !linux 18 | 19 | package metrics 20 | 21 | import "errors" 22 | 23 | // ReadDiskStats retrieves the disk IO stats belonging to the current process. 24 | func ReadDiskStats(stats *DiskStats) error { 25 | return errors.New("Not implemented") 26 | } 27 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/p2p/discv5/nodeevent_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type=nodeEvent"; DO NOT EDIT. 2 | 3 | package discv5 4 | 5 | import "strconv" 6 | 7 | const ( 8 | _nodeEvent_name_0 = "invalidEventpingPacketpongPacketfindnodePacketneighborsPacketfindnodeHashPackettopicRegisterPackettopicQueryPackettopicNodesPacket" 9 | _nodeEvent_name_1 = "pongTimeoutpingTimeoutneighboursTimeout" 10 | ) 11 | 12 | var ( 13 | _nodeEvent_index_0 = [...]uint8{0, 12, 22, 32, 46, 61, 79, 98, 114, 130} 14 | _nodeEvent_index_1 = [...]uint8{0, 11, 22, 39} 15 | ) 16 | 17 | func (i nodeEvent) String() string { 18 | switch { 19 | case 0 <= i && i <= 8: 20 | return _nodeEvent_name_0[_nodeEvent_index_0[i]:_nodeEvent_index_0[i+1]] 21 | case 265 <= i && i <= 267: 22 | i -= 265 23 | return _nodeEvent_name_1[_nodeEvent_index_1[i]:_nodeEvent_index_1[i+1]] 24 | default: 25 | return "nodeEvent(" + strconv.FormatInt(int64(i), 10) + ")" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/p2p/discv5/sim_testmain_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | // +build go1.4,nacl,faketime_simulation 18 | 19 | package discv5 20 | 21 | import ( 22 | "os" 23 | "runtime" 24 | "testing" 25 | "unsafe" 26 | ) 27 | 28 | // Enable fake time mode in the runtime, like on the go playground. 29 | // There is a slight chance that this won't work because some go code 30 | // might have executed before the variable is set. 31 | 32 | //go:linkname faketime runtime.faketime 33 | var faketime = 1 34 | 35 | func TestMain(m *testing.M) { 36 | // We need to use unsafe somehow in order to get access to go:linkname. 37 | _ = unsafe.Sizeof(0) 38 | 39 | // Run the actual test. runWithPlaygroundTime ensures that the only test 40 | // that runs is the one calling it. 41 | runtime.GOMAXPROCS(8) 42 | os.Exit(m.Run()) 43 | } 44 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/p2p/discv5/topic_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package discv5 18 | 19 | import ( 20 | "encoding/binary" 21 | "testing" 22 | "time" 23 | 24 | "github.com/ethereum/go-ethereum/common" 25 | "github.com/ethereum/go-ethereum/common/mclock" 26 | ) 27 | 28 | func TestTopicRadius(t *testing.T) { 29 | now := mclock.Now() 30 | topic := Topic("qwerty") 31 | rad := newTopicRadius(topic) 32 | targetRad := (^uint64(0)) / 100 33 | 34 | waitFn := func(addr common.Hash) time.Duration { 35 | prefix := binary.BigEndian.Uint64(addr[0:8]) 36 | dist := prefix ^ rad.topicHashPrefix 37 | relDist := float64(dist) / float64(targetRad) 38 | relTime := (1 - relDist/2) * 2 39 | if relTime < 0 { 40 | relTime = 0 41 | } 42 | return time.Duration(float64(targetWaitTime) * relTime) 43 | } 44 | 45 | bcnt := 0 46 | cnt := 0 47 | var sum float64 48 | for cnt < 100 { 49 | addr := rad.nextTarget(false).target 50 | wait := waitFn(addr) 51 | ticket := &ticket{ 52 | topics: []Topic{topic}, 53 | regTime: []mclock.AbsTime{mclock.AbsTime(wait)}, 54 | node: &Node{nodeNetGuts: nodeNetGuts{sha: addr}}, 55 | } 56 | rad.adjustWithTicket(now, addr, ticketRef{ticket, 0}) 57 | if rad.radius != maxRadius { 58 | cnt++ 59 | sum += float64(rad.radius) 60 | } else { 61 | bcnt++ 62 | if bcnt > 500 { 63 | t.Errorf("Radius did not converge in 500 iterations") 64 | } 65 | } 66 | } 67 | avgRel := sum / float64(cnt) / float64(targetRad) 68 | if avgRel > 1.05 || avgRel < 0.95 { 69 | t.Errorf("Average/target ratio is too far from 1 (%v)", avgRel) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/p2p/nat/nat_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package nat 18 | 19 | import ( 20 | "net" 21 | "testing" 22 | "time" 23 | ) 24 | 25 | // This test checks that autodisc doesn't hang and returns 26 | // consistent results when multiple goroutines call its methods 27 | // concurrently. 28 | func TestAutoDiscRace(t *testing.T) { 29 | ad := startautodisc("thing", func() Interface { 30 | time.Sleep(500 * time.Millisecond) 31 | return extIP{33, 44, 55, 66} 32 | }) 33 | 34 | // Spawn a few concurrent calls to ad.ExternalIP. 35 | type rval struct { 36 | ip net.IP 37 | err error 38 | } 39 | results := make(chan rval, 50) 40 | for i := 0; i < cap(results); i++ { 41 | go func() { 42 | ip, err := ad.ExternalIP() 43 | results <- rval{ip, err} 44 | }() 45 | } 46 | 47 | // Check that they all return the correct result within the deadline. 48 | deadline := time.After(2 * time.Second) 49 | for i := 0; i < cap(results); i++ { 50 | select { 51 | case <-deadline: 52 | t.Fatal("deadline exceeded") 53 | case rval := <-results: 54 | if rval.err != nil { 55 | t.Errorf("result %d: unexpected error: %v", i, rval.err) 56 | } 57 | wantIP := net.IP{33, 44, 55, 66} 58 | if !rval.ip.Equal(wantIP) { 59 | t.Errorf("result %d: got IP %v, want %v", i, rval.ip, wantIP) 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/p2p/netutil/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package netutil 18 | 19 | // IsTemporaryError checks whether the given error should be considered temporary. 20 | func IsTemporaryError(err error) bool { 21 | tempErr, ok := err.(interface { 22 | Temporary() bool 23 | }) 24 | return ok && tempErr.Temporary() || isPacketTooBig(err) 25 | } 26 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/p2p/netutil/error_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package netutil 18 | 19 | import ( 20 | "net" 21 | "testing" 22 | "time" 23 | ) 24 | 25 | // This test checks that isPacketTooBig correctly identifies 26 | // errors that result from receiving a UDP packet larger 27 | // than the supplied receive buffer. 28 | func TestIsPacketTooBig(t *testing.T) { 29 | listener, err := net.ListenPacket("udp", "127.0.0.1:0") 30 | if err != nil { 31 | t.Fatal(err) 32 | } 33 | defer listener.Close() 34 | sender, err := net.Dial("udp", listener.LocalAddr().String()) 35 | if err != nil { 36 | t.Fatal(err) 37 | } 38 | defer sender.Close() 39 | 40 | sendN := 1800 41 | recvN := 300 42 | for i := 0; i < 20; i++ { 43 | go func() { 44 | buf := make([]byte, sendN) 45 | for i := range buf { 46 | buf[i] = byte(i) 47 | } 48 | sender.Write(buf) 49 | }() 50 | 51 | buf := make([]byte, recvN) 52 | listener.SetDeadline(time.Now().Add(1 * time.Second)) 53 | n, _, err := listener.ReadFrom(buf) 54 | if err != nil { 55 | if nerr, ok := err.(net.Error); ok && nerr.Timeout() { 56 | continue 57 | } 58 | if !isPacketTooBig(err) { 59 | t.Fatalf("unexpected read error: %v", err) 60 | } 61 | continue 62 | } 63 | if n != recvN { 64 | t.Fatalf("short read: %d, want %d", n, recvN) 65 | } 66 | for i := range buf { 67 | if buf[i] != byte(i) { 68 | t.Fatalf("error in pattern") 69 | break 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/p2p/netutil/toobig_notwindows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | //+build !windows 18 | 19 | package netutil 20 | 21 | // isPacketTooBig reports whether err indicates that a UDP packet didn't 22 | // fit the receive buffer. There is no such error on 23 | // non-Windows platforms. 24 | func isPacketTooBig(err error) bool { 25 | return false 26 | } 27 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/p2p/netutil/toobig_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | //+build windows 18 | 19 | package netutil 20 | 21 | import ( 22 | "net" 23 | "os" 24 | "syscall" 25 | ) 26 | 27 | const _WSAEMSGSIZE = syscall.Errno(10040) 28 | 29 | // isPacketTooBig reports whether err indicates that a UDP packet didn't 30 | // fit the receive buffer. On Windows, WSARecvFrom returns 31 | // code WSAEMSGSIZE and no data if this happens. 32 | func isPacketTooBig(err error) bool { 33 | if opErr, ok := err.(*net.OpError); ok { 34 | if scErr, ok := opErr.Err.(*os.SyscallError); ok { 35 | return scErr.Err == _WSAEMSGSIZE 36 | } 37 | return opErr.Err == _WSAEMSGSIZE 38 | } 39 | return false 40 | } 41 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/p2p/simulations/adapters/state.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | package adapters 17 | 18 | type SimStateStore struct { 19 | m map[string][]byte 20 | } 21 | 22 | func (self *SimStateStore) Load(s string) ([]byte, error) { 23 | return self.m[s], nil 24 | } 25 | 26 | func (self *SimStateStore) Save(s string, data []byte) error { 27 | self.m[s] = data 28 | return nil 29 | } 30 | 31 | func NewSimStateStore() *SimStateStore { 32 | return &SimStateStore{ 33 | make(map[string][]byte), 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/p2p/simulations/examples/README.md: -------------------------------------------------------------------------------- 1 | # devp2p simulation examples 2 | 3 | ## ping-pong 4 | 5 | `ping-pong.go` implements a simulation network which contains nodes running a 6 | simple "ping-pong" protocol where nodes send a ping message to all their 7 | connected peers every 10s and receive pong messages in return. 8 | 9 | To run the simulation, run `go run ping-pong.go` in one terminal to start the 10 | simulation API and `./ping-pong.sh` in another to start and connect the nodes: 11 | 12 | ``` 13 | $ go run ping-pong.go 14 | INFO [08-15|13:53:49] using sim adapter 15 | INFO [08-15|13:53:49] starting simulation server on 0.0.0.0:8888... 16 | ``` 17 | 18 | ``` 19 | $ ./ping-pong.sh 20 | ---> 13:58:12 creating 10 nodes 21 | Created node01 22 | Started node01 23 | ... 24 | Created node10 25 | Started node10 26 | ---> 13:58:13 connecting node01 to all other nodes 27 | Connected node01 to node02 28 | ... 29 | Connected node01 to node10 30 | ---> 13:58:14 done 31 | ``` 32 | 33 | Use the `--adapter` flag to choose the adapter type: 34 | 35 | ``` 36 | $ go run ping-pong.go --adapter exec 37 | INFO [08-15|14:01:14] using exec adapter tmpdir=/var/folders/k6/wpsgfg4n23ddbc6f5cnw5qg00000gn/T/p2p-example992833779 38 | INFO [08-15|14:01:14] starting simulation server on 0.0.0.0:8888... 39 | ``` 40 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/p2p/simulations/examples/ping-pong.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Boot a ping-pong network simulation using the HTTP API started by ping-pong.go 4 | 5 | set -e 6 | 7 | main() { 8 | if ! which p2psim &>/dev/null; then 9 | fail "missing p2psim binary (you need to build cmd/p2psim and put it in \$PATH)" 10 | fi 11 | 12 | info "creating 10 nodes" 13 | for i in $(seq 1 10); do 14 | p2psim node create --name "$(node_name $i)" 15 | p2psim node start "$(node_name $i)" 16 | done 17 | 18 | info "connecting node01 to all other nodes" 19 | for i in $(seq 2 10); do 20 | p2psim node connect "node01" "$(node_name $i)" 21 | done 22 | 23 | info "done" 24 | } 25 | 26 | node_name() { 27 | local num=$1 28 | echo "node$(printf '%02d' $num)" 29 | } 30 | 31 | info() { 32 | echo -e "\033[1;32m---> $(date +%H:%M:%S) ${@}\033[0m" 33 | } 34 | 35 | fail() { 36 | echo -e "\033[1;31mERROR: ${@}\033[0m" >&2 37 | exit 1 38 | } 39 | 40 | main "$@" 41 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/rlp/decode_tail_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package rlp 18 | 19 | import ( 20 | "bytes" 21 | "fmt" 22 | ) 23 | 24 | type structWithTail struct { 25 | A, B uint 26 | C []uint `rlp:"tail"` 27 | } 28 | 29 | func ExampleDecode_structTagTail() { 30 | // In this example, the "tail" struct tag is used to decode lists of 31 | // differing length into a struct. 32 | var val structWithTail 33 | 34 | err := Decode(bytes.NewReader([]byte{0xC4, 0x01, 0x02, 0x03, 0x04}), &val) 35 | fmt.Printf("with 4 elements: err=%v val=%v\n", err, val) 36 | 37 | err = Decode(bytes.NewReader([]byte{0xC6, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06}), &val) 38 | fmt.Printf("with 6 elements: err=%v val=%v\n", err, val) 39 | 40 | // Note that at least two list elements must be present to 41 | // fill fields A and B: 42 | err = Decode(bytes.NewReader([]byte{0xC1, 0x01}), &val) 43 | fmt.Printf("with 1 element: err=%q\n", err) 44 | 45 | // Output: 46 | // with 4 elements: err= val={1 2 [3 4]} 47 | // with 6 elements: err= val={1 2 [3 4 5 6]} 48 | // with 1 element: err="rlp: too few elements for rlp.structWithTail" 49 | } 50 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/rlp/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | /* 18 | Package rlp implements the RLP serialization format. 19 | 20 | The purpose of RLP (Recursive Linear Prefix) is to encode arbitrarily 21 | nested arrays of binary data, and RLP is the main encoding method used 22 | to serialize objects in Ethereum. The only purpose of RLP is to encode 23 | structure; encoding specific atomic data types (eg. strings, ints, 24 | floats) is left up to higher-order protocols; in Ethereum integers 25 | must be represented in big endian binary form with no leading zeroes 26 | (thus making the integer value zero equivalent to the empty byte 27 | array). 28 | 29 | RLP values are distinguished by a type tag. The type tag precedes the 30 | value in the input stream and defines the size and kind of the bytes 31 | that follow. 32 | */ 33 | package rlp 34 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/rlp/encoder_example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-ethereum Authors 2 | // This file is part of the go-ethereum library. 3 | // 4 | // The go-ethereum library is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // The go-ethereum library is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Lesser General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Lesser General Public License 15 | // along with the go-ethereum library. If not, see . 16 | 17 | package rlp 18 | 19 | import ( 20 | "fmt" 21 | "io" 22 | ) 23 | 24 | type MyCoolType struct { 25 | Name string 26 | a, b uint 27 | } 28 | 29 | // EncodeRLP writes x as RLP list [a, b] that omits the Name field. 30 | func (x *MyCoolType) EncodeRLP(w io.Writer) (err error) { 31 | // Note: the receiver can be a nil pointer. This allows you to 32 | // control the encoding of nil, but it also means that you have to 33 | // check for a nil receiver. 34 | if x == nil { 35 | err = Encode(w, []uint{0, 0}) 36 | } else { 37 | err = Encode(w, []uint{x.a, x.b}) 38 | } 39 | return err 40 | } 41 | 42 | func ExampleEncoder() { 43 | var t *MyCoolType // t is nil pointer to MyCoolType 44 | bytes, _ := EncodeToBytes(t) 45 | fmt.Printf("%v → %X\n", t, bytes) 46 | 47 | t = &MyCoolType{Name: "foobar", a: 5, b: 6} 48 | bytes, _ = EncodeToBytes(t) 49 | fmt.Printf("%v → %X\n", t, bytes) 50 | 51 | // Output: 52 | // → C28080 53 | // &{foobar 5 6} → C20506 54 | } 55 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/aristanetworks/goarista/monotime/issue15006.s: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 Arista Networks, Inc. 2 | // Use of this source code is governed by the Apache License 2.0 3 | // that can be found in the COPYING file. 4 | 5 | // This file is intentionally empty. 6 | // It's a workaround for https://github.com/golang/go/issues/15006 7 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/aristanetworks/goarista/monotime/nanotime.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 Arista Networks, Inc. 2 | // Use of this source code is governed by the Apache License 2.0 3 | // that can be found in the COPYING file. 4 | 5 | // Package monotime provides a fast monotonic clock source. 6 | package monotime 7 | 8 | import ( 9 | "time" 10 | _ "unsafe" // required to use //go:linkname 11 | ) 12 | 13 | //go:noescape 14 | //go:linkname nanotime runtime.nanotime 15 | func nanotime() int64 16 | 17 | // Now returns the current time in nanoseconds from a monotonic clock. 18 | // The time returned is based on some arbitrary platform-specific point in the 19 | // past. The time returned is guaranteed to increase monotonically at a 20 | // constant rate, unlike time.Now() from the Go standard library, which may 21 | // slow down, speed up, jump forward or backward, due to NTP activity or leap 22 | // seconds. 23 | func Now() uint64 { 24 | return uint64(nanotime()) 25 | } 26 | 27 | // Since returns the amount of time that has elapsed since t. t should be 28 | // the result of a call to Now() on the same machine. 29 | func Since(t uint64) time.Duration { 30 | return time.Duration(Now() - t) 31 | } 32 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/go-stack/stack/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Chris Hines 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/go-stack/stack/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/go-stack/stack?status.svg)](https://godoc.org/github.com/go-stack/stack) 2 | [![Go Report Card](https://goreportcard.com/badge/go-stack/stack)](https://goreportcard.com/report/go-stack/stack) 3 | [![TravisCI](https://travis-ci.org/go-stack/stack.svg?branch=master)](https://travis-ci.org/go-stack/stack) 4 | [![Coverage Status](https://coveralls.io/repos/github/go-stack/stack/badge.svg?branch=master)](https://coveralls.io/github/go-stack/stack?branch=master) 5 | 6 | # stack 7 | 8 | Package stack implements utilities to capture, manipulate, and format call 9 | stacks. It provides a simpler API than package runtime. 10 | 11 | The implementation takes care of the minutia and special cases of interpreting 12 | the program counter (pc) values returned by runtime.Callers. 13 | 14 | ## Versioning 15 | 16 | Package stack publishes releases via [semver](http://semver.org/) compatible Git 17 | tags prefixed with a single 'v'. The master branch always contains the latest 18 | release. The develop branch contains unreleased commits. 19 | 20 | ## Formatting 21 | 22 | Package stack's types implement fmt.Formatter, which provides a simple and 23 | flexible way to declaratively configure formatting when used with logging or 24 | error tracking packages. 25 | 26 | ```go 27 | func DoTheThing() { 28 | c := stack.Caller(0) 29 | log.Print(c) // "source.go:10" 30 | log.Printf("%+v", c) // "pkg/path/source.go:10" 31 | log.Printf("%n", c) // "DoTheThing" 32 | 33 | s := stack.Trace().TrimRuntime() 34 | log.Print(s) // "[source.go:15 caller.go:42 main.go:14]" 35 | } 36 | ``` 37 | 38 | See the docs for all of the supported formatting options. 39 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/golang/snappy/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Snappy-Go authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | # Please keep the list sorted. 10 | 11 | Damian Gryski 12 | Google Inc. 13 | Jan Mercl <0xjnml@gmail.com> 14 | Rodolfo Carvalho 15 | Sebastien Binet 16 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/golang/snappy/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This is the official list of people who can contribute 2 | # (and typically have contributed) code to the Snappy-Go repository. 3 | # The AUTHORS file lists the copyright holders; this file 4 | # lists people. For example, Google employees are listed here 5 | # but not in AUTHORS, because Google holds the copyright. 6 | # 7 | # The submission process automatically checks to make sure 8 | # that people submitting code are listed in this file (by email address). 9 | # 10 | # Names should be added to this file only after verifying that 11 | # the individual or the individual's organization has agreed to 12 | # the appropriate Contributor License Agreement, found here: 13 | # 14 | # http://code.google.com/legal/individual-cla-v1.0.html 15 | # http://code.google.com/legal/corporate-cla-v1.0.html 16 | # 17 | # The agreement for individuals can be filled out on the web. 18 | # 19 | # When adding J Random Contributor's name to this file, 20 | # either J's name or J's organization's name should be 21 | # added to the AUTHORS file, depending on whether the 22 | # individual or corporate CLA was used. 23 | 24 | # Names should be added to this file like so: 25 | # Name 26 | 27 | # Please keep the list sorted. 28 | 29 | Damian Gryski 30 | Jan Mercl <0xjnml@gmail.com> 31 | Kai Backman 32 | Marc-Antoine Ruel 33 | Nigel Tao 34 | Rob Pike 35 | Rodolfo Carvalho 36 | Russ Cox 37 | Sebastien Binet 38 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/golang/snappy/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 The Snappy-Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/golang/snappy/decode_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Snappy-Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | // +build gc 7 | // +build !noasm 8 | 9 | package snappy 10 | 11 | // decode has the same semantics as in decode_other.go. 12 | // 13 | //go:noescape 14 | func decode(dst, src []byte) int 15 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/golang/snappy/encode_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Snappy-Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | // +build gc 7 | // +build !noasm 8 | 9 | package snappy 10 | 11 | // emitLiteral has the same semantics as in encode_other.go. 12 | // 13 | //go:noescape 14 | func emitLiteral(dst, lit []byte) int 15 | 16 | // emitCopy has the same semantics as in encode_other.go. 17 | // 18 | //go:noescape 19 | func emitCopy(dst []byte, offset, length int) int 20 | 21 | // extendMatch has the same semantics as in encode_other.go. 22 | // 23 | //go:noescape 24 | func extendMatch(src []byte, i, j int) int 25 | 26 | // encodeBlock has the same semantics as in encode_other.go. 27 | // 28 | //go:noescape 29 | func encodeBlock(dst, src []byte) (d int) 30 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, John Beisley 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/jackpal/go-nat-pmp/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013 John Howard Palevich 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/jackpal/go-nat-pmp/README.md: -------------------------------------------------------------------------------- 1 | go-nat-pmp 2 | ========== 3 | 4 | A Go language client for the NAT-PMP internet protocol for port mapping and discovering the external 5 | IP address of a firewall. 6 | 7 | NAT-PMP is supported by Apple brand routers and open source routers like Tomato and DD-WRT. 8 | 9 | See http://tools.ietf.org/html/draft-cheshire-nat-pmp-03 10 | 11 | 12 | [![Build Status](https://travis-ci.org/jackpal/go-nat-pmp.svg)](https://travis-ci.org/jackpal/go-nat-pmp) 13 | 14 | Get the package 15 | --------------- 16 | 17 | go get -u github.com/jackpal/go-nat-pmp 18 | 19 | Usage 20 | ----- 21 | 22 | import ( 23 | "github.com/jackpal/gateway" 24 | natpmp "github.com/jackpal/go-nat-pmp" 25 | ) 26 | 27 | gatewayIP, err = gateway.DiscoverGateway() 28 | if err != nil { 29 | return 30 | } 31 | 32 | client := natpmp.NewClient(gatewayIP) 33 | response, err := client.GetExternalAddress() 34 | if err != nil { 35 | return 36 | } 37 | print("External IP address:", response.ExternalIPAddress) 38 | 39 | Clients 40 | ------- 41 | 42 | This library is used in the Taipei Torrent BitTorrent client http://github.com/jackpal/Taipei-Torrent 43 | 44 | Complete documentation 45 | ---------------------- 46 | 47 | http://godoc.org/github.com/jackpal/go-nat-pmp 48 | 49 | License 50 | ------- 51 | 52 | This project is licensed under the Apache License 2.0. 53 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/jackpal/go-nat-pmp/network.go: -------------------------------------------------------------------------------- 1 | package natpmp 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "time" 7 | ) 8 | 9 | const nAT_PMP_PORT = 5351 10 | const nAT_TRIES = 9 11 | const nAT_INITIAL_MS = 250 12 | 13 | // A caller that implements the NAT-PMP RPC protocol. 14 | type network struct { 15 | gateway net.IP 16 | } 17 | 18 | func (n *network) call(msg []byte, timeout time.Duration) (result []byte, err error) { 19 | var server net.UDPAddr 20 | server.IP = n.gateway 21 | server.Port = nAT_PMP_PORT 22 | conn, err := net.DialUDP("udp", nil, &server) 23 | if err != nil { 24 | return 25 | } 26 | defer conn.Close() 27 | 28 | // 16 bytes is the maximum result size. 29 | result = make([]byte, 16) 30 | 31 | var finalTimeout time.Time 32 | if timeout != 0 { 33 | finalTimeout = time.Now().Add(timeout) 34 | } 35 | 36 | needNewDeadline := true 37 | 38 | var tries uint 39 | for tries = 0; (tries < nAT_TRIES && finalTimeout.IsZero()) || time.Now().Before(finalTimeout); { 40 | if needNewDeadline { 41 | nextDeadline := time.Now().Add((nAT_INITIAL_MS << tries) * time.Millisecond) 42 | err = conn.SetDeadline(minTime(nextDeadline, finalTimeout)) 43 | if err != nil { 44 | return 45 | } 46 | needNewDeadline = false 47 | } 48 | _, err = conn.Write(msg) 49 | if err != nil { 50 | return 51 | } 52 | var bytesRead int 53 | var remoteAddr *net.UDPAddr 54 | bytesRead, remoteAddr, err = conn.ReadFromUDP(result) 55 | if err != nil { 56 | if err.(net.Error).Timeout() { 57 | tries++ 58 | needNewDeadline = true 59 | continue 60 | } 61 | return 62 | } 63 | if !remoteAddr.IP.Equal(n.gateway) { 64 | // Ignore this packet. 65 | // Continue without increasing retransmission timeout or deadline. 66 | continue 67 | } 68 | // Trim result to actual number of bytes received 69 | if bytesRead < len(result) { 70 | result = result[:bytesRead] 71 | } 72 | return 73 | } 74 | err = fmt.Errorf("Timed out trying to contact gateway") 75 | return 76 | } 77 | 78 | func minTime(a, b time.Time) time.Time { 79 | if a.IsZero() { 80 | return b 81 | } 82 | if b.IsZero() { 83 | return a 84 | } 85 | if a.Before(b) { 86 | return a 87 | } 88 | return b 89 | } 90 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/jackpal/go-nat-pmp/recorder.go: -------------------------------------------------------------------------------- 1 | package natpmp 2 | 3 | import "time" 4 | 5 | type callObserver interface { 6 | observeCall(msg []byte, result []byte, err error) 7 | } 8 | 9 | // A caller that records the RPC call. 10 | type recorder struct { 11 | child caller 12 | observer callObserver 13 | } 14 | 15 | func (n *recorder) call(msg []byte, timeout time.Duration) (result []byte, err error) { 16 | result, err = n.child.call(msg, timeout) 17 | n.observer.observeCall(msg, result, err) 18 | return 19 | } 20 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Richard Crowley. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following 12 | disclaimer in the documentation and/or other materials provided 13 | with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY RICHARD CROWLEY ``AS IS'' AND ANY EXPRESS 16 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL RICHARD CROWLEY OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 25 | THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | The views and conclusions contained in the software and documentation 28 | are those of the authors and should not be interpreted as representing 29 | official policies, either expressed or implied, of Richard Crowley. 30 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics/healthcheck.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | // Healthchecks hold an error value describing an arbitrary up/down status. 4 | type Healthcheck interface { 5 | Check() 6 | Error() error 7 | Healthy() 8 | Unhealthy(error) 9 | } 10 | 11 | // NewHealthcheck constructs a new Healthcheck which will use the given 12 | // function to update its status. 13 | func NewHealthcheck(f func(Healthcheck)) Healthcheck { 14 | if UseNilMetrics { 15 | return NilHealthcheck{} 16 | } 17 | return &StandardHealthcheck{nil, f} 18 | } 19 | 20 | // NilHealthcheck is a no-op. 21 | type NilHealthcheck struct{} 22 | 23 | // Check is a no-op. 24 | func (NilHealthcheck) Check() {} 25 | 26 | // Error is a no-op. 27 | func (NilHealthcheck) Error() error { return nil } 28 | 29 | // Healthy is a no-op. 30 | func (NilHealthcheck) Healthy() {} 31 | 32 | // Unhealthy is a no-op. 33 | func (NilHealthcheck) Unhealthy(error) {} 34 | 35 | // StandardHealthcheck is the standard implementation of a Healthcheck and 36 | // stores the status and a function to call to update the status. 37 | type StandardHealthcheck struct { 38 | err error 39 | f func(Healthcheck) 40 | } 41 | 42 | // Check runs the healthcheck function to update the healthcheck's status. 43 | func (h *StandardHealthcheck) Check() { 44 | h.f(h) 45 | } 46 | 47 | // Error returns the healthcheck's status, which will be nil if it is healthy. 48 | func (h *StandardHealthcheck) Error() error { 49 | return h.err 50 | } 51 | 52 | // Healthy marks the healthcheck as healthy. 53 | func (h *StandardHealthcheck) Healthy() { 54 | h.err = nil 55 | } 56 | 57 | // Unhealthy marks the healthcheck as unhealthy. The error is stored and 58 | // may be retrieved by the Error method. 59 | func (h *StandardHealthcheck) Unhealthy(err error) { 60 | h.err = err 61 | } 62 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics/metrics.go: -------------------------------------------------------------------------------- 1 | // Go port of Coda Hale's Metrics library 2 | // 3 | // 4 | // 5 | // Coda Hale's original work: 6 | package metrics 7 | 8 | // UseNilMetrics is checked by the constructor functions for all of the 9 | // standard metrics. If it is true, the metric returned is a stub. 10 | // 11 | // This global kill-switch helps quantify the observer effect and makes 12 | // for less cluttered pprof profiles. 13 | var UseNilMetrics bool = false 14 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics/runtime_cgo.go: -------------------------------------------------------------------------------- 1 | // +build cgo 2 | // +build !appengine 3 | 4 | package metrics 5 | 6 | import "runtime" 7 | 8 | func numCgoCall() int64 { 9 | return runtime.NumCgoCall() 10 | } 11 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics/runtime_gccpufraction.go: -------------------------------------------------------------------------------- 1 | // +build go1.5 2 | 3 | package metrics 4 | 5 | import "runtime" 6 | 7 | func gcCPUFraction(memStats *runtime.MemStats) float64 { 8 | return memStats.GCCPUFraction 9 | } 10 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics/runtime_no_cgo.go: -------------------------------------------------------------------------------- 1 | // +build !cgo appengine 2 | 3 | package metrics 4 | 5 | func numCgoCall() int64 { 6 | return 0 7 | } 8 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics/runtime_no_gccpufraction.go: -------------------------------------------------------------------------------- 1 | // +build !go1.5 2 | 3 | package metrics 4 | 5 | import "runtime" 6 | 7 | func gcCPUFraction(memStats *runtime.MemStats) float64 { 8 | return 0 9 | } 10 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics/syslog.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package metrics 4 | 5 | import ( 6 | "fmt" 7 | "log/syslog" 8 | "time" 9 | ) 10 | 11 | // Output each metric in the given registry to syslog periodically using 12 | // the given syslogger. 13 | func Syslog(r Registry, d time.Duration, w *syslog.Writer) { 14 | for _ = range time.Tick(d) { 15 | r.Each(func(name string, i interface{}) { 16 | switch metric := i.(type) { 17 | case Counter: 18 | w.Info(fmt.Sprintf("counter %s: count: %d", name, metric.Count())) 19 | case Gauge: 20 | w.Info(fmt.Sprintf("gauge %s: value: %d", name, metric.Value())) 21 | case GaugeFloat64: 22 | w.Info(fmt.Sprintf("gauge %s: value: %f", name, metric.Value())) 23 | case Healthcheck: 24 | metric.Check() 25 | w.Info(fmt.Sprintf("healthcheck %s: error: %v", name, metric.Error())) 26 | case Histogram: 27 | h := metric.Snapshot() 28 | ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999}) 29 | w.Info(fmt.Sprintf( 30 | "histogram %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f", 31 | name, 32 | h.Count(), 33 | h.Min(), 34 | h.Max(), 35 | h.Mean(), 36 | h.StdDev(), 37 | ps[0], 38 | ps[1], 39 | ps[2], 40 | ps[3], 41 | ps[4], 42 | )) 43 | case Meter: 44 | m := metric.Snapshot() 45 | w.Info(fmt.Sprintf( 46 | "meter %s: count: %d 1-min: %.2f 5-min: %.2f 15-min: %.2f mean: %.2f", 47 | name, 48 | m.Count(), 49 | m.Rate1(), 50 | m.Rate5(), 51 | m.Rate15(), 52 | m.RateMean(), 53 | )) 54 | case Timer: 55 | t := metric.Snapshot() 56 | ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999}) 57 | w.Info(fmt.Sprintf( 58 | "timer %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f 1-min: %.2f 5-min: %.2f 15-min: %.2f mean-rate: %.2f", 59 | name, 60 | t.Count(), 61 | t.Min(), 62 | t.Max(), 63 | t.Mean(), 64 | t.StdDev(), 65 | ps[0], 66 | ps[1], 67 | ps[2], 68 | ps[3], 69 | ps[4], 70 | t.Rate1(), 71 | t.Rate5(), 72 | t.Rate15(), 73 | t.RateMean(), 74 | )) 75 | } 76 | }) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics/validate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # check there are no formatting issues 6 | GOFMT_LINES=`gofmt -l . | wc -l | xargs` 7 | test $GOFMT_LINES -eq 0 || echo "gofmt needs to be run, ${GOFMT_LINES} files have issues" 8 | 9 | # run the tests for the root package 10 | go test . 11 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/comparer.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package leveldb 8 | 9 | import ( 10 | "github.com/syndtr/goleveldb/leveldb/comparer" 11 | ) 12 | 13 | type iComparer struct { 14 | ucmp comparer.Comparer 15 | } 16 | 17 | func (icmp *iComparer) uName() string { 18 | return icmp.ucmp.Name() 19 | } 20 | 21 | func (icmp *iComparer) uCompare(a, b []byte) int { 22 | return icmp.ucmp.Compare(a, b) 23 | } 24 | 25 | func (icmp *iComparer) uSeparator(dst, a, b []byte) []byte { 26 | return icmp.ucmp.Separator(dst, a, b) 27 | } 28 | 29 | func (icmp *iComparer) uSuccessor(dst, b []byte) []byte { 30 | return icmp.ucmp.Successor(dst, b) 31 | } 32 | 33 | func (icmp *iComparer) Name() string { 34 | return icmp.uName() 35 | } 36 | 37 | func (icmp *iComparer) Compare(a, b []byte) int { 38 | x := icmp.uCompare(internalKey(a).ukey(), internalKey(b).ukey()) 39 | if x == 0 { 40 | if m, n := internalKey(a).num(), internalKey(b).num(); m > n { 41 | return -1 42 | } else if m < n { 43 | return 1 44 | } 45 | } 46 | return x 47 | } 48 | 49 | func (icmp *iComparer) Separator(dst, a, b []byte) []byte { 50 | ua, ub := internalKey(a).ukey(), internalKey(b).ukey() 51 | dst = icmp.uSeparator(dst, ua, ub) 52 | if dst != nil && len(dst) < len(ua) && icmp.uCompare(ua, dst) < 0 { 53 | // Append earliest possible number. 54 | return append(dst, keyMaxNumBytes...) 55 | } 56 | return nil 57 | } 58 | 59 | func (icmp *iComparer) Successor(dst, b []byte) []byte { 60 | ub := internalKey(b).ukey() 61 | dst = icmp.uSuccessor(dst, ub) 62 | if dst != nil && len(dst) < len(ub) && icmp.uCompare(ub, dst) < 0 { 63 | // Append earliest possible number. 64 | return append(dst, keyMaxNumBytes...) 65 | } 66 | return nil 67 | } 68 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package comparer 8 | 9 | import "bytes" 10 | 11 | type bytesComparer struct{} 12 | 13 | func (bytesComparer) Compare(a, b []byte) int { 14 | return bytes.Compare(a, b) 15 | } 16 | 17 | func (bytesComparer) Name() string { 18 | return "leveldb.BytewiseComparator" 19 | } 20 | 21 | func (bytesComparer) Separator(dst, a, b []byte) []byte { 22 | i, n := 0, len(a) 23 | if n > len(b) { 24 | n = len(b) 25 | } 26 | for ; i < n && a[i] == b[i]; i++ { 27 | } 28 | if i >= n { 29 | // Do not shorten if one string is a prefix of the other 30 | } else if c := a[i]; c < 0xff && c+1 < b[i] { 31 | dst = append(dst, a[:i+1]...) 32 | dst[i]++ 33 | return dst 34 | } 35 | return nil 36 | } 37 | 38 | func (bytesComparer) Successor(dst, b []byte) []byte { 39 | for i, c := range b { 40 | if c != 0xff { 41 | dst = append(dst, b[:i+1]...) 42 | dst[i]++ 43 | return dst 44 | } 45 | } 46 | return nil 47 | } 48 | 49 | // DefaultComparer are default implementation of the Comparer interface. 50 | // It uses the natural ordering, consistent with bytes.Compare. 51 | var DefaultComparer = bytesComparer{} 52 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | // Package comparer provides interface and implementation for ordering 8 | // sets of data. 9 | package comparer 10 | 11 | // BasicComparer is the interface that wraps the basic Compare method. 12 | type BasicComparer interface { 13 | // Compare returns -1, 0, or +1 depending on whether a is 'less than', 14 | // 'equal to' or 'greater than' b. The two arguments can only be 'equal' 15 | // if their contents are exactly equal. Furthermore, the empty slice 16 | // must be 'less than' any non-empty slice. 17 | Compare(a, b []byte) int 18 | } 19 | 20 | // Comparer defines a total ordering over the space of []byte keys: a 'less 21 | // than' relationship. 22 | type Comparer interface { 23 | BasicComparer 24 | 25 | // Name returns name of the comparer. 26 | // 27 | // The Level-DB on-disk format stores the comparer name, and opening a 28 | // database with a different comparer from the one it was created with 29 | // will result in an error. 30 | // 31 | // An implementation to a new name whenever the comparer implementation 32 | // changes in a way that will cause the relative ordering of any two keys 33 | // to change. 34 | // 35 | // Names starting with "leveldb." are reserved and should not be used 36 | // by any users of this package. 37 | Name() string 38 | 39 | // Bellow are advanced functions used used to reduce the space requirements 40 | // for internal data structures such as index blocks. 41 | 42 | // Separator appends a sequence of bytes x to dst such that a <= x && x < b, 43 | // where 'less than' is consistent with Compare. An implementation should 44 | // return nil if x equal to a. 45 | // 46 | // Either contents of a or b should not by any means modified. Doing so 47 | // may cause corruption on the internal state. 48 | Separator(dst, a, b []byte) []byte 49 | 50 | // Successor appends a sequence of bytes x to dst such that x >= b, where 51 | // 'less than' is consistent with Compare. An implementation should return 52 | // nil if x equal to b. 53 | // 54 | // Contents of b should not by any means modified. Doing so may cause 55 | // corruption on the internal state. 56 | Successor(dst, b []byte) []byte 57 | } 58 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package leveldb 8 | 9 | import ( 10 | "github.com/syndtr/goleveldb/leveldb/errors" 11 | ) 12 | 13 | // Common errors. 14 | var ( 15 | ErrNotFound = errors.ErrNotFound 16 | ErrReadOnly = errors.New("leveldb: read-only mode") 17 | ErrSnapshotReleased = errors.New("leveldb: snapshot released") 18 | ErrIterReleased = errors.New("leveldb: iterator released") 19 | ErrClosed = errors.New("leveldb: closed") 20 | ) 21 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/errors/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | // Package errors provides common error types used throughout leveldb. 8 | package errors 9 | 10 | import ( 11 | "errors" 12 | "fmt" 13 | 14 | "github.com/syndtr/goleveldb/leveldb/storage" 15 | "github.com/syndtr/goleveldb/leveldb/util" 16 | ) 17 | 18 | // Common errors. 19 | var ( 20 | ErrNotFound = New("leveldb: not found") 21 | ErrReleased = util.ErrReleased 22 | ErrHasReleaser = util.ErrHasReleaser 23 | ) 24 | 25 | // New returns an error that formats as the given text. 26 | func New(text string) error { 27 | return errors.New(text) 28 | } 29 | 30 | // ErrCorrupted is the type that wraps errors that indicate corruption in 31 | // the database. 32 | type ErrCorrupted struct { 33 | Fd storage.FileDesc 34 | Err error 35 | } 36 | 37 | func (e *ErrCorrupted) Error() string { 38 | if !e.Fd.Zero() { 39 | return fmt.Sprintf("%v [file=%v]", e.Err, e.Fd) 40 | } 41 | return e.Err.Error() 42 | } 43 | 44 | // NewErrCorrupted creates new ErrCorrupted error. 45 | func NewErrCorrupted(fd storage.FileDesc, err error) error { 46 | return &ErrCorrupted{fd, err} 47 | } 48 | 49 | // IsCorrupted returns a boolean indicating whether the error is indicating 50 | // a corruption. 51 | func IsCorrupted(err error) bool { 52 | switch err.(type) { 53 | case *ErrCorrupted: 54 | return true 55 | case *storage.ErrCorrupted: 56 | return true 57 | } 58 | return false 59 | } 60 | 61 | // ErrMissingFiles is the type that indicating a corruption due to missing 62 | // files. ErrMissingFiles always wrapped with ErrCorrupted. 63 | type ErrMissingFiles struct { 64 | Fds []storage.FileDesc 65 | } 66 | 67 | func (e *ErrMissingFiles) Error() string { return "file missing" } 68 | 69 | // SetFd sets 'file info' of the given error with the given file. 70 | // Currently only ErrCorrupted is supported, otherwise will do nothing. 71 | func SetFd(err error, fd storage.FileDesc) error { 72 | switch x := err.(type) { 73 | case *ErrCorrupted: 74 | x.Fd = fd 75 | return x 76 | } 77 | return err 78 | } 79 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/filter.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package leveldb 8 | 9 | import ( 10 | "github.com/syndtr/goleveldb/leveldb/filter" 11 | ) 12 | 13 | type iFilter struct { 14 | filter.Filter 15 | } 16 | 17 | func (f iFilter) Contains(filter, key []byte) bool { 18 | return f.Filter.Contains(filter, internalKey(key).ukey()) 19 | } 20 | 21 | func (f iFilter) NewGenerator() filter.FilterGenerator { 22 | return iFilterGenerator{f.Filter.NewGenerator()} 23 | } 24 | 25 | type iFilterGenerator struct { 26 | filter.FilterGenerator 27 | } 28 | 29 | func (g iFilterGenerator) Add(key []byte) { 30 | g.FilterGenerator.Add(internalKey(key).ukey()) 31 | } 32 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/filter/filter.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | // Package filter provides interface and implementation of probabilistic 8 | // data structure. 9 | // 10 | // The filter is resposible for creating small filter from a set of keys. 11 | // These filter will then used to test whether a key is a member of the set. 12 | // In many cases, a filter can cut down the number of disk seeks from a 13 | // handful to a single disk seek per DB.Get call. 14 | package filter 15 | 16 | // Buffer is the interface that wraps basic Alloc, Write and WriteByte methods. 17 | type Buffer interface { 18 | // Alloc allocs n bytes of slice from the buffer. This also advancing 19 | // write offset. 20 | Alloc(n int) []byte 21 | 22 | // Write appends the contents of p to the buffer. 23 | Write(p []byte) (n int, err error) 24 | 25 | // WriteByte appends the byte c to the buffer. 26 | WriteByte(c byte) error 27 | } 28 | 29 | // Filter is the filter. 30 | type Filter interface { 31 | // Name returns the name of this policy. 32 | // 33 | // Note that if the filter encoding changes in an incompatible way, 34 | // the name returned by this method must be changed. Otherwise, old 35 | // incompatible filters may be passed to methods of this type. 36 | Name() string 37 | 38 | // NewGenerator creates a new filter generator. 39 | NewGenerator() FilterGenerator 40 | 41 | // Contains returns true if the filter contains the given key. 42 | // 43 | // The filter are filters generated by the filter generator. 44 | Contains(filter, key []byte) bool 45 | } 46 | 47 | // FilterGenerator is the filter generator. 48 | type FilterGenerator interface { 49 | // Add adds a key to the filter generator. 50 | // 51 | // The key may become invalid after call to this method end, therefor 52 | // key must be copied if implementation require keeping key for later 53 | // use. The key should not modified directly, doing so may cause 54 | // undefined results. 55 | Add(key []byte) 56 | 57 | // Generate generates filters based on keys passed so far. After call 58 | // to Generate the filter generator maybe resetted, depends on implementation. 59 | Generate(b Buffer) 60 | } 61 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_nacl.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | // +build nacl 8 | 9 | package storage 10 | 11 | import ( 12 | "os" 13 | "syscall" 14 | ) 15 | 16 | func newFileLock(path string, readOnly bool) (fl fileLock, err error) { 17 | return nil, syscall.ENOTSUP 18 | } 19 | 20 | func setFileLock(f *os.File, readOnly, lock bool) error { 21 | return syscall.ENOTSUP 22 | } 23 | 24 | func rename(oldpath, newpath string) error { 25 | return syscall.ENOTSUP 26 | } 27 | 28 | func isErrInvalid(err error) bool { 29 | return false 30 | } 31 | 32 | func syncDir(name string) error { 33 | return syscall.ENOTSUP 34 | } 35 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package storage 8 | 9 | import ( 10 | "os" 11 | "path/filepath" 12 | ) 13 | 14 | type plan9FileLock struct { 15 | f *os.File 16 | } 17 | 18 | func (fl *plan9FileLock) release() error { 19 | return fl.f.Close() 20 | } 21 | 22 | func newFileLock(path string, readOnly bool) (fl fileLock, err error) { 23 | var ( 24 | flag int 25 | perm os.FileMode 26 | ) 27 | if readOnly { 28 | flag = os.O_RDONLY 29 | } else { 30 | flag = os.O_RDWR 31 | perm = os.ModeExclusive 32 | } 33 | f, err := os.OpenFile(path, flag, perm) 34 | if os.IsNotExist(err) { 35 | f, err = os.OpenFile(path, flag|os.O_CREATE, perm|0644) 36 | } 37 | if err != nil { 38 | return 39 | } 40 | fl = &plan9FileLock{f: f} 41 | return 42 | } 43 | 44 | func rename(oldpath, newpath string) error { 45 | if _, err := os.Stat(newpath); err == nil { 46 | if err := os.Remove(newpath); err != nil { 47 | return err 48 | } 49 | } 50 | 51 | _, fname := filepath.Split(newpath) 52 | return os.Rename(oldpath, fname) 53 | } 54 | 55 | func syncDir(name string) error { 56 | f, err := os.Open(name) 57 | if err != nil { 58 | return err 59 | } 60 | defer f.Close() 61 | if err := f.Sync(); err != nil { 62 | return err 63 | } 64 | return nil 65 | } 66 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | // +build solaris 8 | 9 | package storage 10 | 11 | import ( 12 | "os" 13 | "syscall" 14 | ) 15 | 16 | type unixFileLock struct { 17 | f *os.File 18 | } 19 | 20 | func (fl *unixFileLock) release() error { 21 | if err := setFileLock(fl.f, false, false); err != nil { 22 | return err 23 | } 24 | return fl.f.Close() 25 | } 26 | 27 | func newFileLock(path string, readOnly bool) (fl fileLock, err error) { 28 | var flag int 29 | if readOnly { 30 | flag = os.O_RDONLY 31 | } else { 32 | flag = os.O_RDWR 33 | } 34 | f, err := os.OpenFile(path, flag, 0) 35 | if os.IsNotExist(err) { 36 | f, err = os.OpenFile(path, flag|os.O_CREATE, 0644) 37 | } 38 | if err != nil { 39 | return 40 | } 41 | err = setFileLock(f, readOnly, true) 42 | if err != nil { 43 | f.Close() 44 | return 45 | } 46 | fl = &unixFileLock{f: f} 47 | return 48 | } 49 | 50 | func setFileLock(f *os.File, readOnly, lock bool) error { 51 | flock := syscall.Flock_t{ 52 | Type: syscall.F_UNLCK, 53 | Start: 0, 54 | Len: 0, 55 | Whence: 1, 56 | } 57 | if lock { 58 | if readOnly { 59 | flock.Type = syscall.F_RDLCK 60 | } else { 61 | flock.Type = syscall.F_WRLCK 62 | } 63 | } 64 | return syscall.FcntlFlock(f.Fd(), syscall.F_SETLK, &flock) 65 | } 66 | 67 | func rename(oldpath, newpath string) error { 68 | return os.Rename(oldpath, newpath) 69 | } 70 | 71 | func syncDir(name string) error { 72 | f, err := os.Open(name) 73 | if err != nil { 74 | return err 75 | } 76 | defer f.Close() 77 | if err := f.Sync(); err != nil { 78 | return err 79 | } 80 | return nil 81 | } 82 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package storage 10 | 11 | import ( 12 | "os" 13 | "syscall" 14 | ) 15 | 16 | type unixFileLock struct { 17 | f *os.File 18 | } 19 | 20 | func (fl *unixFileLock) release() error { 21 | if err := setFileLock(fl.f, false, false); err != nil { 22 | return err 23 | } 24 | return fl.f.Close() 25 | } 26 | 27 | func newFileLock(path string, readOnly bool) (fl fileLock, err error) { 28 | var flag int 29 | if readOnly { 30 | flag = os.O_RDONLY 31 | } else { 32 | flag = os.O_RDWR 33 | } 34 | f, err := os.OpenFile(path, flag, 0) 35 | if os.IsNotExist(err) { 36 | f, err = os.OpenFile(path, flag|os.O_CREATE, 0644) 37 | } 38 | if err != nil { 39 | return 40 | } 41 | err = setFileLock(f, readOnly, true) 42 | if err != nil { 43 | f.Close() 44 | return 45 | } 46 | fl = &unixFileLock{f: f} 47 | return 48 | } 49 | 50 | func setFileLock(f *os.File, readOnly, lock bool) error { 51 | how := syscall.LOCK_UN 52 | if lock { 53 | if readOnly { 54 | how = syscall.LOCK_SH 55 | } else { 56 | how = syscall.LOCK_EX 57 | } 58 | } 59 | return syscall.Flock(int(f.Fd()), how|syscall.LOCK_NB) 60 | } 61 | 62 | func rename(oldpath, newpath string) error { 63 | return os.Rename(oldpath, newpath) 64 | } 65 | 66 | func isErrInvalid(err error) bool { 67 | if err == os.ErrInvalid { 68 | return true 69 | } 70 | if syserr, ok := err.(*os.SyscallError); ok && syserr.Err == syscall.EINVAL { 71 | return true 72 | } 73 | return false 74 | } 75 | 76 | func syncDir(name string) error { 77 | f, err := os.Open(name) 78 | if err != nil { 79 | return err 80 | } 81 | defer f.Close() 82 | if err := f.Sync(); err != nil && !isErrInvalid(err) { 83 | return err 84 | } 85 | return nil 86 | } 87 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package storage 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | var ( 15 | modkernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | procMoveFileExW = modkernel32.NewProc("MoveFileExW") 18 | ) 19 | 20 | const ( 21 | _MOVEFILE_REPLACE_EXISTING = 1 22 | ) 23 | 24 | type windowsFileLock struct { 25 | fd syscall.Handle 26 | } 27 | 28 | func (fl *windowsFileLock) release() error { 29 | return syscall.Close(fl.fd) 30 | } 31 | 32 | func newFileLock(path string, readOnly bool) (fl fileLock, err error) { 33 | pathp, err := syscall.UTF16PtrFromString(path) 34 | if err != nil { 35 | return 36 | } 37 | var access, shareMode uint32 38 | if readOnly { 39 | access = syscall.GENERIC_READ 40 | shareMode = syscall.FILE_SHARE_READ 41 | } else { 42 | access = syscall.GENERIC_READ | syscall.GENERIC_WRITE 43 | } 44 | fd, err := syscall.CreateFile(pathp, access, shareMode, nil, syscall.OPEN_EXISTING, syscall.FILE_ATTRIBUTE_NORMAL, 0) 45 | if err == syscall.ERROR_FILE_NOT_FOUND { 46 | fd, err = syscall.CreateFile(pathp, access, shareMode, nil, syscall.OPEN_ALWAYS, syscall.FILE_ATTRIBUTE_NORMAL, 0) 47 | } 48 | if err != nil { 49 | return 50 | } 51 | fl = &windowsFileLock{fd: fd} 52 | return 53 | } 54 | 55 | func moveFileEx(from *uint16, to *uint16, flags uint32) error { 56 | r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags)) 57 | if r1 == 0 { 58 | if e1 != 0 { 59 | return error(e1) 60 | } 61 | return syscall.EINVAL 62 | } 63 | return nil 64 | } 65 | 66 | func rename(oldpath, newpath string) error { 67 | from, err := syscall.UTF16PtrFromString(oldpath) 68 | if err != nil { 69 | return err 70 | } 71 | to, err := syscall.UTF16PtrFromString(newpath) 72 | if err != nil { 73 | return err 74 | } 75 | return moveFileEx(from, to, _MOVEFILE_REPLACE_EXISTING) 76 | } 77 | 78 | func syncDir(name string) error { return nil } 79 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/util.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package leveldb 8 | 9 | import ( 10 | "fmt" 11 | "sort" 12 | 13 | "github.com/syndtr/goleveldb/leveldb/storage" 14 | ) 15 | 16 | func shorten(str string) string { 17 | if len(str) <= 8 { 18 | return str 19 | } 20 | return str[:3] + ".." + str[len(str)-3:] 21 | } 22 | 23 | var bunits = [...]string{"", "Ki", "Mi", "Gi"} 24 | 25 | func shortenb(bytes int) string { 26 | i := 0 27 | for ; bytes > 1024 && i < 4; i++ { 28 | bytes /= 1024 29 | } 30 | return fmt.Sprintf("%d%sB", bytes, bunits[i]) 31 | } 32 | 33 | func sshortenb(bytes int) string { 34 | if bytes == 0 { 35 | return "~" 36 | } 37 | sign := "+" 38 | if bytes < 0 { 39 | sign = "-" 40 | bytes *= -1 41 | } 42 | i := 0 43 | for ; bytes > 1024 && i < 4; i++ { 44 | bytes /= 1024 45 | } 46 | return fmt.Sprintf("%s%d%sB", sign, bytes, bunits[i]) 47 | } 48 | 49 | func sint(x int) string { 50 | if x == 0 { 51 | return "~" 52 | } 53 | sign := "+" 54 | if x < 0 { 55 | sign = "-" 56 | x *= -1 57 | } 58 | return fmt.Sprintf("%s%d", sign, x) 59 | } 60 | 61 | func minInt(a, b int) int { 62 | if a < b { 63 | return a 64 | } 65 | return b 66 | } 67 | 68 | func maxInt(a, b int) int { 69 | if a > b { 70 | return a 71 | } 72 | return b 73 | } 74 | 75 | type fdSorter []storage.FileDesc 76 | 77 | func (p fdSorter) Len() int { 78 | return len(p) 79 | } 80 | 81 | func (p fdSorter) Less(i, j int) bool { 82 | return p[i].Num < p[j].Num 83 | } 84 | 85 | func (p fdSorter) Swap(i, j int) { 86 | p[i], p[j] = p[j], p[i] 87 | } 88 | 89 | func sortFds(fds []storage.FileDesc) { 90 | sort.Sort(fdSorter(fds)) 91 | } 92 | 93 | func ensureBuffer(b []byte, n int) []byte { 94 | if cap(b) < n { 95 | return make([]byte, n) 96 | } 97 | return b[:n] 98 | } 99 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/util/crc32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The LevelDB-Go Authors. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license that can be 4 | // found in the LICENSE file. 5 | 6 | package util 7 | 8 | import ( 9 | "hash/crc32" 10 | ) 11 | 12 | var table = crc32.MakeTable(crc32.Castagnoli) 13 | 14 | // CRC is a CRC-32 checksum computed using Castagnoli's polynomial. 15 | type CRC uint32 16 | 17 | // NewCRC creates a new crc based on the given bytes. 18 | func NewCRC(b []byte) CRC { 19 | return CRC(0).Update(b) 20 | } 21 | 22 | // Update updates the crc with the given bytes. 23 | func (c CRC) Update(b []byte) CRC { 24 | return CRC(crc32.Update(uint32(c), table, b)) 25 | } 26 | 27 | // Value returns a masked crc. 28 | func (c CRC) Value() uint32 { 29 | return uint32(c>>15|c<<17) + 0xa282ead8 30 | } 31 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package util 8 | 9 | import ( 10 | "encoding/binary" 11 | ) 12 | 13 | // Hash return hash of the given data. 14 | func Hash(data []byte, seed uint32) uint32 { 15 | // Similar to murmur hash 16 | const ( 17 | m = uint32(0xc6a4a793) 18 | r = uint32(24) 19 | ) 20 | var ( 21 | h = seed ^ (uint32(len(data)) * m) 22 | i int 23 | ) 24 | 25 | for n := len(data) - len(data)%4; i < n; i += 4 { 26 | h += binary.LittleEndian.Uint32(data[i:]) 27 | h *= m 28 | h ^= (h >> 16) 29 | } 30 | 31 | switch len(data) - i { 32 | default: 33 | panic("not reached") 34 | case 3: 35 | h += uint32(data[i+2]) << 16 36 | fallthrough 37 | case 2: 38 | h += uint32(data[i+1]) << 8 39 | fallthrough 40 | case 1: 41 | h += uint32(data[i]) 42 | h *= m 43 | h ^= (h >> r) 44 | case 0: 45 | } 46 | 47 | return h 48 | } 49 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/util/range.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package util 8 | 9 | // Range is a key range. 10 | type Range struct { 11 | // Start of the key range, include in the range. 12 | Start []byte 13 | 14 | // Limit of the key range, not include in the range. 15 | Limit []byte 16 | } 17 | 18 | // BytesPrefix returns key range that satisfy the given prefix. 19 | // This only applicable for the standard 'bytes comparer'. 20 | func BytesPrefix(prefix []byte) *Range { 21 | var limit []byte 22 | for i := len(prefix) - 1; i >= 0; i-- { 23 | c := prefix[i] 24 | if c < 0xff { 25 | limit = make([]byte, i+1) 26 | copy(limit, prefix) 27 | limit[i] = c + 1 28 | break 29 | } 30 | } 31 | return &Range{prefix, limit} 32 | } 33 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/util/util.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | // Package util provides utilities used throughout leveldb. 8 | package util 9 | 10 | import ( 11 | "errors" 12 | ) 13 | 14 | var ( 15 | ErrReleased = errors.New("leveldb: resource already relesed") 16 | ErrHasReleaser = errors.New("leveldb: releaser already defined") 17 | ) 18 | 19 | // Releaser is the interface that wraps the basic Release method. 20 | type Releaser interface { 21 | // Release releases associated resources. Release should always success 22 | // and can be called multipe times without causing error. 23 | Release() 24 | } 25 | 26 | // ReleaseSetter is the interface that wraps the basic SetReleaser method. 27 | type ReleaseSetter interface { 28 | // SetReleaser associates the given releaser to the resources. The 29 | // releaser will be called once coresponding resources released. 30 | // Calling SetReleaser with nil will clear the releaser. 31 | // 32 | // This will panic if a releaser already present or coresponding 33 | // resource is already released. Releaser should be cleared first 34 | // before assigned a new one. 35 | SetReleaser(releaser Releaser) 36 | } 37 | 38 | // BasicReleaser provides basic implementation of Releaser and ReleaseSetter. 39 | type BasicReleaser struct { 40 | releaser Releaser 41 | released bool 42 | } 43 | 44 | // Released returns whether Release method already called. 45 | func (r *BasicReleaser) Released() bool { 46 | return r.released 47 | } 48 | 49 | // Release implements Releaser.Release. 50 | func (r *BasicReleaser) Release() { 51 | if !r.released { 52 | if r.releaser != nil { 53 | r.releaser.Release() 54 | r.releaser = nil 55 | } 56 | r.released = true 57 | } 58 | } 59 | 60 | // SetReleaser implements ReleaseSetter.SetReleaser. 61 | func (r *BasicReleaser) SetReleaser(releaser Releaser) { 62 | if r.released { 63 | panic(ErrReleased) 64 | } 65 | if r.releaser != nil && releaser != nil { 66 | panic(ErrHasReleaser) 67 | } 68 | r.releaser = releaser 69 | } 70 | 71 | type NoopReleaser struct{} 72 | 73 | func (NoopReleaser) Release() {} 74 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/internal/internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package internal contains code that is shared among encoding implementations. 6 | package internal 7 | 8 | import ( 9 | "golang.org/x/text/encoding" 10 | "golang.org/x/text/encoding/internal/identifier" 11 | "golang.org/x/text/transform" 12 | ) 13 | 14 | // Encoding is an implementation of the Encoding interface that adds the String 15 | // and ID methods to an existing encoding. 16 | type Encoding struct { 17 | encoding.Encoding 18 | Name string 19 | MIB identifier.MIB 20 | } 21 | 22 | // _ verifies that Encoding implements identifier.Interface. 23 | var _ identifier.Interface = (*Encoding)(nil) 24 | 25 | func (e *Encoding) String() string { 26 | return e.Name 27 | } 28 | 29 | func (e *Encoding) ID() (mib identifier.MIB, other string) { 30 | return e.MIB, "" 31 | } 32 | 33 | // SimpleEncoding is an Encoding that combines two Transformers. 34 | type SimpleEncoding struct { 35 | Decoder transform.Transformer 36 | Encoder transform.Transformer 37 | } 38 | 39 | func (e *SimpleEncoding) NewDecoder() *encoding.Decoder { 40 | return &encoding.Decoder{Transformer: e.Decoder} 41 | } 42 | 43 | func (e *SimpleEncoding) NewEncoder() *encoding.Encoder { 44 | return &encoding.Encoder{Transformer: e.Encoder} 45 | } 46 | 47 | // FuncEncoding is an Encoding that combines two functions returning a new 48 | // Transformer. 49 | type FuncEncoding struct { 50 | Decoder func() transform.Transformer 51 | Encoder func() transform.Transformer 52 | } 53 | 54 | func (e FuncEncoding) NewDecoder() *encoding.Decoder { 55 | return &encoding.Decoder{Transformer: e.Decoder()} 56 | } 57 | 58 | func (e FuncEncoding) NewEncoder() *encoding.Encoder { 59 | return &encoding.Encoder{Transformer: e.Encoder()} 60 | } 61 | 62 | // A RepertoireError indicates a rune is not in the repertoire of a destination 63 | // encoding. It is associated with an encoding-specific suggested replacement 64 | // byte. 65 | type RepertoireError byte 66 | 67 | // Error implements the error interrface. 68 | func (r RepertoireError) Error() string { 69 | return "encoding: rune not supported by encoding." 70 | } 71 | 72 | // Replacement returns the replacement string associated with this error. 73 | func (r RepertoireError) Replacement() byte { return byte(r) } 74 | 75 | var ErrASCIIReplacement = RepertoireError(encoding.ASCIISub) 76 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/japanese/all.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package japanese 6 | 7 | import ( 8 | "golang.org/x/text/encoding" 9 | ) 10 | 11 | // All is a list of all defined encodings in this package. 12 | var All = []encoding.Encoding{EUCJP, ISO2022JP, ShiftJIS} 13 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/simplifiedchinese/all.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package simplifiedchinese 6 | 7 | import ( 8 | "golang.org/x/text/encoding" 9 | ) 10 | 11 | // All is a list of all defined encodings in this package. 12 | var All = []encoding.Encoding{GB18030, GBK, HZGB2312} 13 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/golang.org/x/text/language/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | CLEANFILES+=maketables 6 | 7 | maketables: maketables.go 8 | go build $^ 9 | 10 | tables: maketables 11 | ./maketables > tables.go 12 | gofmt -w -s tables.go 13 | 14 | # Build (but do not run) maketables during testing, 15 | # just to make sure it still compiles. 16 | testshort: maketables 17 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/golang.org/x/text/language/common.go: -------------------------------------------------------------------------------- 1 | // This file was generated by go generate; DO NOT EDIT 2 | 3 | package language 4 | 5 | // This file contains code common to the maketables.go and the package code. 6 | 7 | // langAliasType is the type of an alias in langAliasMap. 8 | type langAliasType int8 9 | 10 | const ( 11 | langDeprecated langAliasType = iota 12 | langMacro 13 | langLegacy 14 | 15 | langAliasTypeUnknown langAliasType = -1 16 | ) 17 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/golang.org/x/text/language/gen_common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | // This file contains code common to the maketables.go and the package code. 10 | 11 | // langAliasType is the type of an alias in langAliasMap. 12 | type langAliasType int8 13 | 14 | const ( 15 | langDeprecated langAliasType = iota 16 | langMacro 17 | langLegacy 18 | 19 | langAliasTypeUnknown langAliasType = -1 20 | ) 21 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/golang.org/x/text/language/go1_1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.2 6 | 7 | package language 8 | 9 | import "sort" 10 | 11 | func sortStable(s sort.Interface) { 12 | ss := stableSort{ 13 | s: s, 14 | pos: make([]int, s.Len()), 15 | } 16 | for i := range ss.pos { 17 | ss.pos[i] = i 18 | } 19 | sort.Sort(&ss) 20 | } 21 | 22 | type stableSort struct { 23 | s sort.Interface 24 | pos []int 25 | } 26 | 27 | func (s *stableSort) Len() int { 28 | return len(s.pos) 29 | } 30 | 31 | func (s *stableSort) Less(i, j int) bool { 32 | return s.s.Less(i, j) || !s.s.Less(j, i) && s.pos[i] < s.pos[j] 33 | } 34 | 35 | func (s *stableSort) Swap(i, j int) { 36 | s.s.Swap(i, j) 37 | s.pos[i], s.pos[j] = s.pos[j], s.pos[i] 38 | } 39 | -------------------------------------------------------------------------------- /myp2p/Godeps/_workspace/src/github.com/ethereum/go-ethereum/vendor/golang.org/x/text/language/go1_2.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.2 6 | 7 | package language 8 | 9 | import "sort" 10 | 11 | var sortStable = sort.Stable 12 | -------------------------------------------------------------------------------- /myp2p/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/ethereum/go-ethereum/crypto" 6 | "github.com/ethereum/go-ethereum/p2p" 7 | "github.com/ethereum/go-ethereum/p2p/discover" 8 | "log" 9 | "net" 10 | "os" 11 | "time" 12 | ) 13 | 14 | const messageId = 0 15 | 16 | type Message string 17 | 18 | var server *p2p.Server 19 | 20 | func MyProtocol() p2p.Protocol { 21 | return p2p.Protocol{ 22 | Name: "MyProtocol", 23 | Version: 1, 24 | Length: 1, 25 | Run: msgHandler, 26 | } 27 | } 28 | 29 | func main() { 30 | nodekey, _ := crypto.GenerateKey() 31 | srv := p2p.Server{ 32 | Config: p2p.Config{ 33 | MaxPeers: 10, 34 | PrivateKey: nodekey, 35 | Name: "my node name", 36 | ListenAddr: ":30300", 37 | Protocols: []p2p.Protocol{MyProtocol()}, 38 | BootstrapNodes: []*discover.Node{ 39 | &discover.Node{ 40 | IP: net.ParseIP("120.27.209.161"), 41 | UDP: 30300, 42 | TCP: 30300, 43 | ID: discover.MustHexID("4a140114efb9f4e74ee3cbbc94e8d7935f832a7434acf02ec9b1835e35f72b00be378a309736ae83ed01692f0b158b1de9462f04c8f4b686b4507ca10b3887e6"), 44 | }, 45 | }, 46 | }, 47 | } 48 | server = &srv 49 | if err := srv.Start(); err != nil { 50 | fmt.Println(err) 51 | os.Exit(1) 52 | } 53 | fmt.Println("started..", srv.NodeInfo()) 54 | select {} 55 | } 56 | 57 | func msgHandler(peer *p2p.Peer, ws p2p.MsgReadWriter) error { 58 | fmt.Println(peer, " in,total peers:", server.PeerCount()) 59 | fmt.Println(p2p.SendItems(ws, messageId, peer.String())) 60 | for { 61 | msg, err := ws.ReadMsg() 62 | if err != nil { 63 | return err 64 | } 65 | 66 | var myMessage [1]Message 67 | err = msg.Decode(&myMessage) 68 | if err != nil { 69 | // handle decode error 70 | continue 71 | } 72 | 73 | fmt.Println("code:", msg.Code, "receiver at:", msg.ReceivedAt, "msg:", myMessage) 74 | switch myMessage[0] { 75 | case "foo": 76 | err := p2p.SendItems(ws, messageId, "bar") 77 | if err != nil { 78 | return err 79 | } 80 | default: 81 | fmt.Println("recv:", myMessage) 82 | } 83 | } 84 | } 85 | 86 | func startPeer(serverAddr string) { 87 | conn, err := net.DialTimeout("tcp", serverAddr, 5*time.Second) 88 | if err != nil { 89 | log.Fatalln(err) 90 | } 91 | defer conn.Close() 92 | log.Println("peer ok") 93 | time.Sleep(5 * time.Minute) 94 | } 95 | -------------------------------------------------------------------------------- /peers/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net" 7 | "os" 8 | "strconv" 9 | "strings" 10 | "time" 11 | ) 12 | 13 | var tag string 14 | 15 | const HAND_SHAKE_MSG = "我是打洞消息" 16 | 17 | func main() { 18 | // 当前进程标记字符串,便于显示 19 | tag = os.Args[1] 20 | srcAddr := &net.UDPAddr{IP: net.IPv4zero, Port: 9982} // 注意端口必须固定 21 | dstAddr := &net.UDPAddr{IP: net.ParseIP("207.148.70.129"), Port: 9981} 22 | conn, err := net.DialUDP("udp", srcAddr, dstAddr) 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | if _, err = conn.Write([]byte("hello, I'm new peer:" + tag)); err != nil { 27 | log.Panic(err) 28 | } 29 | data := make([]byte, 1024) 30 | n, remoteAddr, err := conn.ReadFromUDP(data) 31 | if err != nil { 32 | fmt.Printf("error during read: %s", err) 33 | } 34 | conn.Close() 35 | anotherPeer := parseAddr(string(data[:n])) 36 | fmt.Printf("local:%s server:%s another:%s\n", srcAddr, remoteAddr, anotherPeer.String()) 37 | 38 | // 开始打洞 39 | bidirectionHole(srcAddr, &anotherPeer) 40 | 41 | } 42 | 43 | func parseAddr(addr string) net.UDPAddr { 44 | t := strings.Split(addr, ":") 45 | port, _ := strconv.Atoi(t[1]) 46 | return net.UDPAddr{ 47 | IP: net.ParseIP(t[0]), 48 | Port: port, 49 | } 50 | } 51 | 52 | func bidirectionHole(srcAddr *net.UDPAddr, anotherAddr *net.UDPAddr) { 53 | conn, err := net.DialUDP("udp", srcAddr, anotherAddr) 54 | if err != nil { 55 | fmt.Println(err) 56 | } 57 | defer conn.Close() 58 | // 向另一个peer发送一条udp消息(对方peer的nat设备会丢弃该消息,非法来源),用意是在自身的nat设备打开一条可进入的通道,这样对方peer就可以发过来udp消息 59 | if _, err = conn.Write([]byte(HAND_SHAKE_MSG)); err != nil { 60 | log.Println("send handshake:", err) 61 | } 62 | go func() { 63 | for { 64 | time.Sleep(10 * time.Second) 65 | if _, err = conn.Write([]byte("from [" + tag + "]")); err != nil { 66 | log.Println("send msg fail", err) 67 | } 68 | } 69 | }() 70 | for { 71 | data := make([]byte, 1024) 72 | n, _, err := conn.ReadFromUDP(data) 73 | if err != nil { 74 | log.Printf("error during read: %s\n", err) 75 | } else { 76 | log.Printf("收到数据:%s\n", data[:n]) 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net" 7 | "time" 8 | ) 9 | 10 | func main() { 11 | listener, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4zero, Port: 9981}) 12 | if err != nil { 13 | fmt.Println(err) 14 | return 15 | } 16 | log.Printf("本地地址: <%s> \n", listener.LocalAddr().String()) 17 | peers := make([]net.UDPAddr, 0, 2) 18 | data := make([]byte, 1024) 19 | for { 20 | n, remoteAddr, err := listener.ReadFromUDP(data) 21 | if err != nil { 22 | fmt.Printf("error during read: %s", err) 23 | } 24 | log.Printf("<%s> %s\n", remoteAddr.String(), data[:n]) 25 | peers = append(peers, *remoteAddr) 26 | if len(peers) == 2 { 27 | 28 | log.Printf("进行UDP打洞,建立 %s <--> %s 的连接\n", peers[0].String(), peers[1].String()) 29 | listener.WriteToUDP([]byte(peers[1].String()), &peers[0]) 30 | listener.WriteToUDP([]byte(peers[0].String()), &peers[1]) 31 | time.Sleep(time.Second * 8) 32 | log.Println("中转服务器退出,仍不影响peers间通信") 33 | return 34 | } 35 | } 36 | } 37 | --------------------------------------------------------------------------------