From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 239E1CED for ; Sun, 13 Aug 2017 18:46:40 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f169.google.com (mail-wr0-f169.google.com [209.85.128.169]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D47871F2 for ; Sun, 13 Aug 2017 18:46:39 +0000 (UTC) Received: by mail-wr0-f169.google.com with SMTP id 26so12579129wrt.5 for ; Sun, 13 Aug 2017 11:46:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to; bh=M3mvfuExcTJ0t2zZeBlzwrsZJDSHL7X2IhlfawXhhH4=; b=bzXv9QvDlzYRrV0pjdn63UY7Z7OJ3BT0eDaKXLYjA3lxQRGL/BEYYUn3pssc7lh68y sUerdBjmfoKhFSRcc2WjSD7Z8DrfxCYlieHSlvINg5f0UZfVRZSjUdVCuPt911EeUyb4 6DeYVbwgbnH/TKXPVkS1/RFusY9HpT3+nyBs0AyVkotCX0jK+b3mQu0tMcEpgyUJtZbV dHveZcRlLkuVJ6E2wosD/OUfEXvFIqpzobCiFJAfHrQNVZxyxq1jvuwBtVBe1tac+n/6 kpjFRCsUdn/X56g7VyLlq5Y9x6YnZeZUleqHmPA9l2gwgPX/A6RW5KhcrRESQ2lRpAR5 NDBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=M3mvfuExcTJ0t2zZeBlzwrsZJDSHL7X2IhlfawXhhH4=; b=lhfrw2OJv8snVXSNFAz4vtt8NFHWCnmJnSOeujG2tqEsPfDnuN4mVnBqALQTPwTjNq sKWKKoLX1Qq7BxVguxmQ5Gt/853whby0QBrVDtY4jrbOZJCT1KWOIF/TnhO8nM8YtzwN GFv9rJ+k1hy91cEMt978/Tw3A8Em54Yd+UeCROBb0bV+o9pyzXsf4UzDs2sBaEuQN7NU QrHnWThRATbijM03EMtvd1MkylSYYkM9uq+M/kC5UhF4Qt8MD2XXDRza2IZBq2V3/tij NBt4beI9rsTM4asiDKjL+BKXqAFcpfozREJwZLKb6csubdsvo5u5Y4IKNjLpi7SwmhCO mTKQ== X-Gm-Message-State: AHYfb5hOzn8aPnB8YpPuat6CWXgz1N3jFRYRTprIGbNuKBgTJ09Q+dsr X4fNMuiyq+xbTr2IsqJmG8fUw47113RP21U= X-Received: by 10.223.134.134 with SMTP id 6mr14494465wrx.255.1502649998148; Sun, 13 Aug 2017 11:46:38 -0700 (PDT) MIME-Version: 1.0 Sender: earonesty@gmail.com Received: by 10.28.199.204 with HTTP; Sun, 13 Aug 2017 11:46:37 -0700 (PDT) From: Erik Aronesty Date: Sun, 13 Aug 2017 14:46:37 -0400 X-Google-Sender-Auth: wXd9GRW9riC02CXUlZbYnX-roeA Message-ID: To: Bitcoin Protocol Discussion Content-Type: multipart/alternative; boundary="001a11459da05c8cbb0556a6f782" X-Mailman-Approved-At: Sun, 13 Aug 2017 19:19:09 +0000 Subject: [bitcoin-dev] Would anyone object to adding a dlopen message hook system? X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Aug 2017 18:46:40 -0000 --001a11459da05c8cbb0556a6f782 Content-Type: text/plain; charset="UTF-8" I was thinking about something like this that could add the ability for module extensions in the core client. When messages are received, modules hooks are called with the message data. They can then handle, mark the peer invalid, push a message to the peer or pass through an alternate command. Also, modules could have their own private commands prefixed by "x:" or something like that. The idea is that the base P2P layer is left undisturbed, but there is now a way to create "enhanced features" that some peers support. My end goal is to support using lightning network micropayments to allow people to pay for better node access - creating a market for node services. But I don't think this should be "baked in" to core. Nor do I think it should be a "patch". It should be a linked-in module, optionally compiled and added to bitcoin conf, then loaded via dlopen(). Modules should be slightly robust to Bitcoin versions changing out from under them, but not if the network layer is changed. This can be ensured by a) keeping a module version number, and b) treating module responses as if they were just received from the network. Any module incompatibility should throw an exception...ensuring broken peers don't stay online. In general I think the core reference would benefit from the ability to create subnetworks within the Bitcoin ecosystem. Right now, we have two choices... full node and get slammed with traffic, or listen-only node, and do nothing. Adding a module/hook system would allow a complex ecosystem of participation - and it would seem to be far more robust in the long term. Something like this??? class MessageHookIn { public: int hookversion; int64_t nodeid; int nVersion; int64_t serviceflags; const char *strCommand; const char *nodeaddr; const char *vRecv; int vRecvLen; int64_t nTimeReceived; }; class MessageHookOut { public: int hookversion; int misbehaving; const char *logMsg; const char *pushCommand; const unsigned char *pushData; int pushDataLen; const char *passCommand; CDataStream passStream; }; class MessageHook { public: int hookversion; std::string name; typedef bool (*HandlerType)(const MessageHookIn *in, MessageHookOut *out); HandlerType handle; }; --001a11459da05c8cbb0556a6f782 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I was thinking about something like this that could add th= e ability for module extensions in the core client. =C2=A0

When mes= sages are received, modules hooks are called with the message data. =C2=A0 =

They can then handle, mark the peer invalid, push a message to the = peer or pass through an alternate command.=C2=A0 Also, modules could have t= heir own private commands prefixed by "x:" or something like that= . =C2=A0=C2=A0

The idea is that the base P2P layer is le= ft undisturbed, but there is now a way to create "enhanced features&qu= ot; that some peers support.

My end goal is to support using = lightning network micropayments to allow people to pay for better node acce= ss - creating a market for node services. =C2=A0=C2=A0

But I don'= ;t think this should be "baked in" to core. =C2=A0 Nor do I think= it should be a "patch". =C2=A0 It should be a linked-in module, = optionally compiled and added to bitcoin conf, then loaded via dlopen(). = =C2=A0 =C2=A0Modules should be slightly robust to Bitcoin versions changing= out from under them, but not if the network layer is changed. =C2=A0 This = can be ensured by a) keeping a module version number, and b) treating modul= e responses as if they were just received from the network. =C2=A0 Any modu= le incompatibility should throw an exception...ensuring broken peers don= 9;t stay online.

In general I think the core reference would benefit= from the ability to create subnetworks within the Bitcoin ecosystem. =C2= =A0 Right now, we have two choices... full node and get slammed with traffi= c, or listen-only node, and do nothing. =C2=A0

Adding a module/hook = system would allow a complex ecosystem of participation - and it would seem= to be far more robust in the long term.=C2=A0

Som= ething like this???

class MessageHookIn {
public:
=C2=A0 =C2=A0 int hookversion;
=C2=A0 =C2=A0 int64_t nodei= d;
=C2=A0 =C2=A0 int nVersion;
=C2=A0 =C2=A0 int64_t se= rviceflags;
=C2=A0 =C2=A0 const char *strCommand;
=C2= =A0 =C2=A0 const char *nodeaddr;
=C2=A0 =C2=A0 const char *vRecv;=
=C2=A0 =C2=A0 int vRecvLen;
=C2=A0 =C2=A0 int64_t nTim= eReceived;
};

class MessageHookOut {
public:
=C2=A0 =C2=A0 int hookversion;
=C2=A0 = =C2=A0 int misbehaving;
=C2=A0 =C2=A0 const char *logMsg;
=C2=A0 =C2=A0 const char *pushCommand;
=C2=A0 =C2=A0 const uns= igned char *pushData;
=C2=A0 =C2=A0 int pushDataLen;
= =C2=A0 =C2=A0 const char *passCommand;
=C2=A0 =C2=A0 CDataStream = passStream;
};

class MessageHook {
public:
=C2=A0 =C2=A0 int hookversion;
=C2=A0 =C2=A0= std::string name;
=C2=A0 =C2=A0 typedef bool (*HandlerType)(cons= t MessageHookIn *in, MessageHookOut *out);
=C2=A0 =C2=A0 HandlerT= ype handle;
};


--001a11459da05c8cbb0556a6f782--