Merge pull request #2035 from bas-vk/rcp-v2-rebase
rpc: new RPC implementation with pub/sub support
This commit is contained in:
@ -44,6 +44,10 @@ type Account struct {
|
||||
Address common.Address
|
||||
}
|
||||
|
||||
func (acc *Account) MarshalJSON() ([]byte, error) {
|
||||
return []byte(`"` + acc.Address.Hex() + `"`), nil
|
||||
}
|
||||
|
||||
type Manager struct {
|
||||
keyStore crypto.KeyStore
|
||||
unlocked map[common.Address]*unlocked
|
||||
@ -92,6 +96,17 @@ func (am *Manager) Unlock(addr common.Address, keyAuth string) error {
|
||||
return am.TimedUnlock(addr, keyAuth, 0)
|
||||
}
|
||||
|
||||
func (am *Manager) Lock(addr common.Address) error {
|
||||
am.mutex.Lock()
|
||||
if unl, found := am.unlocked[addr]; found {
|
||||
am.mutex.Unlock()
|
||||
am.expire(addr, unl, time.Duration(0) * time.Nanosecond)
|
||||
} else {
|
||||
am.mutex.Unlock()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// TimedUnlock unlocks the account with the given address. The account
|
||||
// stays unlocked for the duration of timeout. A timeout of 0 unlocks the account
|
||||
// until the program exits.
|
||||
|
Reference in New Issue
Block a user