Skip to content

Commit

Permalink
Dynamic validators should work now
Browse files Browse the repository at this point in the history
  • Loading branch information
dukei committed Aug 20, 2018
1 parent 06c3517 commit 531dd89
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 26 deletions.
26 changes: 13 additions & 13 deletions Gopkg.lock

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

6 changes: 3 additions & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ ignored = ["github.com/ethereum/go-ethereum/*"]

[[constraint]]
name = "github.com/ethereum/go-ethereum"
source = "github.com/tendermint/go-ethereum.git"
version = "f1.8.6"
source = "github.com/ya-enot/go-ethereum.git"
branch = "dukei-develop-f1.8.6"

[[constraint]]
name = "gopkg.in/urfave/cli.v1"
Expand Down Expand Up @@ -57,4 +57,4 @@ ignored = ["github.com/ethereum/go-ethereum/*"]
name = "github.com/ethereum/go-ethereum"
unused-packages = false
go-tests = false
non-go = false

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GOTOOLS := \
github.com/karalabe/xgo \
github.com/alecthomas/gometalinter

PACKAGES := $(shell glide novendor)
PACKAGES := $(go list ./... | grep -v vendor)

BUILD_TAGS? := ethermint

Expand Down
2 changes: 1 addition & 1 deletion app/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (app *EthermintApplication) SetValidators(validators []abciTypes.Validator)
func (app *EthermintApplication) GetUpdatedValidators() abciTypes.ResponseEndBlock {
if app.validators != nil {
compvals, err := app.validators.GetCompactedValidators()
if err != nil && len(compvals.ValidatorsCompacted) > 0 {
if err == nil && len(compvals.ValidatorsCompacted) > 0 {
newValidators := getUpdatedValidators(compvals.ValidatorsCompacted, compvals.ValidatorsIndex)
return abciTypes.ResponseEndBlock{ValidatorUpdates: newValidators}
} else {
Expand Down
3 changes: 2 additions & 1 deletion ethereum/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ type Backend struct {
ethConfig *eth.Config

// txBroadcastLoop subscription
txSub *event.TypeMuxSubscription
txCh chan core.TxPreEvent
txSub event.Subscription

// EthState
es *EthState
Expand Down
23 changes: 18 additions & 5 deletions ethereum/txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,32 @@ import (
rpcClient "github.com/tendermint/tendermint/rpc/lib/client"
)

const (
// txChanSize is the size of channel listening to TxPreEvent.
// The number is referenced from the size of tx pool.
txChanSize = 4096
)

//----------------------------------------------------------------------
// Transactions sent via the go-ethereum rpc need to be routed to tendermint

// listen for txs and forward to tendermint
func (b *Backend) txBroadcastLoop() {
b.txSub = b.ethereum.EventMux().Subscribe(core.TxPreEvent{})
b.txCh = make(chan core.TxPreEvent, txChanSize)
b.txSub = b.ethereum.TxPool().SubscribeTxPreEvent(b.txCh)

waitForServer(b.client)

for obj := range b.txSub.Chan() {
event := obj.Data.(core.TxPreEvent)
if err := b.BroadcastTx(event.Tx); err != nil {
log.Error("Broadcast error", "err", err)
for {
select {
case event := <-b.txCh:
if err := b.BroadcastTx(event.Tx); err != nil {
log.Error("Broadcast error", "err", err)
}

// Err() channel will be closed when unsubscribing.
case <-b.txSub.Err():
return
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions ethereum/validators/validatorsManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
)

var (
MainNetAddress = common.HexToAddress("0x9e05b78ea853a4b093694645561c4bfc953a6f62")
TestNetAddress = common.HexToAddress("0x9e05b78ea853a4b093694645561c4bfc953a6f62")
MainNetAddress = common.HexToAddress("0xb6b29ef90120bec597939e0eda6b8a9164f75deb")
TestNetAddress = common.HexToAddress("0xb6b29ef90120bec597939e0eda6b8a9164f75deb")
)

type ValidatorsManager struct {
Expand Down

0 comments on commit 531dd89

Please sign in to comment.