Compare commits
35 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
60aa0afde4 | ||
|
d79e0dd86a | ||
|
34171a4c65 | ||
|
5cd52cbb97 | ||
|
1b24fd5439 | ||
|
b7a84acdb4 | ||
|
b7953cbd0f | ||
|
c5bd4aad3a | ||
|
c45e6e3310 | ||
|
97fbec6477 | ||
|
2a9bf41cf5 | ||
|
c54661d39e | ||
|
ddeae91611 | ||
|
d94cf08719 | ||
|
a0f8960643 | ||
|
ce0f29d982 | ||
|
263d4df300 | ||
|
029deead75 | ||
|
da9fb5925d | ||
|
cbf00281c6 | ||
|
01ad409077 | ||
|
3a8ec01588 | ||
|
b63793fd9b | ||
|
84b8eb10e6 | ||
|
532ff230b4 | ||
|
f7c09acfe2 | ||
|
04d9901f0d | ||
|
b8c2b1b86a | ||
|
c94b291d39 | ||
|
6c360ca2e5 | ||
|
ff74679de8 | ||
|
94bd5c8cdf | ||
|
ccbbcc2157 | ||
|
57191ea378 | ||
|
e646edecca |
47
CHANGELOG
47
CHANGELOG
@ -1,3 +1,50 @@
|
|||||||
|
- 0.2.3
|
||||||
|
* Update wrong license file
|
||||||
|
- 0.2.2
|
||||||
|
* Change license to AGPL3 and copyright waived to public domain
|
||||||
|
- 0.2.1
|
||||||
|
* Implement shep 0.3.0
|
||||||
|
* Implement chainlib 0.4.x
|
||||||
|
- 0.2.0
|
||||||
|
* Implement chainlib 0.3.0
|
||||||
|
- 0.1.16
|
||||||
|
* Queue list cli tool
|
||||||
|
* State parser cli tool
|
||||||
|
* Provide pluggable renderer capability for queue list cli tool
|
||||||
|
* Move path and state query parsing to settings module
|
||||||
|
* Add queue path and digest parameters to base config
|
||||||
|
- 0.1.15
|
||||||
|
* Upgrade shep to avoid sync in persist set
|
||||||
|
- 0.1.14
|
||||||
|
* Upgrade shep to handle exception in filestore list
|
||||||
|
- 0.1.13
|
||||||
|
* Remove sync on each get
|
||||||
|
* Upgrade shep to guarantee atomic state lock state
|
||||||
|
- 0.1.12
|
||||||
|
* Raise correct exception from index store exists check
|
||||||
|
- 0.1.11
|
||||||
|
* Allow for sync skip in store instantiation
|
||||||
|
- 0.1.10
|
||||||
|
* Improve logging
|
||||||
|
- 0.1.9
|
||||||
|
* Upgrade deps
|
||||||
|
- 0.1.8
|
||||||
|
* Upgrade deps
|
||||||
|
- 0.1.7
|
||||||
|
* Improve logging
|
||||||
|
- 0.1.6
|
||||||
|
* Sort upcoming queue item chronologically
|
||||||
|
* Add unit testing for upcoming query method
|
||||||
|
- 0.1.5
|
||||||
|
* Add reserved state check method
|
||||||
|
- 0.1.4
|
||||||
|
* Dependency cleanups
|
||||||
|
- 0.1.3
|
||||||
|
* Add CLI args and config handling, settings object
|
||||||
|
- 0.1.2
|
||||||
|
* Add CLI inspection tools
|
||||||
|
- 0.1.1
|
||||||
|
*
|
||||||
- 0.1.0
|
- 0.1.0
|
||||||
* Replace state transitions with shep
|
* Replace state transitions with shep
|
||||||
- 0.0.3
|
- 0.0.3
|
||||||
|
141
LICENSE
141
LICENSE
@ -1,5 +1,5 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
@ -7,17 +7,15 @@
|
|||||||
|
|
||||||
Preamble
|
Preamble
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
software and other kinds of works.
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
The licenses for most software and other practical works are designed
|
||||||
to take away your freedom to share and change the works. By contrast,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
share and change all versions of a program--to make sure it remains free
|
share and change all versions of a program--to make sure it remains free
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
software for all its users.
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
When we speak of free software, we are referring to freedom, not
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
|
|||||||
want it, that you can change the software or use pieces of it in new
|
want it, that you can change the software or use pieces of it in new
|
||||||
free programs, and that you know you can do these things.
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
Developers that use our General Public Licenses protect your rights
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
you this License which gives you legal permission to copy, distribute
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
and/or modify the software.
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
A secondary benefit of defending all users' freedom is that
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
improvements made in alternate versions of the program, if they
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
receive widespread use, become available for other developers to
|
||||||
or can get the source code. And you must show them these terms so they
|
incorporate. Many developers of free software are heartened and
|
||||||
know their rights.
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
The GNU Affero General Public License is designed specifically to
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
ensure that, in such cases, the modified source code becomes available
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
An older license, called the Affero General Public License and
|
||||||
that there is no warranty for this free software. For both users' and
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
changed, so that their problems will not be attributed erroneously to
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
authors of previous versions.
|
this license.
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
@ -72,7 +60,7 @@ modification follow.
|
|||||||
|
|
||||||
0. Definitions.
|
0. Definitions.
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
works, such as semiconductor masks.
|
works, such as semiconductor masks.
|
||||||
@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
|
|||||||
the Program, the only way you could satisfy both those terms and this
|
the Program, the only way you could satisfy both those terms and this
|
||||||
License would be to refrain entirely from conveying the Program.
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
Notwithstanding any other provision of this License, you have
|
||||||
permission to link or combine any covered work with a work licensed
|
permission to link or combine any covered work with a work licensed
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
under version 3 of the GNU General Public License into a single
|
||||||
combined work, and to convey the resulting work. The terms of this
|
combined work, and to convey the resulting work. The terms of this
|
||||||
License will continue to apply to the part which is the covered work,
|
License will continue to apply to the part which is the covered work,
|
||||||
but the special requirements of the GNU Affero General Public License,
|
but the work with which it is combined will remain governed by version
|
||||||
section 13, concerning interaction through a network will apply to the
|
3 of the GNU General Public License.
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
the GNU General Public License from time to time. Such new versions will
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
address new problems or concerns.
|
address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
Each version is given a distinguishing version number. If the
|
||||||
Program specifies that a certain numbered version of the GNU General
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
Public License "or any later version" applies to it, you have the
|
Public License "or any later version" applies to it, you have the
|
||||||
option of following the terms and conditions either of that numbered
|
option of following the terms and conditions either of that numbered
|
||||||
version or of any later version published by the Free Software
|
version or of any later version published by the Free Software
|
||||||
Foundation. If the Program does not specify a version number of the
|
Foundation. If the Program does not specify a version number of the
|
||||||
GNU General Public License, you may choose any version ever published
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
by the Free Software Foundation.
|
by the Free Software Foundation.
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
If the Program specifies that a proxy can decide which future
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
public statement of acceptance of a version permanently authorizes you
|
public statement of acceptance of a version permanently authorizes you
|
||||||
to choose that version for the Program.
|
to choose that version for the Program.
|
||||||
|
|
||||||
@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||||||
Copyright (C) <year> <name of author>
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
If your software can interact with users remotely through a computer
|
||||||
notice like this when it starts in an interactive mode:
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
<program> Copyright (C) <year> <name of author>
|
interface could display a "Source" link that leads users to an archive
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
of the code. There are many ways you could offer source, and different
|
||||||
This is free software, and you are welcome to redistribute it
|
solutions will be better for different programs; see section 13 for the
|
||||||
under certain conditions; type `show c' for details.
|
specific requirements.
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
<https://www.gnu.org/licenses/>.
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
||||||
|
@ -1 +1 @@
|
|||||||
include *requirements.txt LICENSE chainqueue/db/migrations/default/* chainqueue/db/migrations/default/versions/* chainqueue/db/migrations/default/versions/src/* chainqueue/data/config/*
|
include *requirements.txt LICENSE WAIVER WAIVER.asc CHANGELOG chainqueue/db/migrations/default/* chainqueue/db/migrations/default/versions/* chainqueue/db/migrations/default/versions/src/* chainqueue/data/config/*
|
||||||
|
17
WAIVER
Normal file
17
WAIVER
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Copyright waiver for the python package "chainqueue"
|
||||||
|
|
||||||
|
I dedicate any and all copyright interest in this software to the
|
||||||
|
public domain. I make this dedication for the benefit of the public at
|
||||||
|
large and to the detriment of my heirs and successors. I intend this
|
||||||
|
dedication to be an overt act of relinquishment in perpetuity of all
|
||||||
|
present and future rights to this software under copyright law.
|
||||||
|
|
||||||
|
To the best of my knowledge and belief, my contributions are either
|
||||||
|
originally authored by me or are derived from prior works which I have
|
||||||
|
verified are also in the public domain and are not subject to claims
|
||||||
|
of copyright by other parties.
|
||||||
|
|
||||||
|
To the best of my knowledge and belief, no individual, business,
|
||||||
|
organization, government, or other entity has any copyright interest
|
||||||
|
in my contributions, and I affirm that I will not make contributions
|
||||||
|
that are otherwise encumbered.
|
29
WAIVER.asc
Normal file
29
WAIVER.asc
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
-----BEGIN PGP MESSAGE-----
|
||||||
|
|
||||||
|
owGVU3tQFHUcvztPxAW1KZNp4vETfJUXaCgRoiQIeGkEiIBOJrt7v7v7cXe7yz64
|
||||||
|
LhDGfPAoKmi0A8dHmRQlA4xnIeTENT2YkhzIkEc1XlHkCIeTSo+5iX67B2r1V3/c
|
||||||
|
zO3+vt/P87evzpulClQv7hvtrPz47TR18yyeCsjbqM9NzaaLxj+KAiks5+CRySwC
|
||||||
|
O4mKIQ+MLA9EMwScQzSzDOBI2kKaIIikzSRiiiQowUiC0AMDNCCaFCEgGQf+GQBp
|
||||||
|
tQL6NhhiRMhDQf6D0ZAABNYo2kkeApGV4QlOoqyIBgbWhmGjgR7YSAv0j05DI8w+
|
||||||
|
I4aCDDQiEbBGvzb/MikSVpI3QYXfj4uXRR7ZIKPM2hzADBEvKAOCRNNQEFhekOlk
|
||||||
|
gfIWJiTuIsQolIwHWJyFCEhaweGhVfaOBLOCjD1xkOegKCHRIZ9j7wSH7cqHMpVR
|
||||||
|
EiVsVYlC8Cu7OwKJMeCg74RlJe3RBJHDTlsVZrRbGNZuhYZpgxQWAY06+YBmGeyS
|
||||||
|
kmTJ2ByGhAjv8gSLARGD5eBOJNwfD/GeA9ggwEHKc5gYt4wV8qwNcDzCr+0sbxGA
|
||||||
|
3YxoM87FTBZDAntHRoTH5BXSKrD+Gm8H72/NXzueYFgRp0sVQpwWNktbSWQTCOzh
|
||||||
|
jkUsgpUV4vvEiwgK/8MvI7MbUDEySKRVByhJQAzuUYfNmkgGPa8UpwMmuTFG7kcn
|
||||||
|
m/Wz4Se5IjMpKPf0v/eTwDb+HahOodcD0mhEvA2LJEX8ZEf4gstOlYv6jwVCGZGT
|
||||||
|
UFjtSMCFMLRkozCHIZqo0sRqVepAVdiixdrAZeNvcI+EV3z2Q0XWzFc5WyN/iypi
|
||||||
|
7j0zb5JjFkxtzw3Ze2SFIdU192jctk7fS5u7J7qbvloaVRHS8XXt2Cde32+Tq4eu
|
||||||
|
tpz0ZI6csJwrG6gY/X54cLT0/l+butJ8aOLyqZjBd9Z+9+k6b15NeOm16JWxwZ09
|
||||||
|
Ne9rD6lfpi62ORtLhOX1I5q2xvFvvnhlfuLCa+VrHo59ZkDzRKj7mHt9YnN2lfYM
|
||||||
|
ashqWpLyQHlvxvzE9qSmi5k7+9eeKtBcab1x4nq8yRtZPRaz0FVTsOWpnHlPX1ab
|
||||||
|
g1Z9uyW2uC3GVUVpbzyaUP5LfVJyxINHJnoGrfp2XWj2a40FtYdu9oTteiG10t36
|
||||||
|
Yq73w9VLb1aMhs1putosUYf7un5ekORtpPdtvbD1fF9HUG2n7UpR+gr1+fVs1s7D
|
||||||
|
hVROiNsUc4kuOdDb8lCE1Du4YZORI/S7XXXtUZungj0NjZXHb3mmPIk/Hs3fVVA2
|
||||||
|
4HTOOTu748uGeovxOjdS9+Zf5fUB3SX3habmfw4SawMdnu4z1X0qX+dbf9hsaVmu
|
||||||
|
jncDjxlTTqdb9jjiziE3uTx+E1Aty3iv9INWV513X7hTuLUoklRFJE/sWDnslvqT
|
||||||
|
ug6M7n/8bMNkW0vc7xt0zu2PbQvYfVz75HA6CNpzYSiljA2wcoMZYxt/sqw6+OcO
|
||||||
|
Pj5p6PXM59Ytydib0H8pqNdXWVm9ZlKjPjl177O+BE9ATiGfuz+4KD3f2SflVZWn
|
||||||
|
nuaEvwE=
|
||||||
|
=lGEV
|
||||||
|
-----END PGP MESSAGE-----
|
8
chainqueue/cli/arg.py
Normal file
8
chainqueue/cli/arg.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
def apply_flag(flag):
|
||||||
|
flag.add('queue')
|
||||||
|
return flag
|
||||||
|
|
||||||
|
|
||||||
|
def apply_arg(arg):
|
||||||
|
arg.add_long('tx-digest-size', 'queue', type=int, help='Size of transaction hash in bytes')
|
||||||
|
return arg
|
10
chainqueue/cli/config.py
Normal file
10
chainqueue/cli/config.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
def process_config(config, args, flags):
|
||||||
|
args_override = {}
|
||||||
|
|
||||||
|
args_override['QUEUE_BACKEND'] = getattr(args, 'backend')
|
||||||
|
args_override['TX_DIGEST_SIZE'] = getattr(args, 'tx_digest_size')
|
||||||
|
args_override['QUEUE_STATE_PATH'] = getattr(args, 'state_dir')
|
||||||
|
|
||||||
|
config.dict_override(args_override, 'local cli args')
|
||||||
|
|
||||||
|
return config
|
@ -1,9 +1,8 @@
|
|||||||
[database]
|
[queue]
|
||||||
name =
|
backend = mem
|
||||||
engine =
|
state_path =
|
||||||
driver =
|
index_path =
|
||||||
host =
|
counter_path =
|
||||||
port =
|
|
||||||
user =
|
[tx]
|
||||||
password =
|
digest_size = 32
|
||||||
debug = 0
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# standard imports
|
# standard imports
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
# ecxternal imports
|
# external imports
|
||||||
from hexathon import (
|
from hexathon import (
|
||||||
add_0x,
|
add_0x,
|
||||||
strip_0x,
|
strip_0x,
|
||||||
@ -44,6 +44,12 @@ class QueueEntry:
|
|||||||
return tx_hash
|
return tx_hash
|
||||||
|
|
||||||
|
|
||||||
|
def local_state(self):
|
||||||
|
state = self.store.state(self.k)
|
||||||
|
state_str = self.store.name(state)
|
||||||
|
return (state, state_str,)
|
||||||
|
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
(self.k, self.signed_tx) = self.store.get(self.tx_hash)
|
(self.k, self.signed_tx) = self.store.get(self.tx_hash)
|
||||||
self.synced = True
|
self.synced = True
|
||||||
@ -134,8 +140,12 @@ class QueueEntry:
|
|||||||
self.store.cache.set_block(self.tx_hash, block, tx)
|
self.store.cache.set_block(self.tx_hash, block, tx)
|
||||||
|
|
||||||
|
|
||||||
|
def test(self, state):
|
||||||
|
return self.__match_state(state)
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
v = self.store.get(self.tx_hash)
|
v = self.store.get(self.tx_hash)
|
||||||
n = self.store.state(v[0])
|
n = self.store.state(v[0])
|
||||||
s = self.store.name(n)
|
s = self.store.name(n)
|
||||||
return '{}: {}'.format(self.tx_hash, s)
|
return '{}: {} ({})'.format(self.k, s, n)
|
||||||
|
@ -24,12 +24,6 @@ class CacheIntegrityError(ChainQueueException):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class BackendIntegrityError(ChainQueueException):
|
|
||||||
"""Raised when queue backend has invalid state
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class DuplicateTxError(ChainQueueException):
|
class DuplicateTxError(ChainQueueException):
|
||||||
"""Backend already knows transaction
|
"""Backend already knows transaction
|
||||||
"""
|
"""
|
||||||
|
@ -4,15 +4,19 @@
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
import importlib
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from hexathon import add_0x
|
from hexathon import add_0x
|
||||||
import chainlib.cli
|
import chainlib.cli
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from chainqueue.cli import Outputter
|
import chainqueue.cli
|
||||||
|
#from chainqueue.cli.output import Outputter
|
||||||
|
from chainqueue.settings import ChainqueueSettings
|
||||||
|
from chainqueue.store import Store
|
||||||
|
from chainqueue.entry import QueueEntry
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
@ -21,30 +25,31 @@ logg = logging.getLogger()
|
|||||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
||||||
|
|
||||||
arg_flags = chainlib.cli.argflag_std_base | chainlib.cli.Flag.CHAIN_SPEC
|
arg_flags = chainlib.cli.argflag_std_base | chainlib.cli.Flag.CHAIN_SPEC | chainlib.cli.Flag.UNSAFE
|
||||||
argparser = chainlib.cli.ArgumentParser(arg_flags)
|
argparser = chainlib.cli.ArgumentParser(arg_flags)
|
||||||
argparser.add_argument('--backend', type=str, default='sql', help='Backend to use (currently only "sql")')
|
argparser.add_argument('--backend', type=str, default='sql', help='Backend to use')
|
||||||
argparser.add_argument('--start', type=str, help='Oldest transaction hash to include in results')
|
|
||||||
argparser.add_argument('--end', type=str, help='Newest transaction hash to include in results')
|
|
||||||
argparser.add_argument('--error', action='store_true', help='Only show transactions which have error state')
|
argparser.add_argument('--error', action='store_true', help='Only show transactions which have error state')
|
||||||
argparser.add_argument('--pending', action='store_true', help='Omit finalized transactions')
|
argparser.add_argument('--no-final', action='store_true', dest='no_final', help='Omit finalized transactions')
|
||||||
argparser.add_argument('--status-mask', type=int, dest='status_mask', help='Manually specify status bitmask value to match (overrides --error and --pending)')
|
argparser.add_argument('--status-mask', type=str, dest='status_mask', action='append', default=[], help='Manually specify status bitmask value to match (overrides --error and --pending)')
|
||||||
argparser.add_argument('--summary', action='store_true', help='output summary for each status category')
|
argparser.add_argument('--exact', action='store_true', help='Match status exact')
|
||||||
argparser.add_argument('-o', '--column', dest='column', action='append', type=str, help='add a column to display')
|
argparser.add_argument('--include-pending', action='store_true', dest='include_pending', help='Include transactions in unprocessed state (pending)')
|
||||||
argparser.add_positional('address', type=str, help='Ethereum address of recipient')
|
argparser.add_argument('--renderer', type=str, default=[], action='append', help='Transaction renderer for output')
|
||||||
|
argparser.add_positional('address', required=False, type=str, help='Ethereum address of recipient')
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
extra_args = {
|
extra_args = {
|
||||||
'address': None,
|
'address': None,
|
||||||
'backend': None,
|
'backend': None,
|
||||||
'start': None,
|
'state_dir': None,
|
||||||
'end': None,
|
'exact': None,
|
||||||
'error': None,
|
'error': None,
|
||||||
'pending': None,
|
'include_pending': '_PENDING',
|
||||||
'status_mask': None,
|
'status_mask': None,
|
||||||
'column': None,
|
'no_final': None,
|
||||||
'summary': None,
|
'renderer': None,
|
||||||
}
|
}
|
||||||
config = chainlib.cli.Config.from_args(args, arg_flags, extra_args=extra_args, base_config_dir=config_dir)
|
config = chainlib.cli.Config.from_args(args, arg_flags, extra_args=extra_args, base_config_dir=config_dir)
|
||||||
|
config = chainqueue.cli.config.process_config(config, args, 0)
|
||||||
|
logg.debug('config loaded:\n{}'.format(config))
|
||||||
|
|
||||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||||
|
|
||||||
@ -58,36 +63,40 @@ if status_mask == None:
|
|||||||
|
|
||||||
tx_getter = None
|
tx_getter = None
|
||||||
tx_lister = None
|
tx_lister = None
|
||||||
session_method = None
|
#output_cols = config.get('_COLUMN')
|
||||||
if config.get('_BACKEND') == 'sql':
|
|
||||||
from chainqueue.sql.query import get_account_tx as tx_lister
|
|
||||||
from chainqueue.sql.query import get_tx_cache as tx_getter
|
|
||||||
from chainqueue.runnable.sql import setup_backend
|
|
||||||
from chainqueue.db.models.base import SessionBase
|
|
||||||
setup_backend(config, debug=config.true('DATABASE_DEBUG'))
|
|
||||||
session_method = SessionBase.create_session
|
|
||||||
else:
|
|
||||||
raise NotImplementedError('backend {} not implemented'.format(config.get('_BACKEND')))
|
|
||||||
|
|
||||||
output_cols = config.get('_COLUMN')
|
renderers_mods = []
|
||||||
|
for renderer in config.get('_RENDERER'):
|
||||||
|
m = importlib.import_module(renderer)
|
||||||
|
renderers_mods.append(m)
|
||||||
|
logg.info('using renderer module {}'.format(renderer))
|
||||||
|
|
||||||
|
settings = ChainqueueSettings()
|
||||||
|
settings.process(config)
|
||||||
|
logg.debug('settings:\n{}'.format(settings))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
since = config.get('_START', None)
|
# since = config.get('_START', None)
|
||||||
if since != None:
|
# if since != None:
|
||||||
since = add_0x(since)
|
# since = add_0x(since)
|
||||||
until = config.get('_END', None)
|
# until = config.get('_END', None)
|
||||||
if until != None:
|
# if until != None:
|
||||||
until = add_0x(until)
|
# until = add_0x(until)
|
||||||
txs = tx_lister(chain_spec, config.get('_ADDRESS'), since=since, until=until, status=status_mask, not_status=not_status_mask)
|
# txs = tx_lister(chain_spec, config.get('_ADDRESS'), since=since, until=until, status=status_mask, not_status=not_status_mask)
|
||||||
outputter = Outputter(chain_spec, sys.stdout, tx_getter, session_method=session_method, decode_status=config.true('_RAW'), cols=output_cols)
|
txs = settings.get('QUEUE_STORE').by_state(state=settings.get('QUEUE_STATUS_FILTER'), strict=config.get('_EXACT'), include_pending=config.get('_PENDING'))
|
||||||
if config.get('_SUMMARY'):
|
|
||||||
for k in txs.keys():
|
for i, tx_hash in enumerate(txs):
|
||||||
outputter.add(k)
|
entry = QueueEntry(settings.get('QUEUE_STORE'), tx_hash)
|
||||||
outputter.decode_summary()
|
entry.load()
|
||||||
else:
|
v = None
|
||||||
for k in txs.keys():
|
if len(renderers_mods) == 0:
|
||||||
outputter.decode_single(k)
|
v = str(entry)
|
||||||
|
else:
|
||||||
|
for m in renderers_mods:
|
||||||
|
v = m.apply(i, settings, v, settings.get('CHAIN_SPEC'), entry)
|
||||||
|
print(v)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
# standard imports
|
|
||||||
import logging
|
|
||||||
|
|
||||||
# local imports
|
|
||||||
from chainqueue.db.models.base import SessionBase
|
|
||||||
from chainqueue.db import dsn_from_config
|
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def setup_backend(config, debug=False):
|
|
||||||
dsn = dsn_from_config(config)
|
|
||||||
logg.debug('dsn {}'.format(dsn))
|
|
||||||
SessionBase.connect(dsn, debug=debug)
|
|
51
chainqueue/runnable/state.py
Normal file
51
chainqueue/runnable/state.py
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
# standard imports
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
# local imports
|
||||||
|
from chainqueue.state import Status
|
||||||
|
|
||||||
|
argparser = argparse.ArgumentParser()
|
||||||
|
argparser.add_argument('-r', '--raw', dest='r', action='store_true', help='Always print pure state element strings')
|
||||||
|
argparser.add_argument('state', type=str, help='State to interpret')
|
||||||
|
args = argparser.parse_args()
|
||||||
|
|
||||||
|
status_interpreter = Status(None, allow_invalid=True)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_numeric(v, elements=False):
|
||||||
|
if elements:
|
||||||
|
if not status_interpreter.is_pure(v):
|
||||||
|
return status_interpreter.elements(v)
|
||||||
|
return status_interpreter.name(v)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_string(v):
|
||||||
|
try:
|
||||||
|
return status_interpreter.from_name(v)
|
||||||
|
except AttributeError:
|
||||||
|
return status_interpreter.from_elements(v)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
v = None
|
||||||
|
numeric = False
|
||||||
|
try:
|
||||||
|
v = int(args.state)
|
||||||
|
numeric = True
|
||||||
|
except:
|
||||||
|
v = args.state
|
||||||
|
|
||||||
|
r = None
|
||||||
|
if numeric:
|
||||||
|
r = handle_numeric(v, elements=args.r)
|
||||||
|
else:
|
||||||
|
r = handle_string(v)
|
||||||
|
|
||||||
|
print(r)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
99
chainqueue/settings.py
Normal file
99
chainqueue/settings.py
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
# standard imports
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# external imports
|
||||||
|
from chainlib.settings import ChainSettings
|
||||||
|
from chainqueue.state import Status
|
||||||
|
from chainqueue.store import Store
|
||||||
|
|
||||||
|
logg = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def process_queue_tx(settings, config):
|
||||||
|
settings.set('TX_DIGEST_SIZE', config.get('TX_DIGEST_SIZE'))
|
||||||
|
return settings
|
||||||
|
|
||||||
|
|
||||||
|
def process_queue_store(settings, config):
|
||||||
|
status = Status(settings.get('QUEUE_STORE_FACTORY'), allow_invalid=True)
|
||||||
|
settings.set('QUEUE_STATE_STORE', status)
|
||||||
|
store = Store(
|
||||||
|
settings.get('CHAIN_SPEC'),
|
||||||
|
settings.get('QUEUE_STATE_STORE'),
|
||||||
|
settings.get('QUEUE_INDEX_STORE'),
|
||||||
|
settings.get('QUEUE_COUNTER_STORE'),
|
||||||
|
sync=True,
|
||||||
|
)
|
||||||
|
settings.set('QUEUE_STORE', store)
|
||||||
|
return settings
|
||||||
|
|
||||||
|
|
||||||
|
def process_queue_paths(settings, config):
|
||||||
|
index_dir = config.get('QUEUE_INDEX_PATH')
|
||||||
|
if index_dir == None:
|
||||||
|
index_dir = os.path.join(config.get('STATE_PATH'), 'tx')
|
||||||
|
|
||||||
|
counter_dir = config.get('QUEUE_COUNTER_PATH')
|
||||||
|
if counter_dir == None:
|
||||||
|
counter_dir = os.path.join(config.get('STATE_PATH'))
|
||||||
|
|
||||||
|
settings.set('QUEUE_STATE_PATH', config.get('STATE_PATH'))
|
||||||
|
settings.set('QUEUE_INDEX_PATH', index_dir)
|
||||||
|
settings.set('QUEUE_COUNTER_PATH', counter_dir)
|
||||||
|
return settings
|
||||||
|
|
||||||
|
|
||||||
|
def process_queue_backend_fs(settings, config):
|
||||||
|
from chainqueue.store.fs import IndexStore
|
||||||
|
from chainqueue.store.fs import CounterStore
|
||||||
|
from shep.store.file import SimpleFileStoreFactory
|
||||||
|
index_store = IndexStore(settings.o['QUEUE_INDEX_PATH'], digest_bytes=int(settings.o['TX_DIGEST_SIZE']))
|
||||||
|
counter_store = CounterStore(settings.o['QUEUE_COUNTER_PATH'])
|
||||||
|
factory = SimpleFileStoreFactory(settings.o['QUEUE_STATE_PATH'], use_lock=True).add
|
||||||
|
|
||||||
|
settings.set('QUEUE_INDEX_STORE', index_store)
|
||||||
|
settings.set('QUEUE_COUNTER_STORE', counter_store)
|
||||||
|
settings.set('QUEUE_STORE_FACTORY', factory)
|
||||||
|
|
||||||
|
return settings
|
||||||
|
|
||||||
|
|
||||||
|
def process_queue_status_filter(settings, config):
|
||||||
|
states = 0
|
||||||
|
store = settings.get('QUEUE_STATE_STORE')
|
||||||
|
if len(config.get('_STATUS_MASK')) == 0:
|
||||||
|
for v in store.all(numeric=True):
|
||||||
|
states |= v
|
||||||
|
logg.debug('state store {}'.format(states))
|
||||||
|
else:
|
||||||
|
for v in config.get('_STATUS_MASK'):
|
||||||
|
try:
|
||||||
|
states |= int(v)
|
||||||
|
continue
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
state = store.from_name(v)
|
||||||
|
logg.debug('resolved state argument {} to numeric state {}'.format(v, state))
|
||||||
|
states |= state
|
||||||
|
|
||||||
|
settings.set('QUEUE_STATUS_FILTER', states)
|
||||||
|
return settings
|
||||||
|
|
||||||
|
|
||||||
|
def process_queue(settings, config):
|
||||||
|
settings = process_queue_tx(settings, config)
|
||||||
|
settings = process_queue_paths(settings, config)
|
||||||
|
if config.get('QUEUE_BACKEND') == 'fs':
|
||||||
|
settings = process_queue_backend_fs(settings, config)
|
||||||
|
settings = process_queue_backend(settings, config)
|
||||||
|
settings = process_queue_store(settings, config)
|
||||||
|
settings = process_queue_status_filter(settings, config)
|
||||||
|
return settings
|
||||||
|
|
||||||
|
|
||||||
|
def process_settings(settings, config):
|
||||||
|
super(ChainqueueSettings, settings).process(config)
|
||||||
|
settings = settings.process_queue(settings, config)
|
||||||
|
return settings
|
@ -9,7 +9,7 @@ logg = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class Verify:
|
class Verify:
|
||||||
|
|
||||||
def verify(self, state_store, from_state, to_state):
|
def verify(self, state_store, key, from_state, to_state):
|
||||||
to_state_name = state_store.name(to_state)
|
to_state_name = state_store.name(to_state)
|
||||||
m = None
|
m = None
|
||||||
try:
|
try:
|
||||||
@ -106,10 +106,12 @@ class Verify:
|
|||||||
|
|
||||||
class Status(shep.persist.PersistedState):
|
class Status(shep.persist.PersistedState):
|
||||||
|
|
||||||
def __init__(self, store_factory):
|
bits = 12
|
||||||
|
|
||||||
|
def __init__(self, store_factory, allow_invalid=False, event_callback=None):
|
||||||
verify = Verify().verify
|
verify = Verify().verify
|
||||||
self.set_default_state('PENDING')
|
self.set_default_state('PENDING')
|
||||||
super(Status, self).__init__(store_factory, 12, verifier=verify)
|
super(Status, self).__init__(store_factory, self.bits, verifier=verify, check_alias=not allow_invalid, event_callback=event_callback)
|
||||||
self.add('QUEUED')
|
self.add('QUEUED')
|
||||||
self.add('RESERVED')
|
self.add('RESERVED')
|
||||||
self.add('IN_NETWORK')
|
self.add('IN_NETWORK')
|
||||||
|
@ -2,12 +2,15 @@
|
|||||||
import re
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from chainqueue.cache import CacheTx
|
from chainqueue.cache import CacheTx
|
||||||
from chainqueue.entry import QueueEntry
|
from chainqueue.entry import QueueEntry
|
||||||
from chainqueue.error import (
|
from chainqueue.error import NotLocalTxError
|
||||||
NotLocalTxError,
|
from chainqueue.enum import (
|
||||||
|
StatusBits,
|
||||||
|
all_errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
logg = logging.getLogger(__name__)
|
||||||
@ -21,11 +24,12 @@ def from_key(k):
|
|||||||
(ts_str, seq_str, tx_hash) = k.split('_')
|
(ts_str, seq_str, tx_hash) = k.split('_')
|
||||||
return (float(ts_str), int(seq_str), tx_hash, )
|
return (float(ts_str), int(seq_str), tx_hash, )
|
||||||
|
|
||||||
|
all_local_errors = all_errors() - StatusBits.NETWORK_ERROR
|
||||||
|
|
||||||
re_u = r'^[^_][_A-Z]+$'
|
re_u = r'^[^_][_A-Z]+$'
|
||||||
class Store:
|
class Store:
|
||||||
|
|
||||||
def __init__(self, chain_spec, state_store, index_store, counter, cache=None):
|
def __init__(self, chain_spec, state_store, index_store, counter, cache=None, sync=True):
|
||||||
self.chain_spec = chain_spec
|
self.chain_spec = chain_spec
|
||||||
self.cache = cache
|
self.cache = cache
|
||||||
self.state_store = state_store
|
self.state_store = state_store
|
||||||
@ -43,9 +47,21 @@ class Store:
|
|||||||
'unset',
|
'unset',
|
||||||
'name',
|
'name',
|
||||||
'modified',
|
'modified',
|
||||||
|
'purge',
|
||||||
]:
|
]:
|
||||||
setattr(self, v, getattr(self.state_store, v))
|
setattr(self, v, getattr(self.state_store, v))
|
||||||
self.state_store.sync()
|
|
||||||
|
if not sync:
|
||||||
|
return
|
||||||
|
|
||||||
|
sync_err = None
|
||||||
|
try:
|
||||||
|
self.state_store.sync()
|
||||||
|
except Exception as e:
|
||||||
|
sync_err = e
|
||||||
|
|
||||||
|
if sync_err != None:
|
||||||
|
raise FileNotFoundError(sync_err)
|
||||||
|
|
||||||
|
|
||||||
def put(self, v, cache_adapter=CacheTx):
|
def put(self, v, cache_adapter=CacheTx):
|
||||||
@ -63,29 +79,53 @@ class Store:
|
|||||||
|
|
||||||
|
|
||||||
def get(self, k):
|
def get(self, k):
|
||||||
|
v = None
|
||||||
|
s = self.index_store.get(k)
|
||||||
|
err = None
|
||||||
try:
|
try:
|
||||||
s = self.index_store.get(k)
|
v = self.state_store.get(s)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError as e:
|
||||||
raise NotLocalTxError(k)
|
err = e
|
||||||
v = self.state_store.get(s)
|
if v == None:
|
||||||
|
raise NotLocalTxError('could not find tx {}: {}'.format(k, err))
|
||||||
return (s, v,)
|
return (s, v,)
|
||||||
|
|
||||||
|
|
||||||
def by_state(self, state=0, limit=4096, strict=False, threshold=None):
|
def by_state(self, state=0, not_state=0, include_pending=False, limit=4096, strict=False, threshold=None):
|
||||||
hashes = []
|
hashes = []
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
refs_state = self.state_store.list(state)
|
refs_state = []
|
||||||
|
if state > 0:
|
||||||
|
if self.state_store.is_pure(state):
|
||||||
|
refs_state = self.state_store.list(state)
|
||||||
|
elif strict:
|
||||||
|
refs_state = self.state_store.list(state)
|
||||||
|
else:
|
||||||
|
for v in self.state_store.elements(state, numeric=True):
|
||||||
|
refs_state += self.state_store.list(v)
|
||||||
|
refs_state = list(set(refs_state))
|
||||||
|
if include_pending:
|
||||||
|
refs_state += self.state_store.list(0)
|
||||||
|
|
||||||
|
refs_state.sort()
|
||||||
|
|
||||||
for ref in refs_state:
|
for ref in refs_state:
|
||||||
v = from_key(ref)
|
v = from_key(ref)
|
||||||
hsh = v[2]
|
hsh = v[2]
|
||||||
|
|
||||||
|
item_state = self.state_store.state(ref)
|
||||||
|
|
||||||
if strict:
|
if strict:
|
||||||
item_state = self.state_store.state(ref)
|
|
||||||
if item_state & state != item_state:
|
if item_state & state != item_state:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if item_state & not_state > 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
item_state_str = self.state_store.name(item_state)
|
||||||
|
logg.info('state {} {} ({})'.format(ref, item_state_str, item_state))
|
||||||
|
|
||||||
if threshold != None:
|
if threshold != None:
|
||||||
v = self.state_store.modified(ref)
|
v = self.state_store.modified(ref)
|
||||||
if v > threshold:
|
if v > threshold:
|
||||||
@ -93,9 +133,11 @@ class Store:
|
|||||||
|
|
||||||
hashes.append(hsh)
|
hashes.append(hsh)
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
if limit > 0 and i == limit:
|
||||||
|
break
|
||||||
|
|
||||||
|
#hashes.sort()
|
||||||
hashes.sort()
|
|
||||||
return hashes
|
return hashes
|
||||||
|
|
||||||
|
|
||||||
@ -107,8 +149,19 @@ class Store:
|
|||||||
return self.by_state(state=self.DEFERRED, limit=limit, threshold=threshold)
|
return self.by_state(state=self.DEFERRED, limit=limit, threshold=threshold)
|
||||||
|
|
||||||
|
|
||||||
|
def failed(self, limit=4096):
|
||||||
|
#return self.by_state(state=all_local_errors, limit=limit)
|
||||||
|
r = []
|
||||||
|
r += self.by_state(state=self.LOCAL_ERROR, limit=limit)
|
||||||
|
r += self.by_state(state=self.NODE_ERROR, limit=limit)
|
||||||
|
r.sort()
|
||||||
|
if len(r) > limit:
|
||||||
|
r = r[:limit]
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
def pending(self, limit=4096):
|
def pending(self, limit=4096):
|
||||||
return self.by_state(state=0, limit=limit, strict=True)
|
return self.by_state(include_pending=True, limit=limit, strict=True)
|
||||||
|
|
||||||
|
|
||||||
def reserve(self, k):
|
def reserve(self, k):
|
||||||
@ -129,6 +182,7 @@ class Store:
|
|||||||
def fail(self, k):
|
def fail(self, k):
|
||||||
entry = QueueEntry(self, k)
|
entry = QueueEntry(self, k)
|
||||||
entry.load()
|
entry.load()
|
||||||
|
logg.debug('fail {}'.format(k))
|
||||||
entry.sendfail()
|
entry.sendfail()
|
||||||
|
|
||||||
|
|
||||||
@ -152,3 +206,13 @@ class Store:
|
|||||||
entry = QueueEntry(self, k)
|
entry = QueueEntry(self, k)
|
||||||
entry.load()
|
entry.load()
|
||||||
entry.sent()
|
entry.sent()
|
||||||
|
|
||||||
|
|
||||||
|
def is_reserved(self, k):
|
||||||
|
entry = QueueEntry(self, k)
|
||||||
|
entry.load()
|
||||||
|
return entry.test(self.RESERVED)
|
||||||
|
|
||||||
|
|
||||||
|
def sync(self):
|
||||||
|
self.state_store.sync()
|
||||||
|
@ -6,7 +6,10 @@ import logging
|
|||||||
from leveldir.hex import HexDir
|
from leveldir.hex import HexDir
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from chainqueue.error import DuplicateTxError
|
from chainqueue.error import (
|
||||||
|
DuplicateTxError,
|
||||||
|
NotLocalTxError,
|
||||||
|
)
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
logg = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -22,7 +25,7 @@ class IndexStore(HexDir):
|
|||||||
existing = None
|
existing = None
|
||||||
try:
|
try:
|
||||||
existing = self.get(k)
|
existing = self.get(k)
|
||||||
except FileNotFoundError:
|
except NotLocalTxError:
|
||||||
pass
|
pass
|
||||||
return existing != None
|
return existing != None
|
||||||
|
|
||||||
@ -37,7 +40,14 @@ class IndexStore(HexDir):
|
|||||||
|
|
||||||
def get(self, k):
|
def get(self, k):
|
||||||
fp = self.store.to_filepath(k)
|
fp = self.store.to_filepath(k)
|
||||||
f = open(fp, 'rb')
|
f = None
|
||||||
|
err = None
|
||||||
|
try:
|
||||||
|
f = open(fp, 'rb')
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
err = e
|
||||||
|
if err != None:
|
||||||
|
raise NotLocalTxError(err)
|
||||||
v = f.read()
|
v = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
return v.decode('utf-8')
|
return v.decode('utf-8')
|
||||||
@ -64,7 +74,7 @@ class CounterStore:
|
|||||||
|
|
||||||
v = f.read(8)
|
v = f.read(8)
|
||||||
self.count = int.from_bytes(v, byteorder='big')
|
self.count = int.from_bytes(v, byteorder='big')
|
||||||
logg.info('counter starts at {}'.format(self.count))
|
logg.debug('counter starts at {}'.format(self.count))
|
||||||
|
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
pysha3==1.0.2
|
hexathon~=0.1.7
|
||||||
hexathon~=0.1.5
|
|
||||||
leveldir~=0.3.0
|
leveldir~=0.3.0
|
||||||
alembic==1.4.2
|
confini~=0.6.1
|
||||||
SQLAlchemy==1.3.20
|
chainlib~=0.4.0
|
||||||
confini~=0.6.0
|
shep~=0.3.0
|
||||||
pyxdg~=0.27
|
|
||||||
chainlib>=0.1.0b1,<=0.1.0
|
|
||||||
shep>=0.1.1rc1,<=0.2.0
|
|
||||||
|
25
setup.cfg
25
setup.cfg
@ -1,31 +1,29 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = chainqueue
|
name = chainqueue
|
||||||
version = 0.1.0
|
version = 0.2.4
|
||||||
description = Generic blockchain transaction queue control
|
description = Generic blockchain transaction queue control
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
url = https://gitlab.com/chaintool/chainqueue
|
url = https://git.defalslfy.org/chainqueue,git
|
||||||
keywords =
|
keywords =
|
||||||
cic
|
dlt
|
||||||
cryptocurrency
|
cryptocurrency
|
||||||
ethereum
|
ethereum
|
||||||
solidarity
|
|
||||||
mutual_credit
|
|
||||||
classifiers =
|
classifiers =
|
||||||
Programming Language :: Python :: 3
|
Programming Language :: Python :: 3
|
||||||
Operating System :: OS Independent
|
Operating System :: OS Independent
|
||||||
Development Status :: 3 - Alpha
|
Development Status :: 3 - Alpha
|
||||||
Environment :: Console
|
Environment :: Console
|
||||||
Intended Audience :: Developers
|
Intended Audience :: Developers
|
||||||
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
||||||
Topic :: Internet
|
Topic :: Internet
|
||||||
# Topic :: Blockchain :: EVM
|
# Topic :: Blockchain :: EVM
|
||||||
license = GPL3
|
license = OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
||||||
licence_files =
|
licence_files =
|
||||||
LICENSE.txt
|
LICENSE
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
python_requires = >= 3.6
|
python_requires = >= 3.7
|
||||||
include_package_data = True
|
include_package_data = True
|
||||||
packages =
|
packages =
|
||||||
chainqueue
|
chainqueue
|
||||||
@ -33,7 +31,10 @@ packages =
|
|||||||
chainqueue.unittest
|
chainqueue.unittest
|
||||||
chainqueue.store
|
chainqueue.store
|
||||||
chainqueue.runnable
|
chainqueue.runnable
|
||||||
|
chainqueue.cli
|
||||||
|
chainqueue.data
|
||||||
|
|
||||||
#[options.entry_points]
|
[options.entry_points]
|
||||||
#console_scripts =
|
console_scripts =
|
||||||
# chainqueue-list = chainqueue.runnable.list:main
|
chainqueue-list = chainqueue.runnable.list:main
|
||||||
|
chainqueue-state = chainqueue.runnable.state:main
|
||||||
|
@ -32,7 +32,7 @@ class TestEntry(TestShepBase):
|
|||||||
entry = QueueEntry(self.store, cache_adapter=MockCacheTokenTx)
|
entry = QueueEntry(self.store, cache_adapter=MockCacheTokenTx)
|
||||||
tx_hash_two = entry.create(signed_tx)
|
tx_hash_two = entry.create(signed_tx)
|
||||||
|
|
||||||
txs = self.store.by_state()
|
txs = self.store.by_state(include_pending=True)
|
||||||
self.assertEqual(len(txs), 2)
|
self.assertEqual(len(txs), 2)
|
||||||
|
|
||||||
logg.debug('tx hash one {}'.format(tx_hash_one))
|
logg.debug('tx hash one {}'.format(tx_hash_one))
|
||||||
@ -40,14 +40,14 @@ class TestEntry(TestShepBase):
|
|||||||
entry.load()
|
entry.load()
|
||||||
entry.sent()
|
entry.sent()
|
||||||
|
|
||||||
txs = self.store.by_state()
|
txs = self.store.by_state(include_pending=True)
|
||||||
self.assertEqual(len(txs), 1)
|
self.assertEqual(len(txs), 1)
|
||||||
|
|
||||||
txs = self.store.by_state(state=self.store.IN_NETWORK)
|
txs = self.store.by_state(state=self.store.IN_NETWORK)
|
||||||
self.assertEqual(len(txs), 1)
|
self.assertEqual(len(txs), 1)
|
||||||
|
|
||||||
entry.succeed(None, None)
|
entry.succeed(None, None)
|
||||||
txs = self.store.by_state()
|
txs = self.store.by_state(include_pending=True)
|
||||||
self.assertEqual(len(txs), 1)
|
self.assertEqual(len(txs), 1)
|
||||||
|
|
||||||
entry = QueueEntry(self.store, tx_hash_two)
|
entry = QueueEntry(self.store, tx_hash_two)
|
||||||
@ -78,7 +78,7 @@ class TestEntry(TestShepBase):
|
|||||||
|
|
||||||
entry = QueueEntry(self.store, tx_hash, cache_adapter=MockCacheTokenTx)
|
entry = QueueEntry(self.store, tx_hash, cache_adapter=MockCacheTokenTx)
|
||||||
entry.load()
|
entry.load()
|
||||||
self.assertEqual(str(entry), tx_hash + ': SENDFAIL')
|
self.assertEqual(str(entry.tx_hash), tx_hash)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -6,14 +6,23 @@ import logging
|
|||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
|
from chainlib.chain import ChainSpec
|
||||||
|
from shep.store.noop import NoopStoreFactory
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from chainqueue.store.fs import (
|
from chainqueue.store.fs import (
|
||||||
IndexStore,
|
IndexStore,
|
||||||
CounterStore,
|
CounterStore,
|
||||||
)
|
)
|
||||||
|
from chainqueue.store.base import Store
|
||||||
from chainqueue.error import DuplicateTxError
|
from chainqueue.error import DuplicateTxError
|
||||||
|
from chainqueue.state import Status
|
||||||
|
|
||||||
|
# tests imports
|
||||||
|
from tests.common import (
|
||||||
|
MockTokenCache,
|
||||||
|
MockCacheTokenTx,
|
||||||
|
)
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
@ -58,5 +67,38 @@ class TestStoreImplementations(unittest.TestCase):
|
|||||||
store.put(hx, data)
|
store.put(hx, data)
|
||||||
|
|
||||||
|
|
||||||
|
def test_upcoming_limit(self):
|
||||||
|
index_store = IndexStore(self.path)
|
||||||
|
counter_store = CounterStore(self.path)
|
||||||
|
chain_spec = ChainSpec('foo', 'bar', 42, 'baz')
|
||||||
|
factory = NoopStoreFactory().add
|
||||||
|
state_store = Status(factory)
|
||||||
|
cache_store = MockTokenCache()
|
||||||
|
queue_store = Store(chain_spec, state_store, index_store, counter_store, cache=cache_store)
|
||||||
|
|
||||||
|
txs = []
|
||||||
|
for i in range(3):
|
||||||
|
tx_src = os.urandom(128).hex()
|
||||||
|
tx = queue_store.put(tx_src, cache_adapter=MockCacheTokenTx)
|
||||||
|
txs.append(tx)
|
||||||
|
|
||||||
|
r = queue_store.upcoming(limit=3)
|
||||||
|
self.assertEqual(len(r), 0)
|
||||||
|
|
||||||
|
for tx in txs:
|
||||||
|
queue_store.enqueue(tx[1])
|
||||||
|
|
||||||
|
r = queue_store.upcoming(limit=3)
|
||||||
|
self.assertEqual(len(r), 3)
|
||||||
|
|
||||||
|
queue_store.send_start(txs[0][1])
|
||||||
|
r = queue_store.upcoming(limit=3)
|
||||||
|
self.assertEqual(len(r), 2)
|
||||||
|
|
||||||
|
queue_store.send_end(txs[0][1])
|
||||||
|
r = queue_store.upcoming(limit=3)
|
||||||
|
self.assertEqual(len(r), 2)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user