Skip to content

Commit

Permalink
Merge pull request #9 from getamis/release-v1.0.1
Browse files Browse the repository at this point in the history
Release v1.0.1
  • Loading branch information
bailantaotao authored Nov 13, 2017
2 parents 0de4ceb + a144346 commit e1c8455
Show file tree
Hide file tree
Showing 144 changed files with 2,033 additions and 12,215 deletions.
10 changes: 10 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ import (
ethrpc "github.com/ethereum/go-ethereum/rpc"
)

// client defines typed wrappers for the Ethereum RPC API.
type client struct {
*ethclient.Client
rpc *ethrpc.Client
}

// Dial connects a client to the given URL.
func Dial(rawurl string) (Client, error) {
c, err := ethrpc.Dial(rawurl)
if err != nil {
Expand All @@ -40,13 +42,15 @@ func Dial(rawurl string) (Client, error) {
return NewClient(c), nil
}

// NewClient creates a client that uses the given RPC client.
func NewClient(rpc *ethrpc.Client) Client {
return &client{
Client: ethclient.NewClient(rpc),
rpc: rpc,
}
}

// Close closes an existing RPC connection.
func (c *client) Close() {
c.rpc.Close()
}
Expand All @@ -62,6 +66,7 @@ func (c *client) SendRawTransaction(ctx context.Context, tx *types.Transaction)
return c.SendTransaction(ctx, tx)
}

// BlockNumber returns the current block number.
func (c *client) BlockNumber(ctx context.Context) (*big.Int, error) {
var r string
err := c.rpc.CallContext(ctx, &r, "eth_blockNumber")
Expand All @@ -75,6 +80,7 @@ func (c *client) BlockNumber(ctx context.Context) (*big.Int, error) {
// ----------------------------------------------------------------------------
// admin

// AddPeer connects to the given nodeURL.
func (c *client) AddPeer(ctx context.Context, nodeURL string) error {
var r bool
// TODO: Result needs to be verified
Expand All @@ -86,6 +92,7 @@ func (c *client) AddPeer(ctx context.Context, nodeURL string) error {
return err
}

// AdminPeers returns the number of connected peers.
func (c *client) AdminPeers(ctx context.Context) ([]*p2p.PeerInfo, error) {
var r []*p2p.PeerInfo
// The response data type are bytes, but we cannot parse...
Expand All @@ -96,6 +103,7 @@ func (c *client) AdminPeers(ctx context.Context) ([]*p2p.PeerInfo, error) {
return r, err
}

// NodeInfo gathers and returns a collection of metadata known about the host.
func (c *client) NodeInfo(ctx context.Context) (*p2p.PeerInfo, error) {
var r *p2p.PeerInfo
err := c.rpc.CallContext(ctx, &r, "admin_nodeInfo")
Expand All @@ -108,6 +116,7 @@ func (c *client) NodeInfo(ctx context.Context) (*p2p.PeerInfo, error) {
// ----------------------------------------------------------------------------
// miner

// StartMining starts mining operation.
func (c *client) StartMining(ctx context.Context) error {
var r []byte
// TODO: Result needs to be verified
Expand All @@ -119,6 +128,7 @@ func (c *client) StartMining(ctx context.Context) error {
return err
}

// StopMining stops mining.
func (c *client) StopMining(ctx context.Context) error {
err := c.rpc.CallContext(ctx, nil, "miner_stop", nil)
if err != nil {
Expand Down
Binary file removed eth-client
Binary file not shown.
12 changes: 5 additions & 7 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions glide.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package: github.com/getamis/eth-client
import:
- package: github.com/ethereum/go-ethereum
version: istanbul/develop
repo: [email protected]:getamis/go-ethereum
version: v1.7.2
repo: [email protected]:ethereum/go-ethereum
subpackages:
- common
- common/hexutil
Expand Down
4 changes: 4 additions & 0 deletions istanbul/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ import (
ethClient "github.com/getamis/eth-client/client"
)

// client defines typed wrappers for the eth-client.
type client struct {
ethClient.Client
rpc *rpc.Client
}

// Dial connects a client to the given URL.
func Dial(rawurl string) (Client, error) {
rc, err := rpc.Dial(rawurl)
if err != nil {
Expand All @@ -48,6 +50,7 @@ func Dial(rawurl string) (Client, error) {
return c, nil
}

// Propose injects a new authorization candidate that the validator will attempt to push through.
func (c *client) ProposeValidator(ctx context.Context, address common.Address, auth bool) error {
var r []byte
err := c.rpc.CallContext(ctx, &r, "istanbul_propose", address, auth)
Expand All @@ -71,6 +74,7 @@ func (addrs addresses) Swap(i, j int) {
addrs[i], addrs[j] = addrs[j], addrs[i]
}

// GetValidators retrieves the list of authorized validators at the specified block.
func (c *client) GetValidators(ctx context.Context, blockNumbers *big.Int) ([]common.Address, error) {
var r []common.Address
err := c.rpc.CallContext(ctx, &r, "istanbul_getValidators", toNumArg(blockNumbers))
Expand Down
1 change: 1 addition & 0 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func init() {
)
}

// New returns a new logger with the given context.
func New(ctx ...interface{}) log15.Logger {
return defaultLogger.New(ctx...)
}
5 changes: 5 additions & 0 deletions quorum/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import (
ethClient "github.com/getamis/eth-client/client"
)

// client defines typed wrappers for the eth-client.
type client struct {
ethClient.Client
rpc *rpc.Client
}

// Dial connects a client to the given URL.
func Dial(rawurl string) (Client, error) {
rc, err := rpc.Dial(rawurl)
if err != nil {
Expand All @@ -45,6 +47,7 @@ func Dial(rawurl string) (Client, error) {
return c, nil
}

// CreateContract creates a contract with the given parameters.
func (c *client) CreateContract(ctx context.Context, from common.Address, bytecode string, gas *big.Int) (txHash string, err error) {
var hex hexutil.Bytes
arg := map[string]interface{}{
Expand All @@ -58,6 +61,8 @@ func (c *client) CreateContract(ctx context.Context, from common.Address, byteco
return
}

// CreatePrivateContract creates a private contract with the given parameters. The related information can refer
// to https://github.com/jpmorganchase/quorum/wiki/Using-Quorum#creating-private-transactionscontracts.
func (c *client) CreatePrivateContract(ctx context.Context, from common.Address, bytecode string, gas *big.Int, privateFor []string) (txHash string, err error) {
var hex hexutil.Bytes
arg := map[string]interface{}{
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/ethereum/go-ethereum/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/ethereum/go-ethereum/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/ethereum/go-ethereum/VERSION

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e1c8455

Please sign in to comment.