Add ZMQ, update dependencies

This commit is contained in:
DataHoarder 2023-01-15 08:11:41 +01:00
parent 4f7a4a86de
commit 0849421eb6
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
8 changed files with 646 additions and 12 deletions

16
go.mod
View file

@ -11,19 +11,27 @@ require (
github.com/ake-persson/mapslice-json v0.0.0-20210720081907-22c8edf57807
github.com/floatdrop/lru v1.3.0
github.com/go-faster/xor v0.3.0
github.com/go-zeromq/zmq4 v0.15.0
github.com/gorilla/mux v1.8.0
github.com/holiman/uint256 v1.2.1
github.com/jxskiss/base62 v1.1.0
github.com/lib/pq v1.10.7
github.com/stretchr/testify v1.7.0
github.com/tyler-sommer/stick v1.0.4
golang.org/x/crypto v0.4.0
golang.org/x/exp v0.0.0-20221211140036-ad323defaf05
golang.org/x/net v0.4.0
golang.org/x/crypto v0.5.0
golang.org/x/exp v0.0.0-20230113213754-f9f960f08ad4
golang.org/x/net v0.5.0
lukechampine.com/uint128 v1.2.0
)
require (
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-zeromq/goczmq/v4 v4.2.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

35
go.sum
View file

@ -13,12 +13,18 @@ github.com/ake-persson/mapslice-json v0.0.0-20210720081907-22c8edf57807/go.mod h
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/floatdrop/lru v1.3.0 h1:83abtaKjXcWrPmtzTAk2Ggq8DUKqI29YzrTrB8+vu0c=
github.com/floatdrop/lru v1.3.0/go.mod h1:83zlXKA06Bm32JImNINCiTr0ldadvdAjUe5jSwIaw0s=
github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E=
github.com/go-faster/xor v0.3.0 h1:tc0bdVe31Wj999e5rEj7K3DhHyQNp2VydYyLFj3YSN8=
github.com/go-faster/xor v0.3.0/go.mod h1:x5CaDY9UKErKzqfRfFZdfu+OSTfoZny3w5Ak7UxcipQ=
github.com/go-zeromq/goczmq/v4 v4.2.2 h1:HAJN+i+3NW55ijMJJhk7oWxHKXgAuSBkoFfvr8bYj4U=
github.com/go-zeromq/goczmq/v4 v4.2.2/go.mod h1:Sm/lxrfxP/Oxqs0tnHD6WAhwkWrx+S+1MRrKzcxoaYE=
github.com/go-zeromq/zmq4 v0.15.0 h1:SLqukpmLTx0JsLaOaCCjwy5eBdfJ+ouJX/677HoFbJM=
github.com/go-zeromq/zmq4 v0.15.0/go.mod h1:sD47DcXifeUFsVTB2ps8ijqTpEuTAlYgfuLoiWEXdCE=
github.com/gordonklaus/ineffassign v0.0.0-20210522101830-0589229737b2/go.mod h1:M9mZEtGIsR1oDaZagNPNG9iq9n2HrhZ17dsXk73V3Lw=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
@ -27,14 +33,19 @@ github.com/holiman/uint256 v1.2.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25
github.com/jxskiss/base62 v1.1.0 h1:A5zbF8v8WXx2xixnAKD2w+abC+sIzYJX+nxmhA6HWFw=
github.com/jxskiss/base62 v1.1.0/go.mod h1:HhWAlUXvxKThfOlZbcuFzsqwtF5TcqS9ru3y5GfjWAc=
github.com/kisielk/errcheck v1.6.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tyler-sommer/stick v1.0.4 h1:kuHyr9FFBBPA5dWqHWNFiCdHBqj8Mr/xuCxx7uAbzIk=
github.com/tyler-sommer/stick v1.0.4/go.mod h1:rjBy3zi6GwoxExa6OSRPPPaLqUEKNsBxTeWckhIX1us=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@ -43,10 +54,10 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
golang.org/x/exp v0.0.0-20221211140036-ad323defaf05 h1:T8EldfGCcveFMewH5xAYxxoX3PSQMrsechlUGVFlQBU=
golang.org/x/exp v0.0.0-20221211140036-ad323defaf05/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/exp v0.0.0-20230113213754-f9f960f08ad4 h1:CNkDRtCj8otM5CFz5jYvbr8ioXX8flVsLfDWEj0M5kk=
golang.org/x/exp v0.0.0-20230113213754-f9f960f08ad4/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@ -57,12 +68,14 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 h1:cu5kTvlzcw1Q5S9f5ip1/cpiB4nXvw1XYzFPGgzLUOY=
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -71,11 +84,13 @@ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
@ -86,6 +101,10 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=

201
monero/client/zmq/LICENSE Normal file
View file

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2021 Ciro S. Costa
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -0,0 +1,3 @@
# go-monero ZMQ
Taken from [github.com/cirocosta/go-monero](https://github.com/cirocosta/go-monero/tree/ac58bd1fd1c24265941a0e0cd99edb01ae0c9786/pkg/zmq)

104
monero/client/zmq/types.go Normal file
View file

@ -0,0 +1,104 @@
package zmq
type Topic string
const (
TopicUnknown Topic = "unknown"
TopicMinimalTxPoolAdd Topic = "json-minimal-txpool_add"
TopicFullTxPoolAdd Topic = "json-full-txpool_add"
TopicMinimalChainMain Topic = "json-minimal-chain_main"
TopicFullChainMain Topic = "json-full-chain_main"
)
type MinimalChainMain struct {
FirstHeight uint64 `json:"first_height"`
FirstPrevID string `json:"first_prev_id"`
Ids []string `json:"ids"`
}
type FullChainMain struct {
MajorVersion int `json:"major_version"`
MinorVersion int `json:"minor_version"`
Timestamp int64 `json:"timestamp"`
PrevID string `json:"prev_id"`
Nonce uint64 `json:"nonce"`
MinerTx struct {
Version int `json:"version"`
UnlockTime int64 `json:"unlock_time"`
Inputs []struct {
Gen struct {
Height uint64 `json:"height"`
} `json:"gen"`
} `json:"inputs"`
Outputs []struct {
Amount uint64 `json:"amount"`
ToKey struct {
Key string `json:"key"`
} `json:"to_key"`
} `json:"outputs"`
Extra string `json:"extra"`
Signatures []interface{} `json:"signatures"`
Ringct struct {
Type int `json:"type"`
Encrypted []interface{} `json:"encrypted"`
Commitments []interface{} `json:"commitments"`
Fee uint64 `json:"fee"`
} `json:"ringct"`
} `json:"miner_tx"`
TxHashes []string `json:"tx_hashes"`
}
type MinimalTxPoolAdd struct {
ID string `json:"id"`
BlobSize uint64 `json:"blob_size"`
}
type FullTxPoolAdd struct {
Version int `json:"version"`
UnlockTime int64 `json:"unlock_time"`
Inputs []struct {
ToKey struct {
Amount uint64 `json:"amount"`
KeyOffsets []uint64 `json:"key_offsets"`
KeyImage string `json:"key_image"`
} `json:"to_key"`
} `json:"inputs"`
Outputs []struct {
Amount int `json:"amount"`
ToKey struct {
Key string `json:"key"`
} `json:"to_key"`
} `json:"outputs"`
Extra string `json:"extra"`
Signatures []interface{} `json:"signatures"`
Ringct struct {
Type int `json:"type"`
Encrypted []struct {
Mask string `json:"mask"`
Amount string `json:"amount"`
} `json:"encrypted"`
Commitments []string `json:"commitments"`
Fee int `json:"fee"`
Prunable struct {
RangeProofs []interface{} `json:"range_proofs"`
Bulletproofs []struct {
V []string `json:"V"`
AUpper string `json:"A"`
S string `json:"S"`
T1 string `json:"T1"`
T2 string `json:"T2"`
Taux string `json:"taux"`
Mu string `json:"mu"`
L []string `json:"L"`
R []string `json:"R"`
ALower string `json:"a"`
B string `json:"b"`
T string `json:"t"`
} `json:"bulletproofs"`
Mlsags []interface{} `json:"mlsags"`
PseudoOuts []string `json:"pseudo_outs"`
} `json:"prunable"`
} `json:"ringct"`
}

219
monero/client/zmq/zmq.go Normal file
View file

@ -0,0 +1,219 @@
package zmq
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/go-zeromq/zmq4"
)
type Client struct {
endpoint string
topic Topic
sub zmq4.Socket
}
// NewClient instantiates a new client that will receive monerod's zmq events.
//
// - `topic` is a fully-formed zmq topic to subscribe to
//
// - `endpoint` is the full address where monerod has been configured to
// publish the messages to, including the network schama. for instance,
// considering that monerod has been started with
//
// monerod --zmq-pub tcp://127.0.0.1:18085
//
// `endpoint` should be 'tcp://127.0.0.1:18085'.
func NewClient(endpoint string, topic Topic) *Client {
return &Client{
endpoint: endpoint,
topic: topic,
}
}
// Stream provides channels where instances of the desired topic object are
// sent to.
type Stream struct {
ErrC chan error
FullChainMainC chan *FullChainMain
FullTxPoolAddC chan *FullTxPoolAdd
MinimalChainMainC chan *MinimalChainMain
MinimalTxPoolAddC chan *MinimalTxPoolAdd
}
// Listen listens for a topic pre-configured for this client (via NewClient).
//
// Clients listen to a single topic at a time - to listen to multiple topics,
// create new clients and listen on the corresponding stream's channel.
func (c *Client) Listen(ctx context.Context) (*Stream, error) {
if err := c.listen(ctx, c.topic); err != nil {
return nil, fmt.Errorf("listen on '%s': %w", c.topic, err)
}
stream := &Stream{
ErrC: make(chan error),
FullChainMainC: make(chan *FullChainMain),
FullTxPoolAddC: make(chan *FullTxPoolAdd),
MinimalChainMainC: make(chan *MinimalChainMain),
MinimalTxPoolAddC: make(chan *MinimalTxPoolAdd),
}
go func() {
if err := c.loop(stream); err != nil {
stream.ErrC <- fmt.Errorf("loop: %w", err)
}
close(stream.ErrC)
close(stream.FullChainMainC)
close(stream.FullTxPoolAddC)
close(stream.MinimalChainMainC)
close(stream.MinimalTxPoolAddC)
}()
return stream, nil
}
// Close closes any established connection, if any.
func (c *Client) Close() error {
if c.sub == nil {
return nil
}
return c.sub.Close()
}
func (c *Client) listen(ctx context.Context, topic Topic) error {
c.sub = zmq4.NewSub(ctx)
err := c.sub.Dial(c.endpoint)
if err != nil {
return fmt.Errorf("dial '%s': %w", c.endpoint, err)
}
err = c.sub.SetOption(zmq4.OptionSubscribe, string(topic))
if err != nil {
return fmt.Errorf("subscribe: %w", err)
}
return nil
}
func (c *Client) loop(stream *Stream) error {
for {
msg, err := c.sub.Recv()
if err != nil {
return fmt.Errorf("recv: %w", err)
}
for _, frame := range msg.Frames {
err := c.ingestFrameArray(stream, frame)
if err != nil {
return fmt.Errorf("consume frame: %w", err)
}
}
}
}
func (c *Client) ingestFrameArray(stream *Stream, frame []byte) error {
topic, gson, err := jsonFromFrame(frame)
if err != nil {
return fmt.Errorf("json from frame: %w", err)
}
if c.topic != topic {
return fmt.Errorf("topic '%s' doesn't match "+
"expected '%s'", topic, c.topic)
}
switch c.topic {
case TopicFullChainMain:
return c.transmitFullChainMain(stream, gson)
case TopicFullTxPoolAdd:
return c.transmitFullTxPoolAdd(stream, gson)
case TopicMinimalChainMain:
return c.transmitMinimalChainMain(stream, gson)
case TopicMinimalTxPoolAdd:
return c.transmitMinimalTxPoolAdd(stream, gson)
default:
return fmt.Errorf("unhandled topic '%s'", topic)
}
}
func (c *Client) transmitFullChainMain(stream *Stream, gson []byte) error {
arr := []*FullChainMain{}
if err := json.Unmarshal(gson, &arr); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
for _, element := range arr {
stream.FullChainMainC <- element
}
return nil
}
func (c *Client) transmitFullTxPoolAdd(stream *Stream, gson []byte) error {
arr := []*FullTxPoolAdd{}
if err := json.Unmarshal(gson, &arr); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
for _, element := range arr {
stream.FullTxPoolAddC <- element
}
return nil
}
func (c *Client) transmitMinimalChainMain(stream *Stream, gson []byte) error {
element := &MinimalChainMain{}
if err := json.Unmarshal(gson, element); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
stream.MinimalChainMainC <- element
return nil
}
func (c *Client) transmitMinimalTxPoolAdd(stream *Stream, gson []byte) error {
arr := []*MinimalTxPoolAdd{}
if err := json.Unmarshal(gson, &arr); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
for _, element := range arr {
stream.MinimalTxPoolAddC <- element
}
return nil
}
func jsonFromFrame(frame []byte) (Topic, []byte, error) {
unknown := TopicUnknown
parts := bytes.SplitN(frame, []byte(":"), 2)
if len(parts) != 2 {
return unknown, nil, fmt.Errorf(
"malformed: expected 2 parts, got %d", len(parts))
}
topic, gson := string(parts[0]), parts[1]
switch topic {
case string(TopicMinimalChainMain):
return TopicMinimalChainMain, gson, nil
case string(TopicFullChainMain):
return TopicFullChainMain, gson, nil
case string(TopicFullTxPoolAdd):
return TopicFullTxPoolAdd, gson, nil
case string(TopicMinimalTxPoolAdd):
return TopicMinimalTxPoolAdd, gson, nil
}
return unknown, nil, fmt.Errorf("unknown topic '%s'", topic)
}

View file

@ -0,0 +1,3 @@
package zmq
var JSONFromFrame = jsonFromFrame

View file

@ -0,0 +1,77 @@
package zmq_test
import (
"context"
"git.gammaspectra.live/P2Pool/p2pool-observer/monero/client/zmq"
"log"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestJSONFromFrame(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
input []byte
expectedJSON []byte
expectedTopic zmq.Topic
err string
}{
{
name: "nil",
input: nil,
err: "malformed",
},
{
name: "empty",
input: []byte{},
err: "malformed",
},
{
name: "unknown-topic",
input: []byte(`foobar:[{"foo":"bar"}]`),
err: "unknown topic",
},
{
name: "proper w/ known-topic",
input: []byte(`json-minimal-txpool_add:[{"foo":"bar"}]`),
expectedTopic: zmq.TopicMinimalTxPoolAdd,
expectedJSON: []byte(`[{"foo":"bar"}]`),
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
aTopic, aJSON, err := zmq.JSONFromFrame(tc.input)
if tc.err != "" {
require.Error(t, err)
assert.Contains(t, err.Error(), tc.err)
return
}
assert.NoError(t, err)
assert.Equal(t, tc.expectedTopic, aTopic)
assert.Equal(t, tc.expectedJSON, aJSON)
})
}
}
func TestClient(t *testing.T) {
client := zmq.NewClient(os.Getenv("MONEROD_ZMQ_URL"), "json-minimal-txpool_add")
s, err := client.Listen(context.Background())
if err != nil {
t.Fatal(err)
}
for d := range s.MinimalTxPoolAddC {
log.Print(d)
}
}