-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LRU block cache #88
LRU block cache #88
Conversation
Since it is not only fetching blocks from the network anymore.
neutrino.go
Outdated
@@ -500,6 +500,11 @@ type ChainService struct { | |||
BlockHeaders *headerfs.BlockHeaderStore | |||
RegFilterHeaders *headerfs.FilterHeaderStore | |||
|
|||
// queryPeers will be called to send messages to one or more peers, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good initial start. Ideally in the end we make the set of query methods into an interface so we can easily mock them out if needed. It'll also allow us to test the set of query behavior w/o actually having an active network connection.
cache/cacheable_block.go
Outdated
|
||
// Size returns size of this block in bytes. | ||
func (c *CacheableBlock) Size() (uint64, error) { | ||
f, err := c.Block.Bytes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can instead use SerializeSize
here in order to not have to re-encode the entire thing.
query.go
Outdated
@@ -905,9 +905,21 @@ func (s *ChainService) GetBlockFromNetwork(blockHash chainhash.Hash, | |||
invType = wire.InvTypeBlock | |||
} | |||
|
|||
// Create an inv vector for getting this block. | |||
inv := wire.NewInvVect(invType, &blockHash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use an inv vector rather than the hash of the block for the cache?
This PR builds on top of #72, adding an in-memory block cache for block received from peers.
@halseth