nervosnetwork / ckb-light-client

CKB light client reference implementation
MIT License
14 stars 16 forks source link

fix: let peers cached their own last headers to avoid be overridden #177

Closed yangby-cryptape closed 7 months ago

yangby-cryptape commented 7 months ago

Description

At present, only one set of verified last N block headers are cached.

https://github.com/nervosnetwork/ckb-light-client/blob/0a8c34ab0db24c8d3af53a894efb1a443ea7cae4/src/protocols/light_client/peers.rs#L23-L24

But, in fact, all peers could have different sets of last N block headers.

Consider that:

What will be happened?

How to fix that?

Traverse last headers of all peers every time.

Commits