diff --git a/cmd/ethereum/cmd.go b/cmd/ethereum/cmd.go index d8b9ea4875..8ffd868ed0 100644 --- a/cmd/ethereum/cmd.go +++ b/cmd/ethereum/cmd.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import ( diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 275fcf248c..57e5d8b8c1 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import ( diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 3c143aca10..481914aead 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import ( diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go index 96ef94e401..05e99564c1 100644 --- a/cmd/ethtest/main.go +++ b/cmd/ethtest/main.go @@ -17,8 +17,6 @@ /** * @authors: * Jeffrey Wilcke - * @date 2014 - * */ package main diff --git a/cmd/evm/main.go b/cmd/evm/main.go index 31b7da3c82..f902c99e51 100644 --- a/cmd/evm/main.go +++ b/cmd/evm/main.go @@ -17,8 +17,6 @@ /** * @authors * Jeffrey Wilcke - * @date 2014 - * */ package main @@ -133,6 +131,12 @@ func (self *VMEnv) Value() *big.Int { return self.value } func (self *VMEnv) GasLimit() *big.Int { return big.NewInt(1000000000) } func (self *VMEnv) Depth() int { return 0 } func (self *VMEnv) SetDepth(i int) { self.depth = i } +func (self *VMEnv) GetHash(n uint64) []byte { + if self.block.Number().Cmp(big.NewInt(int64(n))) == 0 { + return self.block.Hash() + } + return nil +} func (self *VMEnv) AddLog(log state.Log) { self.state.AddLog(log) } diff --git a/cmd/mist/assets/qml/views/miner.qml b/cmd/mist/assets/qml/views/miner.qml index e0182649fb..193ce37bea 100644 --- a/cmd/mist/assets/qml/views/miner.qml +++ b/cmd/mist/assets/qml/views/miner.qml @@ -46,6 +46,7 @@ Rectangle { text: "Start" onClicked: { eth.setGasPrice(minGasPrice.text || "10000000000000"); + eth.setExtra(blockExtra.text) if (eth.toggleMining()) { this.text = "Stop"; } else { @@ -55,6 +56,7 @@ Rectangle { } Rectangle { + id: minGasPriceRect anchors.top: parent.top anchors.topMargin: 2 width: 200 @@ -65,6 +67,23 @@ Rectangle { validator: RegExpValidator { regExp: /\d*/ } } } + + Rectangle { + width: 300 + anchors { + left: minGasPriceRect.right + leftMargin: 5 + top: parent.top + topMargin: 2 + } + + TextField { + id: blockExtra + placeholderText: "Extra" + width: parent.width + maximumLength: 1024 + } + } } } diff --git a/cmd/mist/bindings.go b/cmd/mist/bindings.go index 9e55592e60..e91a157dc3 100644 --- a/cmd/mist/bindings.go +++ b/cmd/mist/bindings.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import ( diff --git a/cmd/mist/debugger.go b/cmd/mist/debugger.go index 618e31f4ed..b960e52cf7 100644 --- a/cmd/mist/debugger.go +++ b/cmd/mist/debugger.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import ( diff --git a/cmd/mist/errors.go b/cmd/mist/errors.go index 2069bf26d9..26a172ce95 100644 --- a/cmd/mist/errors.go +++ b/cmd/mist/errors.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import ( diff --git a/cmd/mist/ext_app.go b/cmd/mist/ext_app.go index 33c420a7a1..012c94923a 100644 --- a/cmd/mist/ext_app.go +++ b/cmd/mist/ext_app.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import ( diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index fcee28f19b..2f0790b76a 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import ( diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index 2c31bb3cdf..26239c4dbf 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import "C" diff --git a/cmd/mist/html_container.go b/cmd/mist/html_container.go index bd11ccd57e..f2ba6fbe24 100644 --- a/cmd/mist/html_container.go +++ b/cmd/mist/html_container.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import ( diff --git a/cmd/mist/main.go b/cmd/mist/main.go index b8b58a36af..eb0a80addf 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import ( diff --git a/cmd/mist/qml_container.go b/cmd/mist/qml_container.go index ed24737d0e..7f5d97bec1 100644 --- a/cmd/mist/qml_container.go +++ b/cmd/mist/qml_container.go @@ -1,19 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go index 843c168de3..19cb1797aa 100644 --- a/cmd/mist/ui_lib.go +++ b/cmd/mist/ui_lib.go @@ -1,20 +1,23 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA +/* + This file is part of go-ethereum + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package main import ( @@ -279,6 +282,10 @@ func (self *UiLib) SetGasPrice(price string) { self.miner.MinAcceptedGasPrice = ethutil.Big(price) } +func (self *UiLib) SetExtra(extra string) { + self.miner.Extra = extra +} + func (self *UiLib) ToggleMining() bool { if !self.miner.Mining() { self.miner.Start() diff --git a/cmd/peerserver/main.go b/cmd/peerserver/main.go index 18d183f0bd..341c4dbb9d 100644 --- a/cmd/peerserver/main.go +++ b/cmd/peerserver/main.go @@ -1,10 +1,25 @@ +/* + This file is part of go-ethereum + + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ package main import ( "crypto/elliptic" - "fmt" + "flag" "log" - "net" "os" "github.com/ethereum/go-ethereum/crypto" @@ -12,29 +27,32 @@ import ( "github.com/ethereum/go-ethereum/p2p" ) +var ( + natType = flag.String("nat", "", "NAT traversal implementation") + pmpGateway = flag.String("gateway", "", "gateway address for NAT-PMP") + listenAddr = flag.String("addr", ":30301", "listen address") +) + func main() { + flag.Parse() + nat, err := p2p.ParseNAT(*natType, *pmpGateway) + if err != nil { + log.Fatal("invalid nat:", err) + } + logger.AddLogSystem(logger.NewStdLogSystem(os.Stdout, log.LstdFlags, logger.InfoLevel)) key, _ := crypto.GenerateKey() marshaled := elliptic.Marshal(crypto.S256(), key.PublicKey.X, key.PublicKey.Y) srv := p2p.Server{ MaxPeers: 100, - Identity: p2p.NewSimpleClientIdentity("Ethereum(G)", "0.1", "Peer Server Two", string(marshaled)), - ListenAddr: ":30301", - NAT: p2p.UPNP(), + Identity: p2p.NewSimpleClientIdentity("Ethereum(G)", "0.1", "Peer Server Two", marshaled), + ListenAddr: *listenAddr, + NAT: nat, + NoDial: true, } if err := srv.Start(); err != nil { - fmt.Println("could not start server:", err) - os.Exit(1) + log.Fatal("could not start server:", err) } - - // add seed peers - seed, err := net.ResolveTCPAddr("tcp", "poc-8.ethdev.com:30303") - if err != nil { - fmt.Println("couldn't resolve:", err) - } else { - srv.SuggestPeer(seed.IP, seed.Port, nil) - } - select {} } diff --git a/cmd/rlpdump/main.go b/cmd/rlpdump/main.go index 4c188e179d..8567dcff83 100644 --- a/cmd/rlpdump/main.go +++ b/cmd/rlpdump/main.go @@ -14,6 +14,10 @@ You should have received a copy of the GNU General Public License along with go-ethereum. If not, see . */ +/** + * @authors + * Felix Lange + */ // rlpdump is a pretty-printer for RLP data. package main @@ -106,8 +110,7 @@ func dump(s *rlp.Stream, depth int) error { s.List() defer s.ListEnd() if size == 0 { - fmt.Printf(ws(depth) + "[]") - return nil + fmt.Print(ws(depth) + "[]") } else { fmt.Println(ws(depth) + "[") for i := 0; ; i++ { diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index d01d9da9f9..1a85668b03 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -1,3 +1,24 @@ +/* + This file is part of go-ethereum + + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + * Viktor Tron + */ package utils import ( diff --git a/cmd/utils/vm_env.go b/cmd/utils/vm_env.go index acc2ffad95..5eaf63b651 100644 --- a/cmd/utils/vm_env.go +++ b/cmd/utils/vm_env.go @@ -1,3 +1,23 @@ +/* + This file is part of go-ethereum + + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package utils import ( diff --git a/cmd/utils/websockets.go b/cmd/utils/websockets.go index e4bc1b1854..003e1bc227 100644 --- a/cmd/utils/websockets.go +++ b/cmd/utils/websockets.go @@ -1,3 +1,23 @@ +/* + This file is part of go-ethereum + + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ +/** + * @authors + * Jeffrey Wilcke + */ package utils import ( @@ -33,73 +53,73 @@ func (self *WebSocketServer) Serv() { data := ethutil.NewValue(msg.Args) bcode, err := ethutil.Compile(data.Get(0).Str(), false) if err != nil { - c.Write(args(nil, err.Error()), msg.Seed) + c.Write(args(nil, err.Error()), msg.Id) } code := ethutil.Bytes2Hex(bcode) - c.Write(args(code, nil), msg.Seed) - case "getBlockByNumber": + c.Write(args(code, nil), msg.Id) + case "eth_blockByNumber": args := msg.Arguments() block := pipe.BlockByNumber(int32(args.Get(0).Uint())) - c.Write(block, msg.Seed) + c.Write(block, msg.Id) - case "getKey": - c.Write(pipe.Key().PrivateKey, msg.Seed) - case "transact": + case "eth_blockByHash": + args := msg.Arguments() + + c.Write(pipe.BlockByHash(args.Get(0).Str()), msg.Id) + + case "eth_transact": if mp, ok := msg.Args[0].(map[string]interface{}); ok { object := mapToTxParams(mp) c.Write( - args(pipe.Transact(object["from"], object["to"], object["value"], object["gas"], object["gasPrice"], object["data"])), - msg.Seed, + args(pipe.Transact(pipe.Key().PrivateKey, object["to"], object["value"], object["gas"], object["gasPrice"], object["data"])), + msg.Id, ) } - case "getCoinBase": - c.Write(pipe.CoinBase(), msg.Seed) + case "eth_gasPrice": + c.Write("10000000000000", msg.Id) + case "eth_coinbase": + c.Write(pipe.CoinBase(), msg.Id) - case "getIsListening": - c.Write(pipe.IsListening(), msg.Seed) + case "eth_listening": + c.Write(pipe.IsListening(), msg.Id) - case "getIsMining": - c.Write(pipe.IsMining(), msg.Seed) + case "eth_mining": + c.Write(pipe.IsMining(), msg.Id) - case "getPeerCoint": - c.Write(pipe.PeerCount(), msg.Seed) + case "eth_peerCount": + c.Write(pipe.PeerCount(), msg.Id) - case "getCountAt": + case "eth_countAt": args := msg.Arguments() - c.Write(pipe.TxCountAt(args.Get(0).Str()), msg.Seed) + c.Write(pipe.TxCountAt(args.Get(0).Str()), msg.Id) - case "getCodeAt": + case "eth_codeAt": args := msg.Arguments() - c.Write(len(pipe.CodeAt(args.Get(0).Str())), msg.Seed) + c.Write(len(pipe.CodeAt(args.Get(0).Str())), msg.Id) - case "getBlockByHash": + case "eth_storageAt": args := msg.Arguments() - c.Write(pipe.BlockByHash(args.Get(0).Str()), msg.Seed) + c.Write(pipe.StorageAt(args.Get(0).Str(), args.Get(1).Str()), msg.Id) - case "getStorageAt": + case "eth_balanceAt": args := msg.Arguments() - c.Write(pipe.StorageAt(args.Get(0).Str(), args.Get(1).Str()), msg.Seed) + c.Write(pipe.BalanceAt(args.Get(0).Str()), msg.Id) - case "getBalanceAt": + case "eth_secretToAddress": args := msg.Arguments() - c.Write(pipe.BalanceAt(args.Get(0).Str()), msg.Seed) + c.Write(pipe.SecretToAddress(args.Get(0).Str()), msg.Id) - case "getSecretToAddress": - args := msg.Arguments() - - c.Write(pipe.SecretToAddress(args.Get(0).Str()), msg.Seed) - - case "newFilter": - case "newFilterString": - case "messages": + case "eth_newFilter": + case "eth_newFilterString": + case "eth_messages": // TODO } diff --git a/core/block_processor.go b/core/block_processor.go index 83399f4728..127e979211 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -258,6 +258,10 @@ func (sm *BlockProcessor) CalculateTD(block *types.Block) (*big.Int, bool) { // an uncle or anything that isn't on the current block chain. // Validation validates easy over difficult (dagger takes longer time = difficult) func (sm *BlockProcessor) ValidateBlock(block, parent *types.Block) error { + if len(block.Header().Extra) > 1024 { + return fmt.Errorf("Block extra data too long (%d)", len(block.Header().Extra)) + } + expd := CalcDifficulty(block, parent) if expd.Cmp(block.Header().Difficulty) < 0 { return fmt.Errorf("Difficulty check failed for block %v, %v", block.Header().Difficulty, expd) diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go index 2ed3c6c9e0..6c66961b0a 100644 --- a/core/chain_manager_test.go +++ b/core/chain_manager_test.go @@ -71,7 +71,7 @@ func TestChainInsertions(t *testing.T) { var eventMux event.TypeMux chainMan := NewChainManager(&eventMux) txPool := NewTxPool(&eventMux) - blockMan := NewBlockManager(txPool, chainMan, &eventMux) + blockMan := NewBlockProcessor(txPool, chainMan, &eventMux) chainMan.SetProcessor(blockMan) const max = 2 @@ -115,7 +115,7 @@ func TestChainMultipleInsertions(t *testing.T) { var eventMux event.TypeMux chainMan := NewChainManager(&eventMux) txPool := NewTxPool(&eventMux) - blockMan := NewBlockManager(txPool, chainMan, &eventMux) + blockMan := NewBlockProcessor(txPool, chainMan, &eventMux) chainMan.SetProcessor(blockMan) done := make(chan bool, max) for i, chain := range chains { diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go index e77d7a1aed..2e1debfbee 100644 --- a/core/transaction_pool_test.go +++ b/core/transaction_pool_test.go @@ -55,7 +55,7 @@ func TestAddInvalidTx(t *testing.T) { func TestRemoveSet(t *testing.T) { pool, _ := setup() tx1 := transaction() - pool.pool.Add(tx1) + pool.addTx(tx1) pool.RemoveSet(types.Transactions{tx1}) if pool.Size() > 0 { t.Error("expected pool size to be 0") @@ -65,7 +65,7 @@ func TestRemoveSet(t *testing.T) { func TestRemoveInvalid(t *testing.T) { pool, key := setup() tx1 := transaction() - pool.pool.Add(tx1) + pool.addTx(tx1) pool.RemoveInvalid(stateQuery{}) if pool.Size() > 0 { t.Error("expected pool size to be 0") @@ -73,7 +73,7 @@ func TestRemoveInvalid(t *testing.T) { tx1.SetNonce(1) tx1.SignECDSA(key) - pool.pool.Add(tx1) + pool.addTx(tx1) pool.RemoveInvalid(stateQuery{}) if pool.Size() != 1 { t.Error("expected pool size to be 1, is", pool.Size()) diff --git a/eth/backend.go b/eth/backend.go index 7f397eef41..a5d3521e93 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -17,7 +17,7 @@ import ( ) const ( - seedNodeAddress = "poc-7.ethdev.com:30300" + seedNodeAddress = "poc-8.ethdev.com:30303" ) var seednodeId []byte = nil diff --git a/eth/protocol.go b/eth/protocol.go index b67e5aaeab..723ab5502e 100644 --- a/eth/protocol.go +++ b/eth/protocol.go @@ -140,7 +140,7 @@ func (self *ethProtocol) handle() error { return self.protoError(ErrDecode, "->msg %v: %v", msg, err) } hashes := self.chainManager.GetBlockHashesFromHash(request.Hash, request.Amount) - return self.rw.EncodeMsg(BlockHashesMsg, ethutil.ByteSliceToInterface(hashes)...) + return p2p.EncodeMsg(self.rw, BlockHashesMsg, ethutil.ByteSliceToInterface(hashes)...) case BlockHashesMsg: // TODO: redo using lazy decode , this way very inefficient on known chains @@ -185,7 +185,7 @@ func (self *ethProtocol) handle() error { break } } - return self.rw.EncodeMsg(BlocksMsg, blocks...) + return p2p.EncodeMsg(self.rw, BlocksMsg, blocks...) case BlocksMsg: msgStream := rlp.NewStream(msg.Payload) @@ -298,12 +298,12 @@ func (self *ethProtocol) handleStatus() error { func (self *ethProtocol) requestBlockHashes(from []byte) error { self.peer.Debugf("fetching hashes (%d) %x...\n", blockHashesBatchSize, from[0:4]) - return self.rw.EncodeMsg(GetBlockHashesMsg, interface{}(from), uint64(blockHashesBatchSize)) + return p2p.EncodeMsg(self.rw, GetBlockHashesMsg, interface{}(from), uint64(blockHashesBatchSize)) } func (self *ethProtocol) requestBlocks(hashes [][]byte) error { self.peer.Debugf("fetching %v blocks", len(hashes)) - return self.rw.EncodeMsg(GetBlocksMsg, ethutil.ByteSliceToInterface(hashes)...) + return p2p.EncodeMsg(self.rw, GetBlocksMsg, ethutil.ByteSliceToInterface(hashes)...) } func (self *ethProtocol) protoError(code int, format string, params ...interface{}) (err *protocolError) { diff --git a/eth/protocol_test.go b/eth/protocol_test.go index ab2aa289f0..224b59abd3 100644 --- a/eth/protocol_test.go +++ b/eth/protocol_test.go @@ -41,10 +41,6 @@ func (self *testMsgReadWriter) WriteMsg(msg p2p.Msg) error { return nil } -func (self *testMsgReadWriter) EncodeMsg(code uint64, data ...interface{}) error { - return self.WriteMsg(p2p.NewMsg(code, data...)) -} - func (self *testMsgReadWriter) ReadMsg() (p2p.Msg, error) { msg, ok := <-self.in if !ok { diff --git a/miner/miner.go b/miner/miner.go index 949227d983..f80ae51c68 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -69,6 +69,7 @@ type Miner struct { mining bool MinAcceptedGasPrice *big.Int + Extra string } func New(coinbase []byte, eth *eth.Ethereum) *Miner { @@ -178,6 +179,7 @@ func (self *Miner) mine() { chainMan = self.eth.ChainManager() block = chainMan.NewBlock(self.Coinbase) ) + block.Header().Extra = self.Extra // Apply uncles if len(self.uncles) > 0 { diff --git a/p2p/message.go b/p2p/message.go index a6f62ec4c8..daf2bf05c1 100644 --- a/p2p/message.go +++ b/p2p/message.go @@ -71,14 +71,11 @@ type MsgReader interface { } type MsgWriter interface { - // WriteMsg sends an existing message. - // The Payload reader of the message is consumed. + // WriteMsg sends a message. It will block until the message's + // Payload has been consumed by the other end. + // // Note that messages can be sent only once. WriteMsg(Msg) error - - // EncodeMsg writes an RLP-encoded message with the given - // code and data elements. - EncodeMsg(code uint64, data ...interface{}) error } // MsgReadWriter provides reading and writing of encoded messages. @@ -87,6 +84,12 @@ type MsgReadWriter interface { MsgWriter } +// EncodeMsg writes an RLP-encoded message with the given code and +// data elements. +func EncodeMsg(w MsgWriter, code uint64, data ...interface{}) error { + return w.WriteMsg(NewMsg(code, data...)) +} + var magicToken = []byte{34, 64, 8, 145} func writeMsg(w io.Writer, msg Msg) error { @@ -209,11 +212,6 @@ func (p *MsgPipeRW) WriteMsg(msg Msg) error { return ErrPipeClosed } -// EncodeMsg is a convenient shorthand for sending an RLP-encoded message. -func (p *MsgPipeRW) EncodeMsg(code uint64, data ...interface{}) error { - return p.WriteMsg(NewMsg(code, data...)) -} - // ReadMsg returns a message sent on the other end of the pipe. func (p *MsgPipeRW) ReadMsg() (Msg, error) { if atomic.LoadInt32(p.closed) == 0 { diff --git a/p2p/message_test.go b/p2p/message_test.go index 066d2516d4..5cde9abf5b 100644 --- a/p2p/message_test.go +++ b/p2p/message_test.go @@ -75,8 +75,8 @@ func TestDecodeRealMsg(t *testing.T) { func ExampleMsgPipe() { rw1, rw2 := MsgPipe() go func() { - rw1.EncodeMsg(8, []byte{0, 0}) - rw1.EncodeMsg(5, []byte{1, 1}) + EncodeMsg(rw1, 8, []byte{0, 0}) + EncodeMsg(rw1, 5, []byte{1, 1}) rw1.Close() }() @@ -100,7 +100,7 @@ loop: rw1, rw2 := MsgPipe() done := make(chan struct{}) go func() { - if err := rw1.EncodeMsg(1); err == nil { + if err := EncodeMsg(rw1, 1); err == nil { t.Error("EncodeMsg returned nil error") } else if err != ErrPipeClosed { t.Error("EncodeMsg returned wrong error: got %v, want %v", err, ErrPipeClosed) diff --git a/p2p/peer_test.go b/p2p/peer_test.go index 5b9e9e7847..4ee88f112b 100644 --- a/p2p/peer_test.go +++ b/p2p/peer_test.go @@ -126,10 +126,10 @@ func TestPeerProtoEncodeMsg(t *testing.T) { Name: "a", Length: 2, Run: func(peer *Peer, rw MsgReadWriter) error { - if err := rw.EncodeMsg(2); err == nil { + if err := EncodeMsg(rw, 2); err == nil { t.Error("expected error for out-of-range msg code, got nil") } - if err := rw.EncodeMsg(1, "foo", "bar"); err != nil { + if err := EncodeMsg(rw, 1, "foo", "bar"); err != nil { t.Errorf("write error: %v", err) } return nil diff --git a/p2p/protocol.go b/p2p/protocol.go index 356a89413a..7aabe2860d 100644 --- a/p2p/protocol.go +++ b/p2p/protocol.go @@ -105,25 +105,22 @@ func runBaseProtocol(peer *Peer, rw MsgReadWriter) error { } } }() - var lastActiveC chan time.Time - if bp.peer.listenAddr != nil { - lastActiveC = bp.peer.listenAddr.lastActiveC - } - return bp.loop(errc, lastActiveC) + return bp.loop(errc) } var pingTimeout = 2 * time.Second -func (bp *baseProtocol) loop(quit <-chan error, lastActiveC chan time.Time) error { +func (bp *baseProtocol) loop(quit <-chan error) error { ping := time.NewTimer(pingTimeout) activity := bp.peer.activity.Subscribe(time.Time{}) lastActive := time.Time{} + lastActiveC := bp.peer.lastActiveC defer ping.Stop() defer activity.Unsubscribe() getPeersTick := time.NewTicker(10 * time.Second) defer getPeersTick.Stop() - err := bp.rw.EncodeMsg(getPeersMsg) + err := EncodeMsg(bp.rw, getPeersMsg) for err == nil { select { @@ -131,7 +128,7 @@ func (bp *baseProtocol) loop(quit <-chan error, lastActiveC chan time.Time) erro return err case lastActiveC <- lastActive: case <-getPeersTick.C: - err = bp.rw.EncodeMsg(getPeersMsg) + err = EncodeMsg(bp.rw, getPeersMsg) case event := <-activity.Chan(): ping.Reset(pingTimeout) lastActive = event.(time.Time) @@ -139,7 +136,7 @@ func (bp *baseProtocol) loop(quit <-chan error, lastActiveC chan time.Time) erro if lastActive.Add(pingTimeout * 2).Before(t) { err = newPeerError(errPingTimeout, "") } else if lastActive.Add(pingTimeout).Before(t) { - err = bp.rw.EncodeMsg(pingMsg) + err = EncodeMsg(bp.rw, pingMsg) } } } @@ -169,7 +166,7 @@ func (bp *baseProtocol) handle(rw MsgReadWriter) error { return discRequestedError(reason[0]) case pingMsg: - return bp.rw.EncodeMsg(pongMsg) + return EncodeMsg(bp.rw, pongMsg) case pongMsg: @@ -187,16 +184,22 @@ func (bp *baseProtocol) handle(rw MsgReadWriter) error { peers = append(peers, ourAddr) } } - ds := make([]interface{}, 0, len(peers)) + addrs := make([]interface{}, 0, len(peers)) // encode and filter out requesting peer for _, addr := range peers { - if addr != bp.peer.listenAddr { - ds = append(ds, addr) + if addr != bp.peer.Addr() { + addrs = append(addrs, addr) } } - if len(ds) > 0 { - return bp.rw.EncodeMsg(peersMsg, ds...) + // this is dangerous. the spec says that we should _delay_ + // sending the response if no new information is available. + // this means that would need to send a response later when + // new peers become available. + // + // TODO: add event mechanism to notify baseProtocol for new peers + if len(addrs) > 0 { + return EncodeMsg(bp.rw, peersMsg, addrs...) } case peersMsg: diff --git a/p2p/protocol_test.go b/p2p/protocol_test.go index 38a3094957..4ea38edc28 100644 --- a/p2p/protocol_test.go +++ b/p2p/protocol_test.go @@ -4,6 +4,7 @@ import ( "fmt" "net" "reflect" + "sync" "testing" "github.com/ethereum/go-ethereum/crypto" @@ -36,48 +37,61 @@ func newTestPeer() (peer *Peer) { } func TestBaseProtocolPeers(t *testing.T) { - cannedPeerList := []*peerAddr{ + peerList := []*peerAddr{ {IP: net.ParseIP("1.2.3.4"), Port: 2222, Pubkey: []byte{}}, {IP: net.ParseIP("5.6.7.8"), Port: 3333, Pubkey: []byte{}}, } - var ownAddr *peerAddr = &peerAddr{IP: net.ParseIP("1.3.5.7"), Port: 1111, Pubkey: []byte{}} + listenAddr := &peerAddr{IP: net.ParseIP("1.3.5.7"), Port: 1111, Pubkey: []byte{}} rw1, rw2 := MsgPipe() + defer rw1.Close() + wg := new(sync.WaitGroup) + // run matcher, close pipe when addresses have arrived - addrChan := make(chan *peerAddr, len(cannedPeerList)) + numPeers := len(peerList) + 1 + addrChan := make(chan *peerAddr) + wg.Add(1) go func() { - for _, want := range cannedPeerList { - got := <-addrChan - t.Logf("got peer: %+v", got) + i := 0 + for got := range addrChan { + var want *peerAddr + switch { + case i < len(peerList): + want = peerList[i] + case i == len(peerList): + want = listenAddr // listenAddr should be the last thing sent + } + t.Logf("got peer %d/%d: %v", i+1, numPeers, got) if !reflect.DeepEqual(want, got) { - t.Errorf("mismatch: got %#v, want %#v", got, want) + t.Errorf("mismatch: got %+v, want %+v", got, want) + } + i++ + if i == numPeers { + break } } - close(addrChan) - var own []*peerAddr - var got *peerAddr - for got = range addrChan { - own = append(own, got) + if i != numPeers { + t.Errorf("wrong number of peers received: got %d, want %d", i, numPeers) } - if len(own) < 1 { - t.Errorf("mismatch: peers own address not given") - } else { - if !reflect.DeepEqual(ownAddr, own[0]) { - t.Errorf("mismatch: peers own address is incorrectly or not given, got %v, want %#v", own[0], ownAddr) - } - } - rw2.Close() + rw1.Close() + wg.Done() }() - // run first peer + + // run first peer (in background) peer1 := newTestPeer() - peer1.ourListenAddr = ownAddr + peer1.ourListenAddr = listenAddr peer1.getPeers = func(...[]byte) []*peerAddr { - pl := make([]*peerAddr, len(cannedPeerList)) + pl := make([]*peerAddr, len(peerList)) for i, addr := range cannedPeerList { pl[i] = addr } return pl } - go runBaseProtocol(peer1, rw1) + wg.Add(1) + go func() { + runBaseProtocol(peer1, rw1) + wg.Done() + }() + // run second peer peer2 := newTestPeer() peer2.addPeer = func(addr *peerAddr) error { @@ -87,6 +101,10 @@ func TestBaseProtocolPeers(t *testing.T) { if err := runBaseProtocol(peer2, rw2); err != ErrPipeClosed { t.Errorf("peer2 terminated with unexpected error: %v", err) } + + // terminate matcher + close(addrChan) + wg.Wait() } func TestBaseProtocolDisconnect(t *testing.T) { @@ -100,7 +118,7 @@ func TestBaseProtocolDisconnect(t *testing.T) { if err := expectMsg(rw2, handshakeMsg); err != nil { t.Error(err) } - err := rw2.EncodeMsg(handshakeMsg, + err := EncodeMsg(rw2, handshakeMsg, baseProtocolVersion, "", []interface{}{}, @@ -113,7 +131,7 @@ func TestBaseProtocolDisconnect(t *testing.T) { if err := expectMsg(rw2, getPeersMsg); err != nil { t.Error(err) } - if err := rw2.EncodeMsg(discMsg, DiscQuitting); err != nil { + if err := EncodeMsg(rw2, discMsg, DiscQuitting); err != nil { t.Error(err) } diff --git a/websocket/client.go b/websocket/client.go index d961816e8d..db2c8e5c91 100644 --- a/websocket/client.go +++ b/websocket/client.go @@ -50,8 +50,8 @@ func (c *Client) Conn() *ws.Conn { return c.ws } -func (c *Client) Write(data interface{}, seed int) { - msg := &Message{Seed: seed, Data: data} +func (c *Client) Write(data interface{}, id int) { + msg := &Message{Id: id, Data: data} select { case c.ch <- msg: default: @@ -73,7 +73,6 @@ func (c *Client) Listen() { // Listen write request via chanel func (c *Client) listenWrite() { - wslogger.Debugln("Listening write to client") for { select { @@ -93,7 +92,6 @@ func (c *Client) listenWrite() { // Listen read request via chanel func (c *Client) listenRead() { - wslogger.Debugln("Listening read from client") for { select { diff --git a/websocket/message.go b/websocket/message.go index 67289c4c49..73b47456f6 100644 --- a/websocket/message.go +++ b/websocket/message.go @@ -5,7 +5,7 @@ import "github.com/ethereum/go-ethereum/ethutil" type Message struct { Call string `json:"call"` Args []interface{} `json:"args"` - Seed int `json:"seed"` + Id int `json:"_id"` Data interface{} `json:"data"` } diff --git a/websocket/server.go b/websocket/server.go index 5fd923a0c6..b0658b1b44 100644 --- a/websocket/server.go +++ b/websocket/server.go @@ -81,8 +81,6 @@ func (s *Server) MessageFunc(f MsgFunc) { // Listen and serve. // It serves client connection and broadcast request. func (s *Server) Listen() { - wslogger.Debugln("Listening server...") - // ws handler onConnected := func(ws *ws.Conn) { defer func() { diff --git a/xeth/js_types.go b/xeth/js_types.go index dbddcb7a32..e7a1e95e9f 100644 --- a/xeth/js_types.go +++ b/xeth/js_types.go @@ -169,8 +169,8 @@ func NewJSPeer(peer *p2p.Peer) *JSPeer { return &JSPeer{ ref: peer, - Ip: peer.RemoteAddr().String(), - Version: peer.Identity().String(), + Ip: fmt.Sprintf("%v", peer.RemoteAddr()), + Version: fmt.Sprintf("%v", peer.Identity()), Caps: fmt.Sprintf("%v", caps), } }