diff options
author | kiel barry <kiel.j.barry@gmail.com> | 2018-05-29 18:42:21 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-05-29 18:42:21 +0800 |
commit | 84f8c0cc1fbe1ab9c128555392a82ba609820fef (patch) | |
tree | 4859fe37105cc88d4d338a9f5bc55e42a017a29f /common/types_template.go | |
parent | 998f6564b28ea9241d0052c2abee090d2b9a8b63 (diff) | |
download | go-tangerine-84f8c0cc1fbe1ab9c128555392a82ba609820fef.tar go-tangerine-84f8c0cc1fbe1ab9c128555392a82ba609820fef.tar.gz go-tangerine-84f8c0cc1fbe1ab9c128555392a82ba609820fef.tar.bz2 go-tangerine-84f8c0cc1fbe1ab9c128555392a82ba609820fef.tar.lz go-tangerine-84f8c0cc1fbe1ab9c128555392a82ba609820fef.tar.xz go-tangerine-84f8c0cc1fbe1ab9c128555392a82ba609820fef.tar.zst go-tangerine-84f8c0cc1fbe1ab9c128555392a82ba609820fef.zip |
common: improve documentation comments (#16701)
This commit adds many comments and removes unused code.
It also removes the EmptyHash function, which had some uses
but was silly.
Diffstat (limited to 'common/types_template.go')
-rw-r--r-- | common/types_template.go | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/common/types_template.go b/common/types_template.go deleted file mode 100644 index 9a8f29977..000000000 --- a/common/types_template.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. - -// +build none -//sed -e 's/_N_/Hash/g' -e 's/_S_/32/g' -e '1d' types_template.go | gofmt -w hash.go - -package common - -import "math/big" - -type _N_ [_S_]byte - -func BytesTo_N_(b []byte) _N_ { - var h _N_ - h.SetBytes(b) - return h -} -func StringTo_N_(s string) _N_ { return BytesTo_N_([]byte(s)) } -func BigTo_N_(b *big.Int) _N_ { return BytesTo_N_(b.Bytes()) } -func HexTo_N_(s string) _N_ { return BytesTo_N_(FromHex(s)) } - -// Don't use the default 'String' method in case we want to overwrite - -// Get the string representation of the underlying hash -func (h _N_) Str() string { return string(h[:]) } -func (h _N_) Bytes() []byte { return h[:] } -func (h _N_) Big() *big.Int { return new(big.Int).SetBytes(h[:]) } -func (h _N_) Hex() string { return "0x" + Bytes2Hex(h[:]) } - -// Sets the hash to the value of b. If b is larger than len(h) it will panic -func (h *_N_) SetBytes(b []byte) { - // Use the right most bytes - if len(b) > len(h) { - b = b[len(b)-_S_:] - } - - // Reverse the loop - for i := len(b) - 1; i >= 0; i-- { - h[_S_-len(b)+i] = b[i] - } -} - -// Set string `s` to h. If s is larger than len(h) it will panic -func (h *_N_) SetString(s string) { h.SetBytes([]byte(s)) } - -// Sets h to other -func (h *_N_) Set(other _N_) { - for i, v := range other { - h[i] = v - } -} |