Rebase fixes + static nodes update
This commit is contained in:
parent
2f3cebd047
commit
e731703a55
|
@ -1,7 +1,5 @@
|
|||
[
|
||||
"enode://e15869ba08a25e49be7568b951e15af5d77a472c8e4104a14a4951f99936d65f91240d5b5f23674aee44f1ac09d8adfc6a9bff75cd8c2df73a26442f313f2da4@162.243.63.248:30303",
|
||||
"enode://efe4e6899e05237180c0970aedb81cb5aecf5b200779c7c9e1f955783e8299b364c0b981c03f4c36ad5328ef972b417afde260bbf2c5a8db37ba7f5738033952@198.199.105.122:30303",
|
||||
"enode://5a5839435f48d1e3f2f907e4582f0a134e0b7857afe507073978ca32cf09ea54989dac433605047d0bc4cd19a8c80affac6876069014283aa7c7bb4954d0e623@95.85.40.211:30303",
|
||||
"enode://2f05d430b4cb1c0e2a0772d48da3a034f1b596ea7163ab80d3404802d10b7d55bde323897c2be0d36026181e1a68510ea1f42a646ef9494c27e61f61e4088b7d@188.166.229.119:30303",
|
||||
"enode://ad61a21f83f12b0ca494611650f5e4b6427784e7c62514dcb729a3d65106de6f12836813acf39bdc35c12ecfd0e230723678109fd4e7091ce389697bd7da39b4@139.59.212.114:30303"
|
||||
"enode://fc3065bb80bfced98a01441718e2b70a0353f023b9da3d57beb8f96a827402d23702b3a461e1c1b6c7a208cb09cc0aea9b7c42bf953bb8f732529c198b158db4@95.85.40.211:30303",
|
||||
"enode://5ffa3a39f95614d881e07d24e265865218c45fe73b3a5f5d05868190e385cbf60d03ac8beaa4c31b7ee84a0ec947f22c969e2dd1783041a4d7381f7774c74526@188.166.229.119:30303",
|
||||
"enode://3b020a1fd6ab980a5670975e8a7361af1732fa3fa1819b751a94b6a4265e8c52b02c608c0de1347784b834b298280b018bcf6547f47bbba63612cba0e4707ec1@139.59.212.114:30303"
|
||||
]
|
||||
|
|
36
geth/node.go
36
geth/node.go
|
@ -61,15 +61,15 @@ type SelectedExtKey struct {
|
|||
}
|
||||
|
||||
type NodeManager struct {
|
||||
currentNode *node.Node // currently running geth node
|
||||
ctx *cli.Context // the CLI context used to start the geth node
|
||||
lightEthereum *les.LightEthereum // LES service
|
||||
accountManager *accounts.Manager // the account manager attached to the currentNode
|
||||
jailedRequestQueue *JailedRequestQueue // bridge via which jail notifies node of incoming requests
|
||||
SelectedAccount *SelectedExtKey // account that was processed during the last call to SelectAccount()
|
||||
whisperService *whisper.Whisper // Whisper service
|
||||
client *rpc.ClientRestartWrapper // RPC client
|
||||
nodeStarted chan struct{} // channel to wait for node to start
|
||||
currentNode *node.Node // currently running geth node
|
||||
ctx *cli.Context // the CLI context used to start the geth node
|
||||
lightEthereum *les.LightEthereum // LES service
|
||||
accountManager *accounts.Manager // the account manager attached to the currentNode
|
||||
jailedRequestQueue *JailedRequestQueue // bridge via which jail notifies node of incoming requests
|
||||
SelectedAccount *SelectedExtKey // account that was processed during the last call to SelectAccount()
|
||||
whisperService *whisper.Whisper // Whisper service
|
||||
client *rpc.Client // RPC client
|
||||
nodeStarted chan struct{} // channel to wait for node to start
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -166,13 +166,11 @@ func (m *NodeManager) RunNode() {
|
|||
m.lightEthereum.StatusBackend.SetTransactionQueueHandler(onSendTransactionRequest)
|
||||
m.lightEthereum.StatusBackend.SetAccountsFilterHandler(onAccountsListRequest)
|
||||
|
||||
m.client = rpc.NewClientRestartWrapper(func() *rpc.Client {
|
||||
client, err := m.currentNode.Attach()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return client
|
||||
})
|
||||
var err error
|
||||
m.client, err = m.currentNode.Attach()
|
||||
if err != nil {
|
||||
glog.V(logger.Warn).Infoln("cannot get RPC client service:", ErrInvalidClient)
|
||||
}
|
||||
|
||||
// @TODO Remove after LES supports discover out of box
|
||||
m.populateStaticPeers()
|
||||
|
@ -268,16 +266,16 @@ func (m *NodeManager) LightEthereumService() (*les.LightEthereum, error) {
|
|||
return m.lightEthereum, nil
|
||||
}
|
||||
|
||||
func (m *NodeManager) HasClientRestartWrapper() bool {
|
||||
func (m *NodeManager) HasRPCClient() bool {
|
||||
return m.client != nil
|
||||
}
|
||||
|
||||
func (m *NodeManager) ClientRestartWrapper() (*rpc.ClientRestartWrapper, error) {
|
||||
func (m *NodeManager) RPCClient() (*rpc.Client, error) {
|
||||
if m == nil || !m.HasNode() {
|
||||
return nil, ErrInvalidGethNode
|
||||
}
|
||||
|
||||
if !m.HasClientRestartWrapper() {
|
||||
if !m.HasRPCClient() {
|
||||
return nil, ErrInvalidClient
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ var muPrepareTestNode sync.Mutex
|
|||
|
||||
const (
|
||||
TestDataDir = "../.ethereumtest"
|
||||
TestNodeSyncSeconds = 480
|
||||
TestNodeSyncSeconds = 60
|
||||
)
|
||||
|
||||
type NodeNotificationHandler func(jsonEvent string)
|
||||
|
@ -119,7 +119,7 @@ func PrepareTestNode() (err error) {
|
|||
if !manager.HasNode() {
|
||||
panic(ErrInvalidGethNode)
|
||||
}
|
||||
if !manager.HasClientRestartWrapper() {
|
||||
if !manager.HasRPCClient() {
|
||||
panic(ErrInvalidGethNode)
|
||||
}
|
||||
if !manager.HasWhisperService() {
|
||||
|
|
11
jail/jail.go
11
jail/jail.go
|
@ -25,7 +25,7 @@ var (
|
|||
|
||||
type Jail struct {
|
||||
sync.RWMutex
|
||||
client *rpc.ClientRestartWrapper // lazy inited on the first call to jail.ClientRestartWrapper()
|
||||
client *rpc.Client // lazy inited on the first call
|
||||
cells map[string]*JailedRuntime // jail supports running many isolated instances of jailed runtime
|
||||
statusJS string
|
||||
requestQueue *geth.JailedRequestQueue
|
||||
|
@ -108,7 +108,7 @@ func (jail *Jail) Parse(chatId string, js string) string {
|
|||
}
|
||||
|
||||
func (jail *Jail) Call(chatId string, path string, args string) string {
|
||||
_, err := jail.ClientRestartWrapper()
|
||||
_, err := jail.RPCClient()
|
||||
if err != nil {
|
||||
return printError(err.Error())
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ func (jail *Jail) GetVM(chatId string) (*otto.Otto, error) {
|
|||
|
||||
// Send will serialize the first argument, send it to the node and returns the response.
|
||||
func (jail *Jail) Send(chatId string, call otto.FunctionCall) (response otto.Value) {
|
||||
clientFactory, err := jail.ClientRestartWrapper()
|
||||
client, err := jail.RPCClient()
|
||||
if err != nil {
|
||||
return newErrorResponse(call, -32603, err.Error(), nil)
|
||||
}
|
||||
|
@ -201,7 +201,6 @@ func (jail *Jail) Send(chatId string, call otto.FunctionCall) (response otto.Val
|
|||
return newErrorResponse(call, -32603, err.Error(), nil)
|
||||
}
|
||||
|
||||
client := clientFactory.Client()
|
||||
errc := make(chan error, 1)
|
||||
errc2 := make(chan error)
|
||||
go func() {
|
||||
|
@ -252,7 +251,7 @@ func (jail *Jail) Send(chatId string, call otto.FunctionCall) (response otto.Val
|
|||
return response
|
||||
}
|
||||
|
||||
func (jail *Jail) ClientRestartWrapper() (*rpc.ClientRestartWrapper, error) {
|
||||
func (jail *Jail) RPCClient() (*rpc.Client, error) {
|
||||
if jail == nil {
|
||||
return nil, ErrInvalidJail
|
||||
}
|
||||
|
@ -267,7 +266,7 @@ func (jail *Jail) ClientRestartWrapper() (*rpc.ClientRestartWrapper, error) {
|
|||
}
|
||||
|
||||
// obtain RPC client from running node
|
||||
client, err := nodeManager.ClientRestartWrapper()
|
||||
client, err := nodeManager.RPCClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ func TestJailUnInited(t *testing.T) {
|
|||
t.Errorf("error expected, but got: %v", err)
|
||||
}
|
||||
|
||||
_, err = jailInstance.ClientRestartWrapper()
|
||||
_, err = jailInstance.RPCClient()
|
||||
if err != jail.ErrInvalidJail {
|
||||
t.Errorf("error expected, but got: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue