les: removed "add" field from UpdateBalance

This commit is contained in:
Zsolt Felfoldi 2019-11-02 20:21:08 +01:00
parent 61d6ebab84
commit 8248dfea19
3 changed files with 12 additions and 22 deletions

View file

@ -826,7 +826,7 @@ web3._extend({
new web3._extend.Method({
name: 'updateBalance',
call: 'les_updateBalance',
params: 4
params: 3
}),
],
properties:

View file

@ -235,8 +235,8 @@ loop:
// UpdateBalance updates the balance of a client (either overwrites it or adds to it).
// It also updates the balance meta info string.
func (api *PrivateLightServerAPI) UpdateBalance(id enode.ID, value int64, add bool, meta string) error {
return api.server.clientPool.updateBalance(id, value, add, meta)
func (api *PrivateLightServerAPI) UpdateBalance(id enode.ID, value int64, meta string) error {
return api.server.clientPool.updateBalance(id, value, meta)
}
// SetClientParams sets client parameters for all clients listed in the ids list

View file

@ -564,7 +564,7 @@ func (f *clientPool) getPosBalance(id enode.ID) posBalance {
// updateBalance updates the balance of a client (either overwrites it or adds to it).
// It also updates the balance meta info string.
func (f *clientPool) updateBalance(id enode.ID, amount int64, add bool, meta string) error {
func (f *clientPool) updateBalance(id enode.ID, amount int64, meta string) error {
f.lock.Lock()
defer f.lock.Unlock()
@ -588,7 +588,6 @@ func (f *clientPool) updateBalance(id enode.ID, amount int64, add bool, meta str
c.balanceMetaInfo = meta
}()
}
if add {
if amount > 0 {
if amount > maxBalance || pb.value > maxBalance-uint64(amount) {
return errBalanceOverflow
@ -601,15 +600,6 @@ func (f *clientPool) updateBalance(id enode.ID, amount int64, add bool, meta str
pb.value -= uint64(-amount)
}
}
} else {
if amount > maxBalance {
return errBalanceOverflow
}
if amount < 0 {
amount = 0
}
pb.value = uint64(amount)
}
pb.meta = meta
f.ndb.setPB(id, pb)
return nil