Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
vicotor
mybee
Commits
ce425318
Unverified
Commit
ce425318
authored
Sep 28, 2020
by
Ralph Pichler
Committed by
GitHub
Sep 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ethereum address to /addresses (#771)
parent
fbe2a596
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
17 deletions
+32
-17
SwarmCommon.yaml
openapi/SwarmCommon.yaml
+2
-0
debugapi.go
pkg/debugapi/debugapi.go
+4
-1
debugapi_test.go
pkg/debugapi/debugapi_test.go
+15
-13
p2p.go
pkg/debugapi/p2p.go
+3
-0
p2p_test.go
pkg/debugapi/p2p_test.go
+7
-2
node.go
pkg/node/node.go
+1
-1
No files found.
openapi/SwarmCommon.yaml
View file @
ce425318
...
...
@@ -28,6 +28,8 @@ components:
type
:
array
items
:
$ref
:
'
#/components/schemas/P2PUnderlay'
ethereum
:
$ref
:
'
#/components/schemas/EthereumAddress'
public_key
:
$ref
:
'
#/components/schemas/PublicKey'
...
...
pkg/debugapi/debugapi.go
View file @
ce425318
...
...
@@ -8,6 +8,7 @@ import (
"crypto/ecdsa"
"net/http"
"github.com/ethereum/go-ethereum/common"
"github.com/ethersphere/bee/pkg/accounting"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p"
...
...
@@ -31,6 +32,7 @@ type Service interface {
type
server
struct
{
Overlay
swarm
.
Address
PublicKey
ecdsa
.
PublicKey
EthereumAddress
common
.
Address
P2P
p2p
.
DebugService
Pingpong
pingpong
.
Interface
TopologyDriver
topology
.
Driver
...
...
@@ -47,10 +49,11 @@ type server struct {
http
.
Handler
}
func
New
(
overlay
swarm
.
Address
,
publicKey
ecdsa
.
PublicKey
,
p2p
p2p
.
DebugService
,
pingpong
pingpong
.
Interface
,
topologyDriver
topology
.
Driver
,
storer
storage
.
Storer
,
logger
logging
.
Logger
,
tracer
*
tracing
.
Tracer
,
tags
*
tags
.
Tags
,
accounting
accounting
.
Interface
,
settlement
settlement
.
Interface
,
chequebookEnabled
bool
,
swap
swap
.
ApiInterface
,
chequebook
chequebook
.
Service
)
Service
{
func
New
(
overlay
swarm
.
Address
,
publicKey
ecdsa
.
PublicKey
,
ethereumAddress
common
.
Address
,
p2p
p2p
.
DebugService
,
pingpong
pingpong
.
Interface
,
topologyDriver
topology
.
Driver
,
storer
storage
.
Storer
,
logger
logging
.
Logger
,
tracer
*
tracing
.
Tracer
,
tags
*
tags
.
Tags
,
accounting
accounting
.
Interface
,
settlement
settlement
.
Interface
,
chequebookEnabled
bool
,
swap
swap
.
ApiInterface
,
chequebook
chequebook
.
Service
)
Service
{
s
:=
&
server
{
Overlay
:
overlay
,
PublicKey
:
publicKey
,
EthereumAddress
:
ethereumAddress
,
P2P
:
p2p
,
Pingpong
:
pingpong
,
TopologyDriver
:
topologyDriver
,
...
...
pkg/debugapi/debugapi_test.go
View file @
ce425318
...
...
@@ -12,6 +12,7 @@ import (
"net/url"
"testing"
"github.com/ethereum/go-ethereum/common"
accountingmock
"github.com/ethersphere/bee/pkg/accounting/mock"
"github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/logging"
...
...
@@ -30,18 +31,19 @@ import (
)
type
testServerOptions
struct
{
Overlay
swarm
.
Address
PublicKey
ecdsa
.
PublicKey
P2P
*
p2pmock
.
Service
Pingpong
pingpong
.
Interface
Storer
storage
.
Storer
Resolver
resolver
.
Interface
TopologyOpts
[]
topologymock
.
Option
Tags
*
tags
.
Tags
AccountingOpts
[]
accountingmock
.
Option
SettlementOpts
[]
settlementmock
.
Option
ChequebookOpts
[]
chequebookmock
.
Option
SwapOpts
[]
swapmock
.
Option
Overlay
swarm
.
Address
PublicKey
ecdsa
.
PublicKey
EthereumAddress
common
.
Address
P2P
*
p2pmock
.
Service
Pingpong
pingpong
.
Interface
Storer
storage
.
Storer
Resolver
resolver
.
Interface
TopologyOpts
[]
topologymock
.
Option
Tags
*
tags
.
Tags
AccountingOpts
[]
accountingmock
.
Option
SettlementOpts
[]
settlementmock
.
Option
ChequebookOpts
[]
chequebookmock
.
Option
SwapOpts
[]
swapmock
.
Option
}
type
testServer
struct
{
...
...
@@ -55,7 +57,7 @@ func newTestServer(t *testing.T, o testServerOptions) *testServer {
settlement
:=
settlementmock
.
NewSettlement
(
o
.
SettlementOpts
...
)
chequebook
:=
chequebookmock
.
NewChequebook
(
o
.
ChequebookOpts
...
)
swapserv
:=
swapmock
.
NewApiInterface
(
o
.
SwapOpts
...
)
s
:=
debugapi
.
New
(
o
.
Overlay
,
o
.
PublicKey
,
o
.
P2P
,
o
.
Pingpong
,
topologyDriver
,
o
.
Storer
,
logging
.
New
(
ioutil
.
Discard
,
0
),
nil
,
o
.
Tags
,
acc
,
settlement
,
true
,
swapserv
,
chequebook
)
s
:=
debugapi
.
New
(
o
.
Overlay
,
o
.
PublicKey
,
o
.
EthereumAddress
,
o
.
P2P
,
o
.
Pingpong
,
topologyDriver
,
o
.
Storer
,
logging
.
New
(
ioutil
.
Discard
,
0
),
nil
,
o
.
Tags
,
acc
,
settlement
,
true
,
swapserv
,
chequebook
)
ts
:=
httptest
.
NewServer
(
s
)
t
.
Cleanup
(
ts
.
Close
)
...
...
pkg/debugapi/p2p.go
View file @
ce425318
...
...
@@ -8,6 +8,7 @@ import (
"encoding/hex"
"net/http"
"github.com/ethereum/go-ethereum/common"
"github.com/ethersphere/bee/pkg/crypto"
"github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/swarm"
...
...
@@ -17,6 +18,7 @@ import (
type
addressesResponse
struct
{
Overlay
swarm
.
Address
`json:"overlay"`
Underlay
[]
multiaddr
.
Multiaddr
`json:"underlay"`
Ethereum
common
.
Address
`json:"ethereum"`
PublicKey
string
`json:"public_key"`
}
...
...
@@ -30,6 +32,7 @@ func (s *server) addressesHandler(w http.ResponseWriter, r *http.Request) {
jsonhttp
.
OK
(
w
,
addressesResponse
{
Overlay
:
s
.
Overlay
,
Underlay
:
underlay
,
Ethereum
:
s
.
EthereumAddress
,
PublicKey
:
hex
.
EncodeToString
(
crypto
.
EncodeSecp256k1PublicKey
(
&
s
.
PublicKey
)),
})
}
pkg/debugapi/p2p_test.go
View file @
ce425318
...
...
@@ -10,6 +10,7 @@ import (
"net/http"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethersphere/bee/pkg/crypto"
"github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/jsonhttp"
...
...
@@ -31,9 +32,12 @@ func TestAddresses(t *testing.T) {
mustMultiaddr
(
t
,
"/ip4/127.0.0.1/udp/7071/quic/p2p/16Uiu2HAmTBuJT9LvNmBiQiNoTsxE5mtNy6YG3paw79m94CRa9sRb"
),
}
ethereumAddress
:=
common
.
HexToAddress
(
"abcd"
)
testServer
:=
newTestServer
(
t
,
testServerOptions
{
PublicKey
:
privateKey
.
PublicKey
,
Overlay
:
overlay
,
PublicKey
:
privateKey
.
PublicKey
,
Overlay
:
overlay
,
EthereumAddress
:
ethereumAddress
,
P2P
:
mock
.
New
(
mock
.
WithAddressesFunc
(
func
()
([]
multiaddr
.
Multiaddr
,
error
)
{
return
addresses
,
nil
})),
...
...
@@ -45,6 +49,7 @@ func TestAddresses(t *testing.T) {
Overlay
:
overlay
,
Underlay
:
addresses
,
PublicKey
:
hex
.
EncodeToString
(
crypto
.
EncodeSecp256k1PublicKey
(
&
privateKey
.
PublicKey
)),
Ethereum
:
ethereumAddress
,
}),
)
})
...
...
pkg/node/node.go
View file @
ce425318
...
...
@@ -439,7 +439,7 @@ func NewBee(addr string, swarmAddress swarm.Address, publicKey ecdsa.PublicKey,
if
o
.
DebugAPIAddr
!=
""
{
// Debug API server
debugAPIService
:=
debugapi
.
New
(
swarmAddress
,
publicKey
,
p2ps
,
pingPong
,
kad
,
storer
,
logger
,
tracer
,
tagg
,
acc
,
settlement
,
o
.
SwapEnable
,
swapService
,
chequebookService
)
debugAPIService
:=
debugapi
.
New
(
swarmAddress
,
publicKey
,
overlayEthAddress
,
p2ps
,
pingPong
,
kad
,
storer
,
logger
,
tracer
,
tagg
,
acc
,
settlement
,
o
.
SwapEnable
,
swapService
,
chequebookService
)
// register metrics from components
debugAPIService
.
MustRegisterMetrics
(
p2ps
.
Metrics
()
...
)
debugAPIService
.
MustRegisterMetrics
(
pingPong
.
Metrics
()
...
)
...
...
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