2017-09-27 20:16:21 -07:00
|
|
|
// Copyright 2017 AMIS Technologies
|
|
|
|
// This file is part of the go-ethereum library.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
2017-10-16 20:24:02 -07:00
|
|
|
"crypto/ecdsa"
|
2017-09-27 20:16:21 -07:00
|
|
|
"errors"
|
|
|
|
"math/big"
|
|
|
|
"time"
|
|
|
|
|
2018-11-05 13:12:05 -08:00
|
|
|
"github.com/jpmorganchase/istanbul-tools/client"
|
|
|
|
"github.com/jpmorganchase/istanbul-tools/container"
|
|
|
|
"github.com/jpmorganchase/istanbul-tools/k8s"
|
2017-09-27 20:16:21 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
type metricEthereum struct {
|
|
|
|
container.Ethereum
|
|
|
|
txStartCh chan *txInfo
|
|
|
|
metricsMgr *metricsManager
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *metricEthereum) NewClient() client.Client {
|
|
|
|
return &metricClient{
|
|
|
|
Client: e.Ethereum.NewClient(),
|
|
|
|
txStartCh: e.txStartCh,
|
|
|
|
metricsMgr: e.metricsMgr,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-16 20:24:02 -07:00
|
|
|
func (eth *metricEthereum) AccountKeys() []*ecdsa.PrivateKey {
|
|
|
|
transactor, ok := eth.Ethereum.(k8s.Transactor)
|
|
|
|
if !ok {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return transactor.AccountKeys()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (eth *metricEthereum) SendTransactions(client client.Client, accounts []*ecdsa.PrivateKey, amount *big.Int, duration, frequnce time.Duration) error {
|
|
|
|
transactor, ok := eth.Ethereum.(k8s.Transactor)
|
|
|
|
if !ok {
|
|
|
|
return errors.New("Not support Transactor interface.")
|
|
|
|
}
|
|
|
|
return transactor.SendTransactions(client, accounts, amount, duration, frequnce)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (eth *metricEthereum) PreloadTransactions(client client.Client, accounts []*ecdsa.PrivateKey, amount *big.Int, txCount int) error {
|
2017-09-27 20:16:21 -07:00
|
|
|
transactor, ok := eth.Ethereum.(k8s.Transactor)
|
|
|
|
if !ok {
|
|
|
|
return errors.New("Not support Transactor interface.")
|
|
|
|
}
|
2017-10-16 20:24:02 -07:00
|
|
|
return transactor.PreloadTransactions(client, accounts, amount, txCount)
|
|
|
|
|
2017-09-27 20:16:21 -07:00
|
|
|
}
|