mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
les: keep pos balance entry if meta field is not empty
This commit is contained in:
parent
8248dfea19
commit
703e67e521
1 changed files with 7 additions and 1 deletions
|
|
@ -451,7 +451,9 @@ func (f *clientPool) balanceExhausted(id enode.ID) {
|
|||
c.capacity = f.freeClientCap
|
||||
c.peer.updateCapacity(c.capacity)
|
||||
}
|
||||
f.ndb.delPB(id)
|
||||
pb := f.ndb.getOrNewPB(id)
|
||||
pb.value = 0
|
||||
f.ndb.setPB(id, pb)
|
||||
if f.eventHook != nil {
|
||||
f.eventHook("balanceExhausted", c)
|
||||
}
|
||||
|
|
@ -740,6 +742,10 @@ func (db *nodeDB) getOrNewPB(id enode.ID) posBalance {
|
|||
}
|
||||
|
||||
func (db *nodeDB) setPB(id enode.ID, b posBalance) {
|
||||
if b.value == 0 && len(b.meta) == 0 {
|
||||
db.delPB(id)
|
||||
return
|
||||
}
|
||||
key := db.key(id.Bytes(), false)
|
||||
enc, err := rlp.EncodeToBytes(&(b))
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue