Optimize IsBanned() #29

Closed
opened 3 years ago by duke · 4 comments
duke commented 3 years ago
Owner

IsBanned is called very often in p2p code, this change optimizes it to be faster. Originally by BTC Core and recently pulled into ZEC:

c1600cd259

IsBanned is called very often in p2p code, this change optimizes it to be faster. Originally by BTC Core and recently pulled into ZEC: https://github.com/zcash/zcash/commit/c1600cd2590beaa2c773f936e378d70f7b7d49eb
Collaborator

Not sure the best way to test a change like this -> It builds, it runs, and I can use hush-cli RPC without it crashing.

Not sure the best way to test a change like this -> It builds, it runs, and I can use hush-cli RPC without it crashing.
Poster
Owner

@jahway603 have you tried banning an IP (setban) and looking at banned IP's (listbanned) via hush-cli ?

@jahway603 have you tried banning an IP (`setban`) and looking at banned IP's (listbanned) via hush-cli ?
Collaborator

@duke Does this mean it's working fine?

wtf@wtf:~/dev/hush3$ ./src/hush-cli listbanned
[
]
wtf@wtf:~/dev/hush3$ ./src/hush-cli setban 1.2.3.4/32 add 0
wtf@wtf:~/dev/hush3$ ./src/hush-cli listbanned
[
  {
    "address": "1.2.3.4/255.255.255.255",
    "banned_until": 1657983851,
    "time_remaining": 86398
  }
]
wtf@wtf:~/dev/hush3$ ./src/hush-cli setban 1.2.3.4/32 remove
wtf@wtf:~/dev/hush3$ ./src/hush-cli listbanned
[
]
@duke Does this mean it's working fine? ``` wtf@wtf:~/dev/hush3$ ./src/hush-cli listbanned [ ] wtf@wtf:~/dev/hush3$ ./src/hush-cli setban 1.2.3.4/32 add 0 wtf@wtf:~/dev/hush3$ ./src/hush-cli listbanned [ { "address": "1.2.3.4/255.255.255.255", "banned_until": 1657983851, "time_remaining": 86398 } ] wtf@wtf:~/dev/hush3$ ./src/hush-cli setban 1.2.3.4/32 remove wtf@wtf:~/dev/hush3$ ./src/hush-cli listbanned [ ] ```
Poster
Owner

PR has been merged

PR has been merged
duke closed this issue 2 years ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.