diff options
author | obscuren <geffobscura@gmail.com> | 2014-02-19 18:40:02 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-02-19 18:40:02 +0800 |
commit | 0936e5ccf5c8fc842cbd135c02a6abcd009b4e7f (patch) | |
tree | 9c867dbb5061be01bb040f9bafcf12236679383e | |
parent | 24f2b2afc3a848190822c382e6aa31c8ab120f07 (diff) | |
parent | 531b3a96ebc408c00f67cee00ebe7fe192bf0b8c (diff) | |
download | go-tangerine-0936e5ccf5c8fc842cbd135c02a6abcd009b4e7f.tar go-tangerine-0936e5ccf5c8fc842cbd135c02a6abcd009b4e7f.tar.gz go-tangerine-0936e5ccf5c8fc842cbd135c02a6abcd009b4e7f.tar.bz2 go-tangerine-0936e5ccf5c8fc842cbd135c02a6abcd009b4e7f.tar.lz go-tangerine-0936e5ccf5c8fc842cbd135c02a6abcd009b4e7f.tar.xz go-tangerine-0936e5ccf5c8fc842cbd135c02a6abcd009b4e7f.tar.zst go-tangerine-0936e5ccf5c8fc842cbd135c02a6abcd009b4e7f.zip |
Merge branch 'develop' of github.com-obscure:ethereum/eth-go into develop
Conflicts:
ethutil/config.go
-rw-r--r-- | ethchain/genesis.go | 4 | ||||
-rw-r--r-- | ethutil/config.go | 2 | ||||
-rw-r--r-- | ethutil/encoding_test.go | 30 | ||||
-rw-r--r-- | ethwire/messaging.go | 3 | ||||
-rw-r--r-- | peer.go | 12 |
5 files changed, 43 insertions, 8 deletions
diff --git a/ethchain/genesis.go b/ethchain/genesis.go index 060d347e4..935978a69 100644 --- a/ethchain/genesis.go +++ b/ethchain/genesis.go @@ -13,7 +13,7 @@ var ZeroHash256 = make([]byte, 32) var ZeroHash160 = make([]byte, 20) var EmptyShaList = ethutil.Sha3Bin(ethutil.Encode([]interface{}{})) -var GenisisHeader = []interface{}{ +var GenesisHeader = []interface{}{ // Previous hash (none) //"", ZeroHash256, @@ -36,4 +36,4 @@ var GenisisHeader = []interface{}{ ethutil.Sha3Bin(big.NewInt(42).Bytes()), } -var Genesis = []interface{}{GenisisHeader, []interface{}{}, []interface{}{}} +var Genesis = []interface{}{GenesisHeader, []interface{}{}, []interface{}{}} diff --git a/ethutil/config.go b/ethutil/config.go index 70553fb5b..e61c347de 100644 --- a/ethutil/config.go +++ b/ethutil/config.go @@ -39,7 +39,7 @@ func ReadConfig(base string) *config { _, err := os.Stat(path) if err != nil { if os.IsNotExist(err) { - log.Printf("Debug logging directory %s doesn't exist, creating it", path) + log.Printf("Debug logging directory %s doesn't exist, creating it\n", path) os.Mkdir(path, 0777) } } diff --git a/ethutil/encoding_test.go b/ethutil/encoding_test.go index bcabab0b1..cbfbc0eaf 100644 --- a/ethutil/encoding_test.go +++ b/ethutil/encoding_test.go @@ -35,3 +35,33 @@ func TestCompactHexDecode(t *testing.T) { t.Error("Error compact hex decode. Expected", exp, "got", res) } } + +func TestCompactDecode(t *testing.T) { + exp := []int{1, 2, 3, 4, 5} + res := CompactDecode("\x11\x23\x45") + + if !CompareIntSlice(res, exp) { + t.Error("odd compact decode. Expected", exp, "got", res) + } + + exp = []int{0, 1, 2, 3, 4, 5} + res = CompactDecode("\x00\x01\x23\x45") + + if !CompareIntSlice(res, exp) { + t.Error("even compact decode. Expected", exp, "got", res) + } + + exp = []int{0, 15, 1, 12, 11, 8 /*term*/, 16} + res = CompactDecode("\x20\x0f\x1c\xb8") + + if !CompareIntSlice(res, exp) { + t.Error("even terminated compact decode. Expected", exp, "got", res) + } + + exp = []int{15, 1, 12, 11, 8 /*term*/, 16} + res = CompactDecode("\x3f\x1c\xb8") + + if !CompareIntSlice(res, exp) { + t.Error("even terminated compact decode. Expected", exp, "got", res) + } +}
\ No newline at end of file diff --git a/ethwire/messaging.go b/ethwire/messaging.go index 651bf4710..185faa341 100644 --- a/ethwire/messaging.go +++ b/ethwire/messaging.go @@ -19,6 +19,9 @@ var MagicToken = []byte{34, 64, 8, 145} type MsgType byte const ( + // Values are given explicitly instead of by iota because these values are + // defined by the wire protocol spec; it is easier for humans to ensure + // correctness when values are explicit. MsgHandshakeTy = 0x00 MsgDiscTy = 0x01 MsgPingTy = 0x02 @@ -23,6 +23,9 @@ const ( type DiscReason byte const ( + // Values are given explicitly instead of by iota because these values are + // defined by the wire protocol spec; it is easier for humans to ensure + // correctness when values are explicit. DiscReRequested = 0x00 DiscReTcpSysErr = 0x01 DiscBadProto = 0x02 @@ -56,9 +59,9 @@ func (d DiscReason) String() string { type Caps byte const ( - CapPeerDiscTy = 0x01 - CapTxTy = 0x02 - CapChainTy = 0x04 + CapPeerDiscTy = 1 << iota + CapTxTy + CapChainTy CapDefault = CapChainTy | CapTxTy | CapPeerDiscTy ) @@ -285,7 +288,6 @@ func (p *Peer) HandleInbound() { p.lastPong = time.Now().Unix() case ethwire.MsgBlockTy: // Get all blocks and process them - msg.Data = msg.Data var block, lastBlock *ethchain.Block var err error for i := msg.Data.Len() - 1; i >= 0; i-- { @@ -438,7 +440,7 @@ func (p *Peer) Start() { err := p.pushHandshake() if err != nil { - log.Printf("Peer can't send outbound version ack", err) + log.Println("Peer can't send outbound version ack", err) p.Stop() |