Rename the transaction manager package to make it more neutral (#895)

This commit is contained in:
Peter Fox 2020-01-08 16:15:55 +00:00 committed by Samer Falah
parent 3d91a6ca52
commit a603e74570
5 changed files with 29 additions and 29 deletions

View File

@ -20,7 +20,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/private"
"github.com/ethereum/go-ethereum/private/constellation"
"github.com/ethereum/go-ethereum/private/privatetransactionmanager"
)
// callmsg is the message type used for call transactions in the private state test
@ -128,7 +128,7 @@ func runConstellation() (*osExec.Cmd, error) {
if constellationErr != nil {
return nil, constellationErr
}
private.P = constellation.MustNew(cfgFile.Name())
private.P = privatetransactionmanager.MustNew(cfgFile.Name())
return constellationCmd, nil
}

View File

@ -3,7 +3,7 @@ package private
import (
"os"
"github.com/ethereum/go-ethereum/private/constellation"
"github.com/ethereum/go-ethereum/private/privatetransactionmanager"
)
type PrivateTransactionManager interface {
@ -17,7 +17,7 @@ func FromEnvironmentOrNil(name string) PrivateTransactionManager {
if cfgPath == "" {
return nil
}
return constellation.MustNew(cfgPath)
return privatetransactionmanager.MustNew(cfgPath)
}
var P = FromEnvironmentOrNil("PRIVATE_CONFIG")

View File

@ -1,4 +1,4 @@
package constellation
package privatetransactionmanager
import (
"github.com/BurntSushi/toml"

View File

@ -1,4 +1,4 @@
package constellation
package privatetransactionmanager
import (
"bytes"
@ -56,7 +56,7 @@ func RunNode(socketPath string) error {
if res.StatusCode == 200 {
return nil
}
return errors.New("Constellation Node API did not respond to upcheck request")
return errors.New("private transaction manager did not respond to upcheck request")
}
type Client struct {

View File

@ -1,4 +1,4 @@
package constellation
package privatetransactionmanager
import (
"errors"
@ -11,18 +11,18 @@ import (
"github.com/patrickmn/go-cache"
)
type Constellation struct {
node *Client
c *cache.Cache
isConstellationNotInUse bool
type PrivateTransactionManager struct {
node *Client
c *cache.Cache
isPrivateTransactionManagerNotInUse bool
}
var (
errPrivateTransactionManagerNotUsed = errors.New("private transaction manager not in use")
)
func (g *Constellation) Send(data []byte, from string, to []string) (out []byte, err error) {
if g.isConstellationNotInUse {
func (g *PrivateTransactionManager) Send(data []byte, from string, to []string) (out []byte, err error) {
if g.isPrivateTransactionManagerNotInUse {
return nil, errPrivateTransactionManagerNotUsed
}
out, err = g.node.SendPayload(data, from, to)
@ -33,8 +33,8 @@ func (g *Constellation) Send(data []byte, from string, to []string) (out []byte,
return out, nil
}
func (g *Constellation) SendSignedTx(data []byte, to []string) (out []byte, err error) {
if g.isConstellationNotInUse {
func (g *PrivateTransactionManager) SendSignedTx(data []byte, to []string) (out []byte, err error) {
if g.isPrivateTransactionManagerNotInUse {
return nil, errPrivateTransactionManagerNotUsed
}
out, err = g.node.SendSignedPayload(data, to)
@ -44,8 +44,8 @@ func (g *Constellation) SendSignedTx(data []byte, to []string) (out []byte, err
return out, nil
}
func (g *Constellation) Receive(data []byte) ([]byte, error) {
if g.isConstellationNotInUse {
func (g *PrivateTransactionManager) Receive(data []byte) ([]byte, error) {
if g.isPrivateTransactionManagerNotInUse {
return nil, nil
}
if len(data) == 0 {
@ -65,7 +65,7 @@ func (g *Constellation) Receive(data []byte) ([]byte, error) {
return pl, nil
}
func New(path string) (*Constellation, error) {
func New(path string) (*PrivateTransactionManager, error) {
info, err := os.Lstat(path)
if err != nil {
return nil, err
@ -88,24 +88,24 @@ func New(path string) (*Constellation, error) {
if err != nil {
return nil, err
}
return &Constellation{
node: n,
c: cache.New(5*time.Minute, 5*time.Minute),
isConstellationNotInUse: false,
return &PrivateTransactionManager{
node: n,
c: cache.New(5*time.Minute, 5*time.Minute),
isPrivateTransactionManagerNotInUse: false,
}, nil
}
func MustNew(path string) *Constellation {
func MustNew(path string) *PrivateTransactionManager {
if strings.EqualFold(path, "ignore") {
return &Constellation{
node: nil,
c: nil,
isConstellationNotInUse: true,
return &PrivateTransactionManager{
node: nil,
c: nil,
isPrivateTransactionManagerNotInUse: true,
}
}
g, err := New(path)
if err != nil {
panic(fmt.Sprintf("MustNew: Failed to connect to Constellation (%s): %v", path, err))
panic(fmt.Sprintf("MustNew: Failed to connect to private transaction manager (%s): %v", path, err))
}
return g
}