Skip to content
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

Keep track of peers with maps instead of lists. #433

Merged
merged 1 commit into from
May 21, 2015
Merged

Keep track of peers with maps instead of lists. #433

merged 1 commit into from
May 21, 2015

Conversation

dajohi
Copy link
Member

@dajohi dajohi commented May 14, 2015

No description provided.

@davecgh
Copy link
Member

davecgh commented May 14, 2015

Reads well. I'll spend some time testing it out.

@davecgh
Copy link
Member

davecgh commented May 21, 2015

I've been running this for a while now with no issues.

OK after rebase..

@ishbir
Copy link
Contributor

ishbir commented May 21, 2015

Just curious: why was this change necessary?

@davecgh
Copy link
Member

davecgh commented May 21, 2015

It isn't strictly necessary, but it's more efficient for a few reasons:

  • O(1) lookups instead of O(N). This isn't a huge savings since there generally aren't a lot of peers and the list isn't currently accessed all that frequently, but with the upcoming concurrent downloads, accessing multiple peers via the known set is going to become more frequent.
  • The items in a list.List are all interface{} so accessing the individual items required type asserting them (unboxing). This approach avoids that overhead.
  • The intent is to simply maintain a set of peers, so a list isn't the most optimal data structure for that purpose. Also, the struct{} type doesn't use any memory.

So, summarizing, it uses less memory and provides faster access to the set elements.

@conformal-deploy conformal-deploy merged commit 9d6d0e4 into btcsuite:master May 21, 2015
@dajohi dajohi deleted the list_to_map branch October 27, 2015 16:20
jrick added a commit to jrick/btcd that referenced this pull request Nov 1, 2016
Change the block connected and disconnected notifications to include
the entire block header.

Do not notify the previous block's regular tree transactions if the
newly attached block voted to approve them.  Instead, notify the
regular transactions from the newly attached block.  It is up to the
client to check the vote bits in the header to decide how to handle
the previous block's regular transactions.

Every websocket client now has an associated transaction filter that
is used to determine whether or not a processed transaction is (or
might be) relevant to the client.  A new RPC, loadtxfilter, has been
added to load, reload, or add to this filter.

Redo the entire rescan RPC to scan over previously-processed blocks
using the same transaction filter (rather than specifying which
addresses and outpoints to watch for in the rescan request).

Fixes btcsuite#433.
jrick added a commit to jrick/btcd that referenced this pull request Nov 1, 2016
Change the block connected and disconnected notifications to include
the entire block header.

Do not notify the previous block's regular tree transactions if the
newly attached block voted to approve them.  Instead, notify the
regular transactions from the newly attached block.  It is up to the
client to check the vote bits in the header to decide how to handle
the previous block's regular transactions.

Every websocket client now has an associated transaction filter that
is used to determine whether or not a processed transaction is (or
might be) relevant to the client.  A new RPC, loadtxfilter, has been
added to load, reload, or add to this filter.

Redo the entire rescan RPC to scan over previously-processed blocks
using the same transaction filter (rather than specifying which
addresses and outpoints to watch for in the rescan request).

Fixes btcsuite#433.
jrick added a commit to jrick/btcd that referenced this pull request Nov 8, 2016
Change the block connected and disconnected notifications to include
the entire block header.

Do not notify the previous block's regular tree transactions if the
newly attached block voted to approve them.  Instead, notify the
regular transactions from the newly attached block.  It is up to the
client to check the vote bits in the header to decide how to handle
the previous block's regular transactions.

Every websocket client now has an associated transaction filter that
is used to determine whether or not a processed transaction is (or
might be) relevant to the client.  A new RPC, loadtxfilter, has been
added to load, reload, or add to this filter.

Redo the entire rescan RPC to scan over previously-processed blocks
using the same transaction filter (rather than specifying which
addresses and outpoints to watch for in the rescan request).

Fixes btcsuite#433.
jrick added a commit to jrick/btcd that referenced this pull request Nov 8, 2016
Change the block connected and disconnected notifications to include
the entire block header.

Do not notify the previous block's regular tree transactions if the
newly attached block voted to approve them.  Instead, notify the
regular transactions from the newly attached block.  It is up to the
client to check the vote bits in the header to decide how to handle
the previous block's regular transactions.

Every websocket client now has an associated transaction filter that
is used to determine whether or not a processed transaction is (or
might be) relevant to the client.  A new RPC, loadtxfilter, has been
added to load, reload, or add to this filter.

Redo the entire rescan RPC to scan over previously-processed blocks
using the same transaction filter (rather than specifying which
addresses and outpoints to watch for in the rescan request).

Fixes btcsuite#433.
jrick added a commit to jrick/btcd that referenced this pull request Nov 8, 2016
Change the block connected and disconnected notifications to include
the entire block header.

Do not notify the previous block's regular tree transactions if the
newly attached block voted to approve them.  Instead, notify the
regular transactions from the newly attached block.  It is up to the
client to check the vote bits in the header to decide how to handle
the previous block's regular transactions.

Every websocket client now has an associated transaction filter that
is used to determine whether or not a processed transaction is (or
might be) relevant to the client.  A new RPC, loadtxfilter, has been
added to load, reload, or add to this filter.

Redo the entire rescan RPC to scan over previously-processed blocks
using the same transaction filter (rather than specifying which
addresses and outpoints to watch for in the rescan request).

Fixes btcsuite#433.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants