mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-15 12:50:47 +02:00
Only download offers on click (#941)
* Only download offers for squeak when rpc method called * Only download offers after explicit click in frontend * Update frontend build
This commit is contained in:
parent
e6b6a1e180
commit
32bb960f6a
18 changed files with 105 additions and 142 deletions
|
|
@ -35,10 +35,10 @@ import BuyOfferDetailItem from "../../components/BuyOfferDetailItem";
|
|||
import {
|
||||
makeSqueakRequest,
|
||||
getSigningProfilesRequest,
|
||||
downloadOffersRequest,
|
||||
} from "../../squeakclient/requests"
|
||||
import {
|
||||
getBuyOffersRequest,
|
||||
syncSqueakRequest,
|
||||
} from "../../squeakclient/requests"
|
||||
import {
|
||||
payOfferRequest,
|
||||
|
|
@ -101,8 +101,8 @@ export default function BuySqueakDialog({
|
|||
const onDownloadClick = (event) => {
|
||||
event.preventDefault();
|
||||
console.log("Handling download click...");
|
||||
console.log("syncSqueakRequest with hash: " + hash);
|
||||
syncSqueakRequest(hash, (response) => {
|
||||
console.log("downloadOffersRequest with hash: " + hash);
|
||||
downloadOffersRequest(hash, (response) => {
|
||||
console.log("response:");
|
||||
console.log(response);
|
||||
reloadRoute(history);
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ import {
|
|||
ConnectPeerReply as ConnectSqueakPeerReply,
|
||||
DisconnectPeerRequest as DisconnectSqueakPeerRequest,
|
||||
DisconnectPeerReply as DisconnectSqueakPeerReply,
|
||||
DownloadOffersRequest,
|
||||
DownloadOffersReply,
|
||||
} from "../proto/squeak_admin_pb"
|
||||
|
||||
console.log('The value of REACT_APP_SERVER_PORT is:', process.env.REACT_APP_SERVER_PORT);
|
||||
|
|
@ -689,6 +691,17 @@ export function syncSqueakRequest(squeakHash, handleResponse) {
|
|||
);
|
||||
}
|
||||
|
||||
export function downloadOffersRequest(squeakHash, handleResponse) {
|
||||
var request = new DownloadOffersRequest();
|
||||
request.setSqueakHash(squeakHash);
|
||||
makeRequest(
|
||||
'downloadoffers',
|
||||
request,
|
||||
DownloadOffersReply.deserializeBinary,
|
||||
handleResponse,
|
||||
);
|
||||
}
|
||||
|
||||
export function getSqueakDetailsRequest(hash, handleResponse) {
|
||||
var request = new GetSqueakDetailsRequest();
|
||||
request.setSqueakHash(hash);
|
||||
|
|
|
|||
|
|
@ -714,6 +714,16 @@ def test_connect_other_node(
|
|||
# print(sync_squeaks_response)
|
||||
# assert peer_id in sync_squeaks_response.sync_result.completed_peer_ids
|
||||
|
||||
# Download offer
|
||||
other_admin_stub.DownloadOffers(
|
||||
squeak_admin_pb2.DownloadOffersRequest(
|
||||
squeak_hash=saved_squeak_hash,
|
||||
),
|
||||
)
|
||||
print("Sleeping...")
|
||||
time.sleep(5)
|
||||
print("Done sleeping.")
|
||||
|
||||
# Get the sent offers from the seller node
|
||||
get_sent_offers_response = admin_stub.GetSentOffers(
|
||||
squeak_admin_pb2.GetSentOffersRequest(),
|
||||
|
|
@ -911,7 +921,7 @@ def test_download_single_squeak(
|
|||
squeak_hash=saved_squeak_hash,
|
||||
),
|
||||
)
|
||||
time.sleep(10)
|
||||
time.sleep(5)
|
||||
# print(sync_squeak_response)
|
||||
# assert peer_id in sync_squeak_response.sync_result.completed_peer_ids
|
||||
|
||||
|
|
@ -922,6 +932,15 @@ def test_download_single_squeak(
|
|||
)
|
||||
)
|
||||
assert get_squeak_display_response.HasField("squeak_display_entry")
|
||||
|
||||
# Download offer
|
||||
other_admin_stub.DownloadOffers(
|
||||
squeak_admin_pb2.DownloadOffersRequest(
|
||||
squeak_hash=saved_squeak_hash,
|
||||
),
|
||||
)
|
||||
time.sleep(5)
|
||||
|
||||
# Get the buy offer
|
||||
get_buy_offers_response = other_admin_stub.GetBuyOffers(
|
||||
squeak_admin_pb2.GetBuyOffersRequest(
|
||||
|
|
@ -1029,89 +1048,3 @@ def test_connect_peer(admin_stub, other_admin_stub):
|
|||
assert len(connected_peers) == 0
|
||||
other_connected_peers = get_connected_peers(other_admin_stub)
|
||||
assert len(other_connected_peers) == 0
|
||||
|
||||
|
||||
def test_share_single_squeak(
|
||||
admin_stub,
|
||||
other_admin_stub,
|
||||
connected_tcp_peer_id,
|
||||
lightning_client,
|
||||
signing_profile_id,
|
||||
saved_squeak_hash,
|
||||
):
|
||||
# Get the squeak profile
|
||||
get_squeak_profile_response = admin_stub.GetSqueakProfile(
|
||||
squeak_admin_pb2.GetSqueakProfileRequest(
|
||||
profile_id=signing_profile_id,
|
||||
)
|
||||
)
|
||||
squeak_profile_address = get_squeak_profile_response.squeak_profile.address
|
||||
squeak_profile_name = get_squeak_profile_response.squeak_profile.profile_name
|
||||
# print(
|
||||
# "Got squeak profile: {} with address: {}".format(
|
||||
# squeak_profile_name, squeak_profile_address
|
||||
# )
|
||||
# )
|
||||
|
||||
# Set the signing profile to be sharing on the main server
|
||||
admin_stub.SetSqueakProfileSharing(
|
||||
squeak_admin_pb2.SetSqueakProfileSharingRequest(
|
||||
profile_id=signing_profile_id,
|
||||
sharing=True,
|
||||
)
|
||||
)
|
||||
|
||||
# Add the contact profile to the other server and set the profile to be following
|
||||
create_contact_profile_response = other_admin_stub.CreateContactProfile(
|
||||
squeak_admin_pb2.CreateContactProfileRequest(
|
||||
profile_name=squeak_profile_name,
|
||||
address=squeak_profile_address,
|
||||
)
|
||||
)
|
||||
contact_profile_id = create_contact_profile_response.profile_id
|
||||
other_admin_stub.SetSqueakProfileFollowing(
|
||||
squeak_admin_pb2.SetSqueakProfileFollowingRequest(
|
||||
profile_id=contact_profile_id,
|
||||
following=True,
|
||||
)
|
||||
)
|
||||
|
||||
# Get the squeak display item (should be empty)
|
||||
get_squeak_display_response = other_admin_stub.GetSqueakDisplay(
|
||||
squeak_admin_pb2.GetSqueakDisplayRequest(
|
||||
squeak_hash=saved_squeak_hash,
|
||||
)
|
||||
)
|
||||
assert not get_squeak_display_response.HasField("squeak_display_entry")
|
||||
|
||||
# Get buy offers for the squeak hash (should be empty)
|
||||
get_buy_offers_response = other_admin_stub.GetBuyOffers(
|
||||
squeak_admin_pb2.GetBuyOffersRequest(
|
||||
squeak_hash=saved_squeak_hash,
|
||||
)
|
||||
)
|
||||
# print(get_buy_offers_response)
|
||||
assert len(get_buy_offers_response.offers) == 0
|
||||
|
||||
# Upload squeak
|
||||
admin_stub.SyncSqueaks(
|
||||
squeak_admin_pb2.SyncSqueaksRequest(),
|
||||
)
|
||||
time.sleep(10)
|
||||
# print(sync_squeak_response)
|
||||
|
||||
# Get the squeak display item
|
||||
get_squeak_display_response = other_admin_stub.GetSqueakDisplay(
|
||||
squeak_admin_pb2.GetSqueakDisplayRequest(
|
||||
squeak_hash=saved_squeak_hash,
|
||||
)
|
||||
)
|
||||
assert get_squeak_display_response.HasField("squeak_display_entry")
|
||||
# Get the buy offer
|
||||
get_buy_offers_response = other_admin_stub.GetBuyOffers(
|
||||
squeak_admin_pb2.GetBuyOffersRequest(
|
||||
squeak_hash=saved_squeak_hash,
|
||||
)
|
||||
)
|
||||
# print(get_buy_offers_response)
|
||||
assert len(get_buy_offers_response.offers) > 0
|
||||
|
|
|
|||
|
|
@ -196,6 +196,10 @@ service SqueakAdmin {
|
|||
*/
|
||||
rpc SyncSqueak (SyncSqueakRequest) returns (SyncSqueakReply) {}
|
||||
|
||||
/** sqkadmin: `downloadoffers`
|
||||
*/
|
||||
rpc DownloadOffers (DownloadOffersRequest) returns (DownloadOffersReply) {}
|
||||
|
||||
/** sqkadmin: `payoffer`
|
||||
*/
|
||||
rpc PayOffer (PayOfferRequest) returns (PayOfferReply) {}
|
||||
|
|
@ -780,6 +784,14 @@ message SyncSqueakRequest {
|
|||
message SyncSqueakReply {
|
||||
}
|
||||
|
||||
message DownloadOffersRequest {
|
||||
/// The squeak hash.
|
||||
string squeak_hash = 1;
|
||||
}
|
||||
|
||||
message DownloadOffersReply {
|
||||
}
|
||||
|
||||
message GetSqueakDetailsRequest {
|
||||
/// Hash of the squeak.
|
||||
string squeak_hash = 1;
|
||||
|
|
|
|||
|
|
@ -512,7 +512,6 @@ class SqueakAdminServerHandler(object):
|
|||
# self.sync_controller.download_timeline()
|
||||
# self.sync_controller.upload_timeline()
|
||||
self.squeak_controller.sync_timeline()
|
||||
self.squeak_controller.share_squeaks()
|
||||
return squeak_admin_pb2.SyncSqueaksReply()
|
||||
|
||||
def handle_sync_squeak(self, request):
|
||||
|
|
@ -526,6 +525,17 @@ class SqueakAdminServerHandler(object):
|
|||
self.squeak_controller.download_single_squeak(squeak_hash)
|
||||
return squeak_admin_pb2.SyncSqueakReply()
|
||||
|
||||
def handle_download_offers(self, request):
|
||||
squeak_hash_str = request.squeak_hash
|
||||
squeak_hash = bytes.fromhex(squeak_hash_str)
|
||||
logger.info(
|
||||
"Handle download offer for hash: {}".format(squeak_hash_str))
|
||||
# sync_result = self.squeak_controller.sync_squeaks()
|
||||
# self.sync_controller.download_timeline()
|
||||
# self.sync_controller.upload_timeline()
|
||||
self.squeak_controller.download_offers(squeak_hash)
|
||||
return squeak_admin_pb2.DownloadOffersReply()
|
||||
|
||||
def handle_pay_offer(self, request):
|
||||
offer_id = request.offer_id
|
||||
logger.info("Handle pay offer for offer id: {}".format(offer_id))
|
||||
|
|
|
|||
|
|
@ -167,6 +167,9 @@ class SqueakAdminServerServicer(squeak_admin_pb2_grpc.SqueakAdminServicer):
|
|||
def SyncSqueak(self, request, context):
|
||||
return self.handler.handle_sync_squeak(request)
|
||||
|
||||
def DownloadOffers(self, request, context):
|
||||
return self.handler.handle_download_offers(request)
|
||||
|
||||
def PayOffer(self, request, context):
|
||||
return self.handler.handle_pay_offer(request)
|
||||
|
||||
|
|
|
|||
|
|
@ -443,6 +443,14 @@ def create_app(handler, username, password):
|
|||
handler.handle_sync_squeak,
|
||||
)
|
||||
|
||||
@app.route("/downloadoffers", methods=["POST"])
|
||||
@login_required
|
||||
def downloadoffers():
|
||||
return handle_request(
|
||||
squeak_admin_pb2.DownloadOffersRequest(),
|
||||
handler.handle_download_offers,
|
||||
)
|
||||
|
||||
@app.route("/getsqueakdetails", methods=["POST"])
|
||||
@login_required
|
||||
def getsqueakdetails():
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
{
|
||||
"files": {
|
||||
"main.js": "/static/js/main.36afb12f.chunk.js",
|
||||
"main.js.map": "/static/js/main.36afb12f.chunk.js.map",
|
||||
"main.js": "/static/js/main.02ddf78b.chunk.js",
|
||||
"main.js.map": "/static/js/main.02ddf78b.chunk.js.map",
|
||||
"runtime-main.js": "/static/js/runtime-main.9f0ba400.js",
|
||||
"runtime-main.js.map": "/static/js/runtime-main.9f0ba400.js.map",
|
||||
"static/css/2.15110fae.chunk.css": "/static/css/2.15110fae.chunk.css",
|
||||
"static/js/2.0c6b0365.chunk.js": "/static/js/2.0c6b0365.chunk.js",
|
||||
"static/js/2.0c6b0365.chunk.js.map": "/static/js/2.0c6b0365.chunk.js.map",
|
||||
"index.html": "/index.html",
|
||||
"precache-manifest.4cce7117314e6adbd0dd58dd394aa04a.js": "/precache-manifest.4cce7117314e6adbd0dd58dd394aa04a.js",
|
||||
"precache-manifest.6287ba31017aea9c05cf8c369106635c.js": "/precache-manifest.6287ba31017aea9c05cf8c369106635c.js",
|
||||
"service-worker.js": "/service-worker.js",
|
||||
"static/css/2.15110fae.chunk.css.map": "/static/css/2.15110fae.chunk.css.map",
|
||||
"static/js/2.0c6b0365.chunk.js.LICENSE.txt": "/static/js/2.0c6b0365.chunk.js.LICENSE.txt",
|
||||
|
|
@ -20,6 +20,6 @@
|
|||
"static/js/runtime-main.9f0ba400.js",
|
||||
"static/css/2.15110fae.chunk.css",
|
||||
"static/js/2.0c6b0365.chunk.js",
|
||||
"static/js/main.36afb12f.chunk.js"
|
||||
"static/js/main.02ddf78b.chunk.js"
|
||||
]
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeak Node</title><meta name="description" content="Squeak Node is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.15110fae.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.0c6b0365.chunk.js"></script><script src="/static/js/main.36afb12f.chunk.js"></script></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeak Node</title><meta name="description" content="Squeak Node is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.15110fae.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.0c6b0365.chunk.js"></script><script src="/static/js/main.02ddf78b.chunk.js"></script></body></html>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
self.__precacheManifest = (self.__precacheManifest || []).concat([
|
||||
{
|
||||
"revision": "98ad3e84087701c4ca5bbd9c6e37dc17",
|
||||
"revision": "93a3f7db5933742ada7b7210791083d9",
|
||||
"url": "/index.html"
|
||||
},
|
||||
{
|
||||
|
|
@ -16,8 +16,8 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
|
|||
"url": "/static/js/2.0c6b0365.chunk.js.LICENSE.txt"
|
||||
},
|
||||
{
|
||||
"revision": "85fb0a9f6c8246d1c7b1",
|
||||
"url": "/static/js/main.36afb12f.chunk.js"
|
||||
"revision": "ebd75b83d6adc192731e",
|
||||
"url": "/static/js/main.02ddf78b.chunk.js"
|
||||
},
|
||||
{
|
||||
"revision": "cc9816de5a8639d377ea",
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
|
||||
|
||||
importScripts(
|
||||
"/precache-manifest.4cce7117314e6adbd0dd58dd394aa04a.js"
|
||||
"/precache-manifest.6287ba31017aea9c05cf8c369106635c.js"
|
||||
);
|
||||
|
||||
self.addEventListener('message', (event) => {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -14,7 +14,6 @@ from squeak.net import CSqueakLocator
|
|||
|
||||
from squeaknode.core.offer import Offer
|
||||
from squeaknode.core.util import generate_ping_nonce
|
||||
from squeaknode.core.util import get_hash
|
||||
from squeaknode.node.squeak_controller import SqueakController
|
||||
|
||||
|
||||
|
|
@ -173,16 +172,16 @@ class PeerMessageHandler:
|
|||
squeak = msg.squeak
|
||||
# TODO: check if interested before saving.
|
||||
self.squeak_controller.save_squeak(squeak)
|
||||
# TODO: If squeak is still locked, send getdata msg to get offer.
|
||||
if not squeak.HasDecryptionKey():
|
||||
invs = [
|
||||
CInv(
|
||||
type=2,
|
||||
hash=get_hash(squeak),
|
||||
)
|
||||
]
|
||||
getdata_msg = msg_getdata(inv=invs)
|
||||
self.peer.send_msg(getdata_msg)
|
||||
# # TODO: If squeak is still locked, send getdata msg to get offer.
|
||||
# if not squeak.HasDecryptionKey():
|
||||
# invs = [
|
||||
# CInv(
|
||||
# type=2,
|
||||
# hash=get_hash(squeak),
|
||||
# )
|
||||
# ]
|
||||
# getdata_msg = msg_getdata(inv=invs)
|
||||
# self.peer.send_msg(getdata_msg)
|
||||
|
||||
def handle_offer(self, msg):
|
||||
# Save the offer if interested.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ from squeak.core.signing import CSigningKey
|
|||
from squeak.core.signing import CSqueakAddress
|
||||
from squeak.messages import msg_getdata
|
||||
from squeak.messages import msg_getsqueaks
|
||||
from squeak.messages import msg_sharesqueaks
|
||||
from squeak.messages import MsgSerializable
|
||||
from squeak.net import CInterested
|
||||
from squeak.net import CInv
|
||||
|
|
@ -557,10 +556,11 @@ class SqueakController:
|
|||
ret.append(
|
||||
CInv(type=1, hash=inv.hash)
|
||||
)
|
||||
elif not squeak_entry.squeak.HasDecryptionKey():
|
||||
ret.append(
|
||||
CInv(type=2, hash=inv.hash)
|
||||
)
|
||||
# TODO: Decide if offers should be loaded whenever missing?
|
||||
# elif not squeak_entry.squeak.HasDecryptionKey():
|
||||
# ret.append(
|
||||
# CInv(type=2, hash=inv.hash)
|
||||
# )
|
||||
return ret
|
||||
|
||||
def sync_timeline(self):
|
||||
|
|
@ -601,29 +601,15 @@ class SqueakController:
|
|||
# peer.send_msg(getdata_msg)
|
||||
self.broadcast_msg(getdata_msg)
|
||||
|
||||
def share_squeaks(self):
|
||||
block_range = self.get_block_range()
|
||||
logger.info("Sharing timeline with block range: {}".format(block_range))
|
||||
sharing_addresses = self.get_sharing_addresses()
|
||||
logger.debug("Sharing squeaks with sharing addresses: {}".format(
|
||||
sharing_addresses))
|
||||
interests = [
|
||||
CInterested(
|
||||
address=CSqueakAddress(address),
|
||||
nMinBlockHeight=0,
|
||||
nMaxBlockHeight=block_range.max_block,
|
||||
)
|
||||
for address in sharing_addresses
|
||||
def download_offers(self, squeak_hash: bytes):
|
||||
logger.info("Downloading offers for squeak: {}".format(
|
||||
squeak_hash.hex(),
|
||||
))
|
||||
invs = [
|
||||
CInv(type=2, hash=squeak_hash)
|
||||
]
|
||||
locator = CSqueakLocator(
|
||||
vInterested=interests,
|
||||
)
|
||||
sharesqueaks_msg = msg_sharesqueaks(
|
||||
locator=locator,
|
||||
)
|
||||
# for peer in self.connection_manager.peers:
|
||||
# peer.send_msg(sharesqueaks_msg)
|
||||
self.broadcast_msg(sharesqueaks_msg)
|
||||
getdata_msg = msg_getdata(inv=invs)
|
||||
self.broadcast_msg(getdata_msg)
|
||||
|
||||
def filter_shared_squeak_locator(self, interests: List[CInterested]):
|
||||
ret = []
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ class SqueakPeerSyncWorker:
|
|||
logger.debug("Syncing timeline with peers...")
|
||||
# self.print_running_threads()
|
||||
self.squeak_controller.sync_timeline()
|
||||
self.squeak_controller.share_squeaks()
|
||||
|
||||
def start_running(self):
|
||||
if self.sync_interval_s:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue