<p>SPV wallets typically keep track of what the best known block for each of their peers is as well, to make sure they are up to date and can assess the security of their transactions (# of confirmations). The way they do this is to start a counter initialized at the height given in the <code>version</code> message. And then when the node broadcasts a new <code>inv</code> (inventory) message for a block, get that block header, and if it builds on their previous best header, then increment the counter. With this method, you can keep a mapping of nodes to their main chain tips.</p>

<p>Essentially, this is just keeping track of the <code>inv</code> broadcasts form a peer, which is how peers publicly report new blocks. </p>

CC BY-SA 3.0
2015-06-22T19:57:26.310Z
2015-06-22T19:57:26.310Z
morsecoder
<p>In case I'm a selfish miner and have successfully forked the blockchain, I'd like to know the state of progress of my honest nodes at any given time - how can I achieve this?</p>

<p><strong>Do peers on separate blockchains exchange information about their progress through data messages?</strong></p>

<p><strong><em>Let's look at this scenario for a better understanding:<br/></em></strong>
<em>selfish node=<strong>s</strong>;    honest node=<strong>h</strong><br/></em></p>

<p><strong>s</strong>: mine a block#1 (child of genesis block), don't report<br/>
<strong>h</strong>: mine block#2, block#3 publicly<br/>
<strong>s</strong>: mine block#4, block#5 secretly (don't report)<br/>
<strong>h</strong>: mine block#4 publicly<br/>
<strong>s</strong>: get information what block height the honest network is at!?<br/></p>

<p><strong>NOTE:</strong> <br/></p>

<ul>
<li><code>pindexLastCommonBlock</code> doesn't seem to be helpful since calling its
height would say that last common block is 3, but does not say what
height honest nodes are at.</li>
<li><code>setInventoryKnown</code> in case of a fork stores all blocks ever mined.</li>
</ul>

CC BY-SA 3.0
2015-06-22T20:01:23.983Z
`peers on separate blockchains` - If by separate blockchains you mean different coins, these peers don't talk to each other at all. If you mean peers working with the same blockchain but at different points in the synchronization process, these peers do exchange data messages.
morsecoder
CC BY-SA 3.0
2015-06-22T20:03:59.703Z
No by separate blockchains I mean on separate subchains with a common forked block.
Aliakbar Ahmadi
CC BY-SA 3.0
2015-06-22T20:16:22.697Z
I don't see how that's any different from the second situation I posed in my first comment.
morsecoder
CC BY-SA 3.0
2015-06-22T20:57:16.643Z
Ok if its the same thing as what you mean by node with different sync points, then we talk of the same phenomenon
Aliakbar Ahmadi
<blockchain><blockchain-fork><c++><selfish-mining>
How to access peer's tip of chain?
Aliakbar Ahmadi
# How to access peer's tip of chain?

(Asked by: username_0 on 2015-06-22)

In case I'm a selfish miner and have successfully forked the blockchain, I'd like to know the state of progress of my honest nodes at any given time - how can I achieve this?

**Do peers on separate blockchains exchange information about their progress through data messages?**

***Let's look at this scenario for a better understanding:***
*selfish node=**s**; honest node=**h***

**s**: mine a block#1 (child of genesis block), don't report  
**h**: mine block#2, block#3 publicly  
**s**: mine block#4, block#5 secretly (don't report)  
**h**: mine block#4 publicly  
**s**: get information what block height the honest network is at!?

**NOTE:**

* `pindexLastCommonBlock` doesn't seem to be helpful since calling its
  height would say that last common block is 3, but does not say what
  height honest nodes are at.
* `setInventoryKnown` in case of a fork stores all blocks ever mined.

**Tags:** blockchain, blockchain-fork, c++, selfish-mining

> **Comments:**
> **username_1**: `peers on separate blockchains` - If by separate blockchains you mean different coins, these peers don't talk to each other at all. If you mean peers working with the same blockchain but at different points in the synchronization process, these peers do exchange data messages.  
> **username_0**: No by separate blockchains I mean on separate subchains with a common forked block.  
> **username_1**: I don't see how that's any different from the second situation I posed in my first comment.  
> **username_0**: Ok if its the same thing as what you mean by node with different sync points, then we talk of the same phenomenon  

---

## 1 answers

### Answer by username_1 on 2015-06-22. Score: 1

SPV wallets typically keep track of what the best known block for each of their peers is as well, to make sure they are up to date and can assess the security of their transactions (# of confirmations). The way they do this is to start a counter initialized at the height given in the `version` message. And then when the node broadcasts a new `inv` (inventory) message for a block, get that block header, and if it builds on their previous best header, then increment the counter. With this method, you can keep a mapping of nodes to their main chain tips.

Essentially, this is just keeping track of the `inv` broadcasts form a peer, which is how peers publicly report new blocks.


---

