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
88167f39
Commit
88167f39
authored
10 years ago
by
zelig
Committed by
Felix Lange
10 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add privkey to clientIdentity + tests
parent
c8a8aa0d
master
v1.10.12
v1.10.12-modified
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
5 deletions
+21
-5
client_identity.go
p2p/client_identity.go
+11
-4
client_identity_test.go
p2p/client_identity_test.go
+10
-1
No files found.
p2p/client_identity.go
View file @
88167f39
...
...
@@ -7,8 +7,9 @@ import (
// ClientIdentity represents the identity of a peer.
type
ClientIdentity
interface
{
String
()
string
// human readable identity
Pubkey
()
[]
byte
// 512-bit public key
String
()
string
// human readable identity
Pubkey
()
[]
byte
// 512-bit public key
PrivKey
()
[]
byte
// 512-bit private key
}
type
SimpleClientIdentity
struct
{
...
...
@@ -17,10 +18,11 @@ type SimpleClientIdentity struct {
customIdentifier
string
os
string
implementation
string
privkey
[]
byte
pubkey
[]
byte
}
func
NewSimpleClientIdentity
(
clientIdentifier
string
,
version
string
,
customIdentifier
string
,
pubkey
[]
byte
)
*
SimpleClientIdentity
{
func
NewSimpleClientIdentity
(
clientIdentifier
string
,
version
string
,
customIdentifier
string
,
p
rivkey
[]
byte
,
p
ubkey
[]
byte
)
*
SimpleClientIdentity
{
clientIdentity
:=
&
SimpleClientIdentity
{
clientIdentifier
:
clientIdentifier
,
version
:
version
,
...
...
@@ -28,6 +30,7 @@ func NewSimpleClientIdentity(clientIdentifier string, version string, customIden
os
:
runtime
.
GOOS
,
implementation
:
runtime
.
Version
(),
pubkey
:
pubkey
,
privkey
:
privkey
,
}
return
clientIdentity
...
...
@@ -50,8 +53,12 @@ func (c *SimpleClientIdentity) String() string {
c
.
implementation
)
}
func
(
c
*
SimpleClientIdentity
)
Privkey
()
[]
byte
{
return
c
.
privkey
}
func
(
c
*
SimpleClientIdentity
)
Pubkey
()
[]
byte
{
return
[]
byte
(
c
.
pubkey
)
return
c
.
pubkey
}
func
(
c
*
SimpleClientIdentity
)
SetCustomIdentifier
(
customIdentifier
string
)
{
...
...
This diff is collapsed.
Click to expand it.
p2p/client_identity_test.go
View file @
88167f39
package
p2p
import
(
"bytes"
"fmt"
"runtime"
"testing"
)
func
TestClientIdentity
(
t
*
testing
.
T
)
{
clientIdentity
:=
NewSimpleClientIdentity
(
"Ethereum(G)"
,
"0.5.16"
,
"test"
,
[]
byte
(
"pubkey"
))
clientIdentity
:=
NewSimpleClientIdentity
(
"Ethereum(G)"
,
"0.5.16"
,
"test"
,
[]
byte
(
"privkey"
),
[]
byte
(
"pubkey"
))
key
:=
clientIdentity
.
Privkey
()
if
!
bytes
.
Equal
(
key
,
[]
byte
(
"privkey"
))
{
t
.
Errorf
(
"Expected Privkey to be %x, got %x"
,
key
,
[]
byte
(
"privkey"
))
}
key
=
clientIdentity
.
Pubkey
()
if
!
bytes
.
Equal
(
key
,
[]
byte
(
"pubkey"
))
{
t
.
Errorf
(
"Expected Pubkey to be %x, got %x"
,
key
,
[]
byte
(
"pubkey"
))
}
clientString
:=
clientIdentity
.
String
()
expected
:=
fmt
.
Sprintf
(
"Ethereum(G)/v0.5.16/test/%s/%s"
,
runtime
.
GOOS
,
runtime
.
Version
())
if
clientString
!=
expected
{
...
...
This diff is collapsed.
Click to expand it.
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