Skip to content

Commit

Permalink
added admin.etcdGetWork() and admin.etcdDeleteWork() commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sadoci committed Sep 23, 2019
1 parent fab71b0 commit 0c14910
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
10 changes: 10 additions & 0 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ func (api *PrivateAdminAPI) EtcdMoveLeader(name string) error {
return metaapi.EtcdMoveLeader(name)
}

// Get the latest logged work
func (api *PrivateAdminAPI) EtcdGetWork() (string, error) {
return metaapi.EtcdGetWork()
}

// Remove the latest logged work
func (api *PrivateAdminAPI) EtcdDeleteWork() error {
return metaapi.EtcdDeleteWork()
}

// Synchronize with the peer
func (api *PrivateAdminAPI) SynchroniseWith(id enode.ID) error {
return api.eth.protocolManager.SynchroniseWith(id)
Expand Down
10 changes: 10 additions & 0 deletions internal/web3ext/web3ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ web3._extend({
params: 1,
inputFormatter: [null]
}),
new web3._extend.Method({
name: 'etcdGetWork',
call: 'admin_etcdGetWork',
params: 0
}),
new web3._extend.Method({
name: 'etcdDeleteWork',
call: 'admin_etcdDeleteWork',
params: 0
}),
],
properties: [
new web3._extend.Property({
Expand Down
2 changes: 2 additions & 0 deletions metadium/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,8 @@ func init() {
metaapi.EtcdRemoveMember = EtcdRemoveMember
metaapi.EtcdJoin = EtcdJoin
metaapi.EtcdMoveLeader = EtcdMoveLeader
metaapi.EtcdGetWork = EtcdGetWork
metaapi.EtcdDeleteWork = EtcdDeleteWork
}

/* EOF */
2 changes: 2 additions & 0 deletions metadium/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ var (
EtcdRemoveMember func(name string) (string, error)
EtcdJoin func(cluster string) error
EtcdMoveLeader func(name string) error
EtcdGetWork func() (string, error)
EtcdDeleteWork func() error
)

func SetMsgChannel(ch chan interface{}) {
Expand Down
14 changes: 14 additions & 0 deletions metadium/etcdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,18 @@ func EtcdJoin(name string) error {
return admin.etcdJoin(name)
}

func EtcdGetWork() (string, error) {
if admin == nil {
return "", ErrNotRunning
}
return admin.etcdGet("metadium-work")
}

func EtcdDeleteWork() error {
if admin == nil {
return ErrNotRunning
}
return admin.etcdDelete("metadium-work")
}

/* EOF */

0 comments on commit 0c14910

Please sign in to comment.