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

Merged
merged 14 commits into from Aug 23, 2018

Conversation

Projects
None yet
3 participants
@Roasbeef
Member

Roasbeef commented Aug 22, 2018

This PR builds on top of #72, adding an in-memory block cache for block received from peers.

@halseth

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,

This comment has been minimized.

@Roasbeef

Roasbeef Aug 23, 2018

Member

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.

// Size returns size of this block in bytes.
func (c *CacheableBlock) Size() (uint64, error) {
f, err := c.Block.Bytes()

This comment has been minimized.

@Roasbeef

Roasbeef Aug 23, 2018

Member

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)

This comment has been minimized.

@Roasbeef

Roasbeef Aug 23, 2018

Member

Why use an inv vector rather than the hash of the block for the cache?

@coveralls

This comment has been minimized.

coveralls commented Aug 23, 2018

Coverage Status

Coverage decreased (-0.4%) to 70.041% when pulling e89b367 on Roasbeef:block-filter-cache into 3894831 on lightninglabs:master.

@Roasbeef Roasbeef merged commit d24ca51 into lightninglabs:master Aug 23, 2018

1 of 2 checks passed

coverage/coveralls Coverage decreased (-0.4%) to 70.041%
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

This was referenced Aug 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment