summaryrefslogtreecommitdiff
path: root/a7/61cccff8ec7eb2ef884548af7db0c09e584ca2
blob: b91a2e61408e2f93ebf7d3cafaa4e35b20fb933f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191]
	helo=mx.sourceforge.net)
	by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76)
	(envelope-from <andyparkins@gmail.com>) id 1UiOqT-0001cw-RI
	for bitcoin-development@lists.sourceforge.net;
	Fri, 31 May 2013 12:54:13 +0000
Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com
	designates 209.85.212.174 as permitted sender)
	client-ip=209.85.212.174; envelope-from=andyparkins@gmail.com;
	helo=mail-wi0-f174.google.com; 
Received: from mail-wi0-f174.google.com ([209.85.212.174])
	by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128)
	(Exim 4.76) id 1UiOqT-0001sp-1m
	for bitcoin-development@lists.sourceforge.net;
	Fri, 31 May 2013 12:54:13 +0000
Received: by mail-wi0-f174.google.com with SMTP id c10so658693wiw.7
	for <bitcoin-development@lists.sourceforge.net>;
	Fri, 31 May 2013 05:54:06 -0700 (PDT)
X-Received: by 10.180.37.229 with SMTP id b5mr3165679wik.29.1370004846932;
	Fri, 31 May 2013 05:54:06 -0700 (PDT)
Received: from momentum.localnet ([91.84.15.31])
	by mx.google.com with ESMTPSA id en3sm3832021wid.1.2013.05.31.05.54.05
	for <multiple recipients>
	(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
	Fri, 31 May 2013 05:54:06 -0700 (PDT)
From: Andy Parkins <andyparkins@gmail.com>
To: bitcoin-development@lists.sourceforge.net
Date: Fri, 31 May 2013 13:54:03 +0100
User-Agent: KMail/1.13.7 (Linux/3.8-trunk-686-pae; KDE/4.8.4; i686; ; )
References: <CAH2=CKzW41TYbX6c1F8oknA_LttOaA8vmDPmojuowXgEADY61g@mail.gmail.com>
In-Reply-To: <CAH2=CKzW41TYbX6c1F8oknA_LttOaA8vmDPmojuowXgEADY61g@mail.gmail.com>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable
Message-Id: <201305311354.03625.andyparkins@gmail.com>
X-Spam-Score: -1.6 (-)
X-Spam-Report: Spam Filtering performed by mx.sourceforge.net.
	See http://spamassassin.org/tag/ for more details.
	-1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for
	sender-domain
	0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider
	(andyparkins[at]gmail.com)
	-0.0 SPF_PASS               SPF: sender matches SPF record
	-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from
	author's domain
	0.1 DKIM_SIGNED            Message has a DKIM or DK signature,
	not necessarily valid
	-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
X-Headers-End: 1UiOqT-0001sp-1m
Subject: Re: [Bitcoin-development] Implementing batch processing for
	-blocknotify
X-BeenThere: bitcoin-development@lists.sourceforge.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: <bitcoin-development.lists.sourceforge.net>
List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>,
	<mailto:bitcoin-development-request@lists.sourceforge.net?subject=unsubscribe>
List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=bitcoin-development>
List-Post: <mailto:bitcoin-development@lists.sourceforge.net>
List-Help: <mailto:bitcoin-development-request@lists.sourceforge.net?subject=help>
List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>,
	<mailto:bitcoin-development-request@lists.sourceforge.net?subject=subscribe>
X-List-Received-Date: Fri, 31 May 2013 12:54:14 -0000

On Friday 31 May 2013 12:56:43 Rune Kj=E6r Svendsen wrote:

> I have an application that wants to keep up with new blocks as they come
> in. For that I can use the -blocknotify option with bitcoind, which will
> execute my application for each new block.
>=20
> The problem is that my app isn't necessarily quick enough to finish its
> work before a new block comes in and the app is executed again. This means
> the that bitcoind might keep executing my application even though the
> previous instance hasn't finished, and that's fairly inefficient
> resource-wise, as many instances of the application will be running
> simultaneously.

Have your program try to create a unix-domain socket when it starts.  If it=
=20
can't create it (because one already exists at that path), then connect to =
it.

You then have two modes:

 - Creator of socket, listens to socket for more incoming data, and adds it=
 to
   some sort of internal block queue.
 - Client to socket, pushes output of -blocknotify to socket and exits

Your concurrency problems go away because only one process is ever actually=
=20
doing something with the data.

Should be fairly straight forward.  The client is simple.  The server is tw=
o=20
threads, one listening on the socket and then briefly locking and updating =
a=20
queue, and one thread briefly locking and removing from the queue.



Andy

=2D-=20
Dr Andy Parkins
andyparkins@gmail.com