Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
01a6db93
Commit
01a6db93
authored
Dec 15, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added whisper debug interface + whisper fixes
parent
993280ec
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
28 deletions
+32
-28
main.qml
cmd/mist/assets/qml/main.qml
+1
-0
gui.go
cmd/mist/gui.go
+7
-1
ui_lib.go
cmd/mist/ui_lib.go
+4
-0
whisper.go
ui/qt/qwhisper/whisper.go
+15
-5
main.go
whisper/main.go
+2
-12
whisper.go
whisper/whisper.go
+3
-10
No files found.
cmd/mist/assets/qml/main.qml
View file @
01a6db93
...
...
@@ -50,6 +50,7 @@ ApplicationWindow {
addPlugin
(
"./views/miner.qml"
,
{
noAdd
:
true
,
close
:
false
,
section
:
"ethereum"
,
active
:
true
});
addPlugin
(
"./views/transaction.qml"
,
{
noAdd
:
true
,
close
:
false
,
section
:
"legacy"
});
addPlugin
(
"./views/whisper.qml"
,
{
noAdd
:
true
,
close
:
false
,
section
:
"legacy"
});
addPlugin
(
"./views/chain.qml"
,
{
noAdd
:
true
,
close
:
false
,
section
:
"legacy"
});
addPlugin
(
"./views/pending_tx.qml"
,
{
noAdd
:
true
,
close
:
false
,
section
:
"legacy"
});
addPlugin
(
"./views/info.qml"
,
{
noAdd
:
true
,
close
:
false
,
section
:
"legacy"
});
...
...
cmd/mist/gui.go
View file @
01a6db93
...
...
@@ -38,6 +38,7 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/ui/qt/qwhisper"
"github.com/ethereum/go-ethereum/xeth"
"gopkg.in/qml.v1"
)
...
...
@@ -87,7 +88,8 @@ type Gui struct {
eth
*
eth
.
Ethereum
// The public Ethereum library
uiLib
*
UiLib
uiLib
*
UiLib
whisper
*
qwhisper
.
Whisper
txDb
*
ethdb
.
LDBDatabase
...
...
@@ -138,10 +140,12 @@ func (gui *Gui) Start(assetPath string) {
gui
.
engine
=
qml
.
NewEngine
()
context
:=
gui
.
engine
.
Context
()
gui
.
uiLib
=
NewUiLib
(
gui
.
engine
,
gui
.
eth
,
assetPath
)
gui
.
whisper
=
qwhisper
.
New
(
gui
.
eth
.
Whisper
())
// Expose the eth library and the ui library to QML
context
.
SetVar
(
"gui"
,
gui
)
context
.
SetVar
(
"eth"
,
gui
.
uiLib
)
context
.
SetVar
(
"shh"
,
gui
.
whisper
)
// Load the main QML interface
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
...
...
@@ -391,6 +395,8 @@ func (gui *Gui) update() {
gui
.
setPeerInfo
()
}()
gui
.
whisper
.
SetView
(
gui
.
win
.
Root
()
.
ObjectByName
(
"whisperView"
))
for
_
,
plugin
:=
range
gui
.
plugins
{
guilogger
.
Infoln
(
"Loading plugin "
,
plugin
.
Name
)
...
...
cmd/mist/ui_lib.go
View file @
01a6db93
...
...
@@ -377,6 +377,10 @@ func (self *UiLib) ToggleMining() bool {
}
}
func
(
self
*
UiLib
)
ToHex
(
data
string
)
string
{
return
"0x"
+
ethutil
.
Bytes2Hex
([]
byte
(
data
))
}
/*
// XXX Refactor me & MOVE
func (self *Ethereum) InstallFilter(filter *core.Filter) (id int) {
...
...
ui/qt/qwhisper/whisper.go
View file @
01a6db93
package
qwhisper
import
(
"fmt"
"time"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/whisper"
"gopkg.in/qml.v1"
)
func
fromHex
(
s
string
)
[]
byte
{
...
...
@@ -18,25 +20,33 @@ func toHex(b []byte) string { return "0x" + ethutil.Bytes2Hex(b) }
type
Whisper
struct
{
*
whisper
.
Whisper
view
qml
.
Object
}
func
New
(
w
*
whisper
.
Whisper
)
*
Whisper
{
return
&
Whisper
{
w
}
return
&
Whisper
{
w
,
nil
}
}
func
(
self
*
Whisper
)
Post
(
data
string
,
pow
,
ttl
uint32
,
to
,
from
string
)
{
func
(
self
*
Whisper
)
SetView
(
view
qml
.
Object
)
{
self
.
view
=
view
}
func
(
self
*
Whisper
)
Post
(
data
string
,
to
,
from
string
,
topics
[]
string
,
pow
,
ttl
uint32
)
{
msg
:=
whisper
.
NewMessage
(
fromHex
(
data
))
envelope
,
err
:=
msg
.
Seal
(
time
.
Duration
(
pow
),
whisper
.
Opts
{
Ttl
:
time
.
Duration
(
ttl
),
To
:
crypto
.
ToECDSAPub
(
fromHex
(
to
)),
From
:
crypto
.
ToECDSA
(
fromHex
(
from
)),
Ttl
:
time
.
Duration
(
ttl
),
To
:
crypto
.
ToECDSAPub
(
fromHex
(
to
)),
From
:
crypto
.
ToECDSA
(
fromHex
(
from
)),
Topics
:
whisper
.
TopicsFromString
(
topics
),
})
if
err
!=
nil
{
fmt
.
Println
(
err
)
// handle error
return
}
if
err
:=
self
.
Whisper
.
Send
(
envelope
);
err
!=
nil
{
fmt
.
Println
(
err
)
// handle error
return
}
...
...
whisper/main.go
View file @
01a6db93
...
...
@@ -5,10 +5,8 @@ package main
import
(
"fmt"
"log"
"net"
"os"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/whisper"
...
...
@@ -20,12 +18,12 @@ func main() {
pub
,
_
:=
secp256k1
.
GenerateKeyPair
()
whisper
:=
whisper
.
New
(
&
event
.
TypeMux
{}
)
whisper
:=
whisper
.
New
()
srv
:=
p2p
.
Server
{
MaxPeers
:
10
,
Identity
:
p2p
.
NewSimpleClientIdentity
(
"whisper-go"
,
"1.0"
,
""
,
string
(
pub
)),
ListenAddr
:
":3030
3
"
,
ListenAddr
:
":3030
0
"
,
NAT
:
p2p
.
UPNP
(),
Protocols
:
[]
p2p
.
Protocol
{
whisper
.
Protocol
()},
...
...
@@ -35,13 +33,5 @@ func main() {
os
.
Exit
(
1
)
}
// add seed peers
seed
,
err
:=
net
.
ResolveTCPAddr
(
"tcp"
,
"poc-7.ethdev.com:30300"
)
if
err
!=
nil
{
fmt
.
Println
(
"couldn't resolve:"
,
err
)
os
.
Exit
(
1
)
}
srv
.
SuggestPeer
(
seed
.
IP
,
seed
.
Port
,
nil
)
select
{}
}
whisper/whisper.go
View file @
01a6db93
...
...
@@ -4,6 +4,7 @@ import (
"bytes"
"crypto/ecdsa"
"errors"
"fmt"
"sync"
"time"
...
...
@@ -71,16 +72,6 @@ func New() *Whisper {
}
whisper
.
filters
.
Start
()
// XXX TODO REMOVE TESTING CODE
//msg := NewMessage([]byte(fmt.Sprintf("Hello world. This is whisper-go. Incase you're wondering; the time is %v", time.Now())))
//envelope, _ := msg.Seal(DefaultPow, Opts{
// Ttl: DefaultTtl,
//})
//if err := whisper.Send(envelope); err != nil {
// fmt.Println(err)
//}
// XXX TODO REMOVE TESTING CODE
// p2p whisper sub protocol handler
whisper
.
protocol
=
p2p
.
Protocol
{
Name
:
"shh"
,
...
...
@@ -158,6 +149,7 @@ func (self *Whisper) msgHandler(peer *p2p.Peer, ws p2p.MsgReadWriter) error {
continue
}
fmt
.
Println
(
"recv"
)
if
err
:=
self
.
add
(
envelope
);
err
!=
nil
{
// TODO Punish peer here. Invalid envelope.
peer
.
Infoln
(
err
)
...
...
@@ -184,6 +176,7 @@ func (self *Whisper) add(envelope *Envelope) error {
if
!
self
.
expiry
[
envelope
.
Expiry
]
.
Has
(
hash
)
{
self
.
expiry
[
envelope
.
Expiry
]
.
Add
(
hash
)
self
.
postEvent
(
envelope
)
fmt
.
Println
(
"envelope added"
,
envelope
)
}
return
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment