Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goshimmer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iota-imt
goshimmer
Commits
cc1f7db0
Commit
cc1f7db0
authored
5 years ago
by
Wolfgang Welz
Browse files
Options
Downloads
Patches
Plain Diff
Call the zmq send from a goroutine
parent
2d34a35d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/zeromq/plugin.go
+9
-6
9 additions, 6 deletions
plugins/zeromq/plugin.go
with
9 additions
and
6 deletions
plugins/zeromq/plugin.go
+
9
−
6
View file @
cc1f7db0
...
@@ -15,6 +15,7 @@ import (
...
@@ -15,6 +15,7 @@ import (
var
PLUGIN
=
node
.
NewPlugin
(
"ZeroMQ"
,
configure
,
run
)
var
PLUGIN
=
node
.
NewPlugin
(
"ZeroMQ"
,
configure
,
run
)
var
publisher
*
Publisher
var
publisher
*
Publisher
var
emptyTag
=
strings
.
Repeat
(
"9"
,
27
)
// Configure the zeromq plugin
// Configure the zeromq plugin
func
configure
(
plugin
*
node
.
Plugin
)
{
func
configure
(
plugin
*
node
.
Plugin
)
{
...
@@ -31,9 +32,12 @@ func configure(plugin *node.Plugin) {
...
@@ -31,9 +32,12 @@ func configure(plugin *node.Plugin) {
// TODO: should be tangle.Events.TransactionStored
// TODO: should be tangle.Events.TransactionStored
tangle
.
Events
.
TransactionSolid
.
Attach
(
events
.
NewClosure
(
func
(
tx
*
value_transaction
.
ValueTransaction
)
{
tangle
.
Events
.
TransactionSolid
.
Attach
(
events
.
NewClosure
(
func
(
tx
*
value_transaction
.
ValueTransaction
)
{
if
err
:=
publishTx
(
tx
);
err
!=
nil
{
// create goroutine for every event
plugin
.
LogFailure
(
err
.
Error
())
go
func
()
{
}
if
err
:=
publishTx
(
tx
);
err
!=
nil
{
plugin
.
LogFailure
(
err
.
Error
())
}
}()
}))
}))
}
}
...
@@ -72,14 +76,13 @@ func publishTx(tx *value_transaction.ValueTransaction) error {
...
@@ -72,14 +76,13 @@ func publishTx(tx *value_transaction.ValueTransaction) error {
trunk
:=
tx
.
MetaTransaction
.
GetTrunkTransactionHash
()
trunk
:=
tx
.
MetaTransaction
.
GetTrunkTransactionHash
()
branch
:=
tx
.
MetaTransaction
.
GetBranchTransactionHash
()
branch
:=
tx
.
MetaTransaction
.
GetBranchTransactionHash
()
stored
:=
time
.
Now
()
.
Unix
()
stored
:=
time
.
Now
()
.
Unix
()
tag
:=
strings
.
Repeat
(
"9"
,
27
)
// use empty tag
messages
:=
[]
string
{
messages
:=
[]
string
{
"tx"
,
// ZMQ event
"tx"
,
// ZMQ event
hash
.
ToString
(),
// Transaction hash
hash
.
ToString
(),
// Transaction hash
address
.
ToString
(),
// Address
address
.
ToString
(),
// Address
strconv
.
FormatInt
(
value
,
10
),
// Value
strconv
.
FormatInt
(
value
,
10
),
// Value
tag
,
// Obsolete tag
emptyTag
,
// Obsolete tag
strconv
.
FormatInt
(
timestamp
,
10
),
// Timestamp
strconv
.
FormatInt
(
timestamp
,
10
),
// Timestamp
"0"
,
// Index of the transaction in the bundle
"0"
,
// Index of the transaction in the bundle
"0"
,
// Last transaction index of the bundle
"0"
,
// Last transaction index of the bundle
...
@@ -87,7 +90,7 @@ func publishTx(tx *value_transaction.ValueTransaction) error {
...
@@ -87,7 +90,7 @@ func publishTx(tx *value_transaction.ValueTransaction) error {
trunk
.
ToString
(),
// Trunk transaction hash
trunk
.
ToString
(),
// Trunk transaction hash
branch
.
ToString
(),
// Branch transaction hash
branch
.
ToString
(),
// Branch transaction hash
strconv
.
FormatInt
(
stored
,
10
),
// Unix timestamp for when the transaction was received
strconv
.
FormatInt
(
stored
,
10
),
// Unix timestamp for when the transaction was received
tag
,
// Tag
emptyTag
,
// Tag
}
}
return
publisher
.
Send
(
messages
)
return
publisher
.
Send
(
messages
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment