diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index a75bf54..bb317d2 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
| @@ -1877,6 +1877,14 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) | |||
| 1877 | pfrom->PushMessage("getblocks", CBlockLocator(pindexBest), uint256(0)); | 1877 | pfrom->PushMessage("getblocks", CBlockLocator(pindexBest), uint256(0)); |
| 1878 | } | 1878 | } |
| 1879 | 1879 | ||
| 1880 | // Introduce ourselves and hand over the .btf peers that answered us. | ||
| 1881 | // Everything in here is self-certifying, so this is safe to send to a | ||
| 1882 | // node we know nothing about, and safe for it to act on. | ||
| 1883 | vector<string> vPexOut; | ||
| 1884 | BtfPexCollect(vPexOut); | ||
| 1885 | if (!vPexOut.empty()) | ||
| 1886 | pfrom->PushMessage("btfpeers", vPexOut); | ||
| 1887 | |||
| 1880 | if (LogAcceptsCategory("net")) printf("version addrMe = %s\n", addrMe.ToString().c_str()); | 1888 | if (LogAcceptsCategory("net")) printf("version addrMe = %s\n", addrMe.ToString().c_str()); |
| 1881 | } | 1889 | } |
| 1882 | 1890 | ||
| @@ -1888,6 +1896,29 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) | |||
| 1888 | } | 1896 | } |
| 1889 | 1897 | ||
| 1890 | 1898 | ||
| 1899 | else if (strCommand == "btfpeers") | ||
| 1900 | { | ||
| 1901 | // Peer exchange. Nothing here is taken on trust: BtfPexAccept checks | ||
| 1902 | // every descriptor's signature against the key its .btf address | ||
| 1903 | // decodes to, and drops the rest. | ||
| 1904 | int64 nNow = GetTime(); | ||
| 1905 | if (nNow - pfrom->nLastPexRecv < PEX_MIN_INTERVAL) | ||
| 1906 | { | ||
| 1907 | if (LogAcceptsCategory("net")) | ||
| 1908 | printf("btfpeers: ignoring, %s is sending them too fast\n", | ||
| 1909 | pfrom->addr.ToString().c_str()); | ||
| 1910 | return true; | ||
| 1911 | } | ||
| 1912 | pfrom->nLastPexRecv = nNow; | ||
| 1913 | |||
| 1914 | vector<string> vDesc; | ||
| 1915 | vRecv >> vDesc; | ||
| 1916 | int nKept = BtfPexAccept(vDesc); | ||
| 1917 | LogPrint("net", "btfpeers: kept %d of %zu descriptor(s) from %s\n", | ||
| 1918 | nKept, vDesc.size(), pfrom->addr.ToString().c_str()); | ||
| 1919 | } | ||
| 1920 | |||
| 1921 | |||
| 1891 | else if (strCommand == "inv") | 1922 | else if (strCommand == "inv") |
| 1892 | { | 1923 | { |
| 1893 | vector<CInv> vInv; | 1924 | vector<CInv> vInv; |