aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-16 19:20:17 +0800
committerobscuren <geffobscura@gmail.com>2015-03-16 19:20:17 +0800
commitdc864ee3a5baadc0197b8491d55e94bba52a30d9 (patch)
tree529057ce4c12a4f08aadd406df2bc739263a6b77
parentf486c0ae563eaf89a601ca5d60f30be96db2e69a (diff)
downloaddexon-dc864ee3a5baadc0197b8491d55e94bba52a30d9.tar
dexon-dc864ee3a5baadc0197b8491d55e94bba52a30d9.tar.gz
dexon-dc864ee3a5baadc0197b8491d55e94bba52a30d9.tar.bz2
dexon-dc864ee3a5baadc0197b8491d55e94bba52a30d9.tar.lz
dexon-dc864ee3a5baadc0197b8491d55e94bba52a30d9.tar.xz
dexon-dc864ee3a5baadc0197b8491d55e94bba52a30d9.tar.zst
dexon-dc864ee3a5baadc0197b8491d55e94bba52a30d9.zip
Added ToString methods
-rw-r--r--common/types.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/common/types.go b/common/types.go
index 11ac39815..911be9b9b 100644
--- a/common/types.go
+++ b/common/types.go
@@ -24,19 +24,22 @@ func (h Hash) SetBytes(b []byte) {
}
}
+func (h Hash) SetString(s string) { h.SetBytes([]byte(s)) }
+
// Get the string representation of the underlying address
func (a Address) Str() string {
return string(a[:])
}
// Sets the address to the value of b. If b is larger than len(a) it will panic
-func (h Address) SetBytes(b []byte) {
- if len(b) > len(h) {
+func (a Address) SetBytes(b []byte) {
+ if len(b) > len(a) {
panic("unable to set bytes. too big")
}
// reverse loop
for i := len(b); i >= 0; i-- {
- h[i] = b[i]
+ a[i] = b[i]
}
}
+func (a Address) SetString(s string) { h.SetBytes([]byte(a)) }