Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Goshimmer_without_tipselection
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
COLLET Ismael
Goshimmer_without_tipselection
Commits
cac95695
Commit
cac95695
authored
5 years ago
by
capossele
Browse files
Options
Downloads
Patches
Plain Diff
refactors livefeed
parent
91241bd2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/spa/livefeed.go
+13
-13
13 additions, 13 deletions
plugins/spa/livefeed.go
with
13 additions
and
13 deletions
plugins/spa/livefeed.go
+
13
−
13
View file @
cac95695
...
...
@@ -19,8 +19,8 @@ var liveFeedWorkerPool *workerpool.WorkerPool
func
configureLiveFeed
()
{
liveFeedWorkerPool
=
workerpool
.
New
(
func
(
task
workerpool
.
Task
)
{
task
.
Param
(
0
)
.
(
*
message
.
CachedMessage
)
.
Consume
(
func
(
transaction
*
message
.
Message
)
{
sendToAllWSClient
(
&
msg
{
MsgTypeTx
,
&
tx
{
transaction
.
Id
()
.
String
(),
0
}})
task
.
Param
(
0
)
.
(
*
message
.
CachedMessage
)
.
Consume
(
func
(
message
*
message
.
Message
)
{
sendToAllWSClient
(
&
msg
{
MsgTypeTx
,
&
tx
{
message
.
Id
()
.
String
(),
0
}})
})
task
.
Return
(
nil
)
...
...
@@ -28,26 +28,26 @@ func configureLiveFeed() {
}
func
runLiveFeed
()
{
new
Tx
RateLimiter
:=
time
.
NewTicker
(
time
.
Second
/
10
)
notifyNew
Tx
:=
events
.
NewClosure
(
func
(
tx
*
message
.
CachedMessage
,
metadata
*
tangle
.
CachedMessageMetadata
)
{
new
Msg
RateLimiter
:=
time
.
NewTicker
(
time
.
Second
/
10
)
notifyNew
Msg
:=
events
.
NewClosure
(
func
(
message
*
message
.
CachedMessage
,
metadata
*
tangle
.
CachedMessageMetadata
)
{
metadata
.
Release
()
select
{
case
<-
new
Tx
RateLimiter
.
C
:
liveFeedWorkerPool
.
TrySubmit
(
tx
)
case
<-
new
Msg
RateLimiter
.
C
:
liveFeedWorkerPool
.
TrySubmit
(
message
)
default
:
tx
.
Release
()
message
.
Release
()
}
})
daemon
.
BackgroundWorker
(
"SPA[
Tx
Updater]"
,
func
(
shutdownSignal
<-
chan
struct
{})
{
messagelayer
.
Tangle
.
Events
.
TransactionAttached
.
Attach
(
notifyNew
Tx
)
daemon
.
BackgroundWorker
(
"SPA[
Msg
Updater]"
,
func
(
shutdownSignal
<-
chan
struct
{})
{
messagelayer
.
Tangle
.
Events
.
TransactionAttached
.
Attach
(
notifyNew
Msg
)
liveFeedWorkerPool
.
Start
()
<-
shutdownSignal
log
.
Info
(
"Stopping SPA[
Tx
Updater] ..."
)
messagelayer
.
Tangle
.
Events
.
TransactionAttached
.
Detach
(
notifyNew
Tx
)
new
Tx
RateLimiter
.
Stop
()
log
.
Info
(
"Stopping SPA[
Msg
Updater] ..."
)
messagelayer
.
Tangle
.
Events
.
TransactionAttached
.
Detach
(
notifyNew
Msg
)
new
Msg
RateLimiter
.
Stop
()
liveFeedWorkerPool
.
Stop
()
log
.
Info
(
"Stopping SPA[
Tx
Updater] ... done"
)
log
.
Info
(
"Stopping SPA[
Msg
Updater] ... done"
)
},
shutdown
.
ShutdownPrioritySPA
)
}
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