Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
a3f39a29
Commit
a3f39a29
authored
8 years ago
by
Silas Davis
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #292 from benjaminbollen/eris-client-part6
client: ListValidators, GetName
parents
a7086aa1
3a3fff19
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
client/client.go
+24
-3
24 additions, 3 deletions
client/client.go
client/mock/client_mock.go
+15
-0
15 additions, 0 deletions
client/mock/client_mock.go
consensus/types/validator.go
+10
-2
10 additions, 2 deletions
consensus/types/validator.go
with
49 additions
and
5 deletions
client/client.go
+
24
−
3
View file @
a3f39a29
...
...
@@ -22,6 +22,7 @@ import (
"github.com/tendermint/go-rpc/client"
acc
"github.com/eris-ltd/eris-db/account"
consensus_types
"github.com/eris-ltd/eris-db/consensus/types"
tendermint_client
"github.com/eris-ltd/eris-db/rpc/tendermint/client"
tendermint_types
"github.com/eris-ltd/eris-db/rpc/tendermint/core/types"
"github.com/eris-ltd/eris-db/txs"
...
...
@@ -36,6 +37,10 @@ type NodeClient interface {
GetAccount
(
address
[]
byte
)
(
*
acc
.
Account
,
error
)
QueryContract
(
callerAddress
,
calleeAddress
,
data
[]
byte
)
(
ret
[]
byte
,
gasUsed
int64
,
err
error
)
QueryContractCode
(
address
,
code
,
data
[]
byte
)
(
ret
[]
byte
,
gasUsed
int64
,
err
error
)
DumpStorage
(
address
[]
byte
)
(
storage
*
core_types
.
Storage
,
err
error
)
GetName
(
name
string
)
(
owner
[]
byte
,
data
string
,
expirationBlock
int
,
err
error
)
ListValidators
()
(
blockHeight
int
,
bondedValidators
,
unbondingValidators
[]
consensus_types
.
Validator
,
err
error
)
}
// NOTE [ben] Compiler check to ensure ErisNodeClient successfully implements
...
...
@@ -155,21 +160,37 @@ func (erisNodeClient *ErisNodeClient) DumpStorage(address []byte) (storage *core
//--------------------------------------------------------------------------------------------
// Name registry
func
(
erisNodeClient
*
ErisNodeClient
)
GetName
(
name
string
)
(
owner
[]
byte
,
data
[]
byte
,
expirationBlock
int
,
err
error
)
{
func
(
erisNodeClient
*
ErisNodeClient
)
GetName
(
name
string
)
(
owner
[]
byte
,
data
string
,
expirationBlock
int
,
err
error
)
{
client
:=
rpcclient
.
NewClientURI
(
erisNodeClient
.
broadcastRPC
)
entryResult
,
err
:=
tendermint_client
.
GetName
(
client
,
name
)
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"Error connecting to node (%s) to get name registrar entry for name (%s)"
,
erisNodeClient
.
broadcastRPC
,
name
)
return
nil
,
nil
,
0
,
err
return
nil
,
""
,
0
,
err
}
// unwrap return results
owner
=
make
([]
byte
,
len
(
entryResult
.
Owner
))
copy
(
owner
,
entryResult
.
Owner
)
data
=
[]
byte
(
entryResult
.
Data
)
data
=
entryResult
.
Data
expirationBlock
=
entryResult
.
Expires
return
}
//--------------------------------------------------------------------------------------------
func
(
erisNodeClient
*
ErisNodeClient
)
ListValidators
()
(
blockHeight
int
,
bondedValidators
[]
consensus_types
.
Validator
,
unbondingValidators
[]
consensus_types
.
Validator
,
err
error
)
{
client
:=
rpcclient
.
NewClientURI
(
erisNodeClient
.
broadcastRPC
)
validatorsResult
,
err
:=
tendermint_client
.
ListValidators
(
client
)
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"Error connecting to node (%s) to get validators"
,
erisNodeClient
.
broadcastRPC
)
return
0
,
nil
,
nil
,
err
}
// unwrap return results
blockHeight
=
validatorsResult
.
BlockHeight
bondedValidators
=
validatorsResult
.
BondedValidators
unbondingValidators
=
validatorsResult
.
UnbondingValidators
return
}
This diff is collapsed.
Click to expand it.
client/mock/client_mock.go
+
15
−
0
View file @
a3f39a29
...
...
@@ -19,6 +19,8 @@ package mock
import
(
"github.com/tendermint/go-crypto"
consensus_types
"github.com/eris-ltd/eris-db/consensus/types"
core_types
"github.com/eris-ltd/eris-db/core/types"
acc
"github.com/eris-ltd/eris-db/account"
.
"github.com/eris-ltd/eris-db/client"
"github.com/eris-ltd/eris-db/txs"
...
...
@@ -100,3 +102,16 @@ func (mock *MockNodeClient) QueryContractCode(address, code, data []byte) (ret [
ret
=
make
([]
byte
,
0
)
return
ret
,
0
,
nil
}
func
(
mock
*
MockNodeClient
)
DumpStorage
(
address
[]
byte
)
(
storage
*
core_types
.
Storage
,
err
error
)
{
return
nil
,
nil
}
func
(
mock
*
MockNodeClient
)
GetName
(
name
string
)
(
owner
[]
byte
,
data
string
,
expirationBlock
int
,
err
error
)
{
return
nil
,
""
,
0
,
nil
}
func
(
mock
*
MockNodeClient
)
ListValidators
()
(
blockHeight
int
,
bondedValidators
,
unbondingValidators
[]
consensus_types
.
Validator
,
err
error
){
return
0
,
nil
,
nil
,
nil
}
This diff is collapsed.
Click to expand it.
consensus/types/validator.go
+
10
−
2
View file @
a3f39a29
...
...
@@ -12,6 +12,7 @@ var _ = wire.RegisterInterface(
type
Validator
interface
{
AssertIsValidator
()
Address
()
[]
byte
}
// Anticipating moving to our own definition of Validator, or at least
...
...
@@ -20,11 +21,18 @@ type TendermintValidator struct {
*
tendermint_types
.
Validator
`json:"validator"`
}
func
(
validator
*
TendermintValidator
)
AssertIsValidator
()
{
var
_
Validator
=
(
*
TendermintValidator
)(
nil
)
func
(
tendermintValidator
*
TendermintValidator
)
AssertIsValidator
()
{
}
var
_
Validator
=
(
*
TendermintValidator
)(
nil
)
func
(
tendermintValidator
*
TendermintValidator
)
Address
()
[]
byte
{
return
tendermintValidator
.
Address
()
}
//-------------------------------------------------------------------------------------
// Helper function for TendermintValidator
func
FromTendermintValidators
(
tmValidators
[]
*
tendermint_types
.
Validator
)
[]
Validator
{
validators
:=
make
([]
Validator
,
len
(
tmValidators
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment