aboutsummaryrefslogtreecommitdiff
path: root/coreth.go
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-08-15 01:09:01 -0400
committerDeterminant <[email protected]>2019-08-15 01:09:01 -0400
commit0cfa95ffa018041e53b056365a66fee32235779f (patch)
treeb512d51597c0a54f511ffd007d365ca1ec713978 /coreth.go
parentd271cc649e34963507411d4915512353ae1780e4 (diff)
apply the stupid gofmt
Diffstat (limited to 'coreth.go')
-rw-r--r--coreth.go105
1 files changed, 52 insertions, 53 deletions
diff --git a/coreth.go b/coreth.go
index 06471a9..49864c7 100644
--- a/coreth.go
+++ b/coreth.go
@@ -1,19 +1,19 @@
package coreth
import (
- "io"
- "os"
- "crypto/ecdsa"
-
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/event"
- "github.com/Determinant/coreth/eth"
- "github.com/Determinant/coreth/node"
- "github.com/Determinant/coreth/consensus/dummy"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/log"
- "github.com/mattn/go-isatty"
+ "crypto/ecdsa"
+ "io"
+ "os"
+
+ "github.com/Determinant/coreth/consensus/dummy"
+ "github.com/Determinant/coreth/eth"
+ "github.com/Determinant/coreth/node"
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/event"
+ "github.com/ethereum/go-ethereum/log"
+ "github.com/mattn/go-isatty"
)
type Tx = types.Transaction
@@ -21,81 +21,80 @@ type Block = types.Block
type Hash = common.Hash
type ETHChain struct {
- backend *eth.Ethereum
- cb *dummy.ConsensusCallbacks
+ backend *eth.Ethereum
+ cb *dummy.ConsensusCallbacks
}
-
func isLocalBlock(block *types.Block) bool {
- return false
+ return false
}
func NewETHChain(config *eth.Config, etherBase *common.Address) *ETHChain {
- if config == nil {
- config = &eth.DefaultConfig
- }
- mux := new(event.TypeMux)
- ctx := node.NewServiceContext(mux)
- cb := new(dummy.ConsensusCallbacks)
- backend, _ := eth.New(&ctx, config, cb)
- chain := &ETHChain { backend: backend, cb: cb }
- if etherBase == nil {
- etherBase = &common.Address{
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- }
- }
- backend.SetEtherbase(*etherBase)
- return chain
+ if config == nil {
+ config = &eth.DefaultConfig
+ }
+ mux := new(event.TypeMux)
+ ctx := node.NewServiceContext(mux)
+ cb := new(dummy.ConsensusCallbacks)
+ backend, _ := eth.New(&ctx, config, cb)
+ chain := &ETHChain{backend: backend, cb: cb}
+ if etherBase == nil {
+ etherBase = &common.Address{
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ }
+ }
+ backend.SetEtherbase(*etherBase)
+ return chain
}
func (self *ETHChain) Start() {
- self.backend.StartMining(0)
+ self.backend.StartMining(0)
}
func (self *ETHChain) Stop() {
- self.backend.StopPart()
+ self.backend.StopPart()
}
func (self *ETHChain) GenBlock() {
- self.backend.Miner().GenBlock()
+ self.backend.Miner().GenBlock()
}
func (self *ETHChain) AddRemoteTxs(txs []*types.Transaction) []error {
- return self.backend.TxPool().AddRemotes(txs)
+ return self.backend.TxPool().AddRemotes(txs)
}
func (self *ETHChain) AddLocalTxs(txs []*types.Transaction) []error {
- return self.backend.TxPool().AddLocals(txs)
+ return self.backend.TxPool().AddLocals(txs)
}
func (self *ETHChain) SetOnSeal(cb func(*types.Block)) {
- self.cb.OnSeal = cb
+ self.cb.OnSeal = cb
}
type Key struct {
- Address common.Address
+ Address common.Address
PrivateKey *ecdsa.PrivateKey
}
func NewKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key {
- key := &Key{
- Address: crypto.PubkeyToAddress(privateKeyECDSA.PublicKey),
- PrivateKey: privateKeyECDSA,
- }
- return key
+ key := &Key{
+ Address: crypto.PubkeyToAddress(privateKeyECDSA.PublicKey),
+ PrivateKey: privateKeyECDSA,
+ }
+ return key
}
func NewKey(rand io.Reader) (*Key, error) {
- privateKeyECDSA, err := ecdsa.GenerateKey(crypto.S256(), rand)
- if err != nil {
- return nil, err
- }
- return NewKeyFromECDSA(privateKeyECDSA), nil
+ privateKeyECDSA, err := ecdsa.GenerateKey(crypto.S256(), rand)
+ if err != nil {
+ return nil, err
+ }
+ return NewKeyFromECDSA(privateKeyECDSA), nil
}
func init() {
- usecolor := (isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb"
- glogger := log.StreamHandler(io.Writer(os.Stderr), log.TerminalFormat(usecolor))
- log.Root().SetHandler(glogger)
+ usecolor := (isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb"
+ glogger := log.StreamHandler(io.Writer(os.Stderr), log.TerminalFormat(usecolor))
+ log.Root().SetHandler(glogger)
}