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
148de1c8
Commit
148de1c8
authored
Dec 14, 2014
by
zelig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adapt xeth pkg to new backend. FIXME JSPeer peer info
parent
76070b46
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
44 deletions
+35
-44
hexface.go
xeth/hexface.go
+2
-7
js_types.go
xeth/js_types.go
+31
-34
world.go
xeth/world.go
+2
-3
No files found.
xeth/hexface.go
View file @
148de1c8
...
...
@@ -3,7 +3,6 @@ package xeth
import
(
"bytes"
"encoding/json"
"sync/atomic"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
...
...
@@ -63,12 +62,8 @@ func (self *JSXEth) PeerCount() int {
func
(
self
*
JSXEth
)
Peers
()
[]
JSPeer
{
var
peers
[]
JSPeer
for
peer
:=
self
.
obj
.
Peers
()
.
Front
();
peer
!=
nil
;
peer
=
peer
.
Next
()
{
p
:=
peer
.
Value
.
(
core
.
Peer
)
// we only want connected peers
if
atomic
.
LoadInt32
(
p
.
Connected
())
!=
0
{
peers
=
append
(
peers
,
*
NewJSPeer
(
p
))
}
for
_
,
peer
:=
range
self
.
obj
.
Peers
()
{
peers
=
append
(
peers
,
*
NewJSPeer
(
peer
))
}
return
peers
...
...
xeth/js_types.go
View file @
148de1c8
package
xeth
import
(
"fmt"
"strconv"
"strings"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/state"
)
...
...
@@ -155,38 +154,36 @@ func NewPReciept(contractCreation bool, creationAddress, hash, address []byte) *
// Peer interface exposed to QML
type
JSPeer
struct
{
ref
*
core
.
Peer
Inbound
bool
`json:"isInbound"`
LastSend
int64
`json:"lastSend"`
LastPong
int64
`json:"lastPong"`
Ip
string
`json:"ip"`
Port
int
`json:"port"`
Version
string
`json:"version"`
LastResponse
string
`json:"lastResponse"`
Latency
string
`json:"latency"`
Caps
string
`json:"caps"`
}
func
NewJSPeer
(
peer
core
.
Peer
)
*
JSPeer
{
if
peer
==
nil
{
return
nil
}
var
ip
[]
string
for
_
,
i
:=
range
peer
.
Host
()
{
ip
=
append
(
ip
,
strconv
.
Itoa
(
int
(
i
)))
}
ipAddress
:=
strings
.
Join
(
ip
,
"."
)
var
caps
[]
string
capsIt
:=
peer
.
Caps
()
.
NewIterator
()
for
capsIt
.
Next
()
{
cap
:=
capsIt
.
Value
()
.
Get
(
0
)
.
Str
()
ver
:=
capsIt
.
Value
()
.
Get
(
1
)
.
Uint
()
caps
=
append
(
caps
,
fmt
.
Sprintf
(
"%s/%d"
,
cap
,
ver
))
}
return
&
JSPeer
{
ref
:
&
peer
,
Inbound
:
peer
.
Inbound
(),
LastSend
:
peer
.
LastSend
()
.
Unix
(),
LastPong
:
peer
.
LastPong
(),
Version
:
peer
.
Version
(),
Ip
:
ipAddress
,
Port
:
int
(
peer
.
Port
()),
Latency
:
peer
.
PingTime
(),
Caps
:
"["
+
strings
.
Join
(
caps
,
", "
)
+
"]"
}
ref
*
p2p
.
Peer
// Inbound bool `json:"isInbound"`
// LastSend int64 `json:"lastSend"`
// LastPong int64 `json:"lastPong"`
// Ip string `json:"ip"`
// Port int `json:"port"`
// Version string `json:"version"`
// LastResponse string `json:"lastResponse"`
// Latency string `json:"latency"`
// Caps string `json:"caps"`
}
func
NewJSPeer
(
peer
*
p2p
.
Peer
)
*
JSPeer
{
// var ip []string
// for _, i := range peer.Host() {
// ip = append(ip, strconv.Itoa(int(i)))
// }
// ipAddress := strings.Join(ip, ".")
// var caps []string
// capsIt := peer.Caps().NewIterator()
// for capsIt.Next() {
// cap := capsIt.Value().Get(0).Str()
// ver := capsIt.Value().Get(1).Uint()
// caps = append(caps, fmt.Sprintf("%s/%d", cap, ver))
// }
return
&
JSPeer
{
ref
:
peer
}
// return &JSPeer{ref: &peer, Inbound: peer.Inbound(), LastSend: peer.LastSend().Unix(), LastPong: peer.LastPong(), Version: peer.Version(), Ip: ipAddress, Port: int(peer.Port()), Latency: peer.PingTime(), Caps: "[" + strings.Join(caps, ", ") + "]"}
}
type
JSReceipt
struct
{
...
...
xeth/world.go
View file @
148de1c8
package
xeth
import
(
"container/list"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/state"
)
...
...
@@ -55,7 +54,7 @@ func (self *World) IsListening() bool {
return
self
.
pipe
.
obj
.
IsListening
()
}
func
(
self
*
World
)
Peers
()
*
list
.
List
{
func
(
self
*
World
)
Peers
()
[]
*
p2p
.
Peer
{
return
self
.
pipe
.
obj
.
Peers
()
}
...
...
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