From 991993357c902eaab56726bef97e7494674aa5e5 Mon Sep 17 00:00:00 2001 From: Maran Date: Sat, 14 Mar 2015 11:39:35 +0100 Subject: DRY up the use of fromHex and put it in ethutil --- xeth/whisper.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'xeth/whisper.go') diff --git a/xeth/whisper.go b/xeth/whisper.go index d9c7e1614..f5c26faae 100644 --- a/xeth/whisper.go +++ b/xeth/whisper.go @@ -5,6 +5,7 @@ import ( "time" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/whisper" ) @@ -28,12 +29,12 @@ func (self *Whisper) Post(payload string, to, from string, topics []string, prio ttl = 100 } - pk := crypto.ToECDSAPub(fromHex(from)) + pk := crypto.ToECDSAPub(ethutil.FromHex(from)) if key := self.Whisper.GetIdentity(pk); key != nil || len(from) == 0 { - msg := whisper.NewMessage(fromHex(payload)) + msg := whisper.NewMessage(ethutil.FromHex(payload)) envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{ Ttl: time.Duration(ttl) * time.Second, - To: crypto.ToECDSAPub(fromHex(to)), + To: crypto.ToECDSAPub(ethutil.FromHex(to)), From: key, Topics: whisper.TopicsFromString(topics...), }) @@ -59,13 +60,13 @@ func (self *Whisper) NewIdentity() string { } func (self *Whisper) HasIdentity(key string) bool { - return self.Whisper.HasIdentity(crypto.ToECDSAPub(fromHex(key))) + return self.Whisper.HasIdentity(crypto.ToECDSAPub(ethutil.FromHex(key))) } func (self *Whisper) Watch(opts *Options) int { filter := whisper.Filter{ - To: crypto.ToECDSAPub(fromHex(opts.To)), - From: crypto.ToECDSAPub(fromHex(opts.From)), + To: crypto.ToECDSAPub(ethutil.FromHex(opts.To)), + From: crypto.ToECDSAPub(ethutil.FromHex(opts.From)), Topics: whisper.TopicsFromString(opts.Topics...), } -- cgit v1.2.3