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
65a91713
Unverified
Commit
65a91713
authored
5 years ago
by
Luca Moser
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
removes sent counter as value from spammed transactions (#163)
parent
b553b432
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/transactionspammer/transactionspammer.go
+21
-12
21 additions, 12 deletions
packages/transactionspammer/transactionspammer.go
plugins/webapi/spammer/plugin.go
+1
-1
1 addition, 1 deletion
plugins/webapi/spammer/plugin.go
with
22 additions
and
13 deletions
packages/transactionspammer/transactionspammer.go
+
21
−
12
View file @
65a91713
package
transactionspammer
import
(
"strings"
"sync"
"time"
"github.com/iotaledger/goshimmer/packages/shutdown"
"github.com/iotaledger/goshimmer/plugins/autopeering/local"
"github.com/iotaledger/goshimmer/packages/gossip"
"github.com/iotaledger/goshimmer/packages/model/meta_transaction"
"github.com/iotaledger/goshimmer/packages/model/value_transaction"
"github.com/iotaledger/goshimmer/packages/shutdown"
"github.com/iotaledger/goshimmer/plugins/autopeering/local"
"github.com/iotaledger/goshimmer/plugins/tipselection"
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/logger"
)
const
logEveryNTransactions
=
5000
var
log
*
logger
.
Logger
var
spamming
=
false
...
...
@@ -23,14 +25,14 @@ var spammingMutex sync.Mutex
var
shutdownSignal
chan
struct
{}
var
done
chan
struct
{}
var
sentCounter
=
uint
(
0
)
func
init
()
{
shutdownSignal
=
make
(
chan
struct
{})
done
=
make
(
chan
struct
{})
}
func
Start
(
tps
uint
)
{
var
targetAddress
=
strings
.
Repeat
(
"SPAMMMMER"
,
9
)
func
Start
(
tps
uint64
)
{
log
=
logger
.
NewLogger
(
"Transaction Spammer"
)
spammingMutex
.
Lock
()
spamming
=
true
...
...
@@ -38,8 +40,11 @@ func Start(tps uint) {
daemon
.
BackgroundWorker
(
"Transaction Spammer"
,
func
(
daemonShutdownSignal
<-
chan
struct
{})
{
start
:=
time
.
Now
()
totalSentCounter
:=
int64
(
0
)
var
totalSentCounter
,
currentSentCounter
uint64
log
.
Infof
(
"started spammer...will output sent count every %d transactions"
,
logEveryNTransactions
)
defer
log
.
Infof
(
"spammer stopped, spammed %d transactions"
,
totalSentCounter
)
for
{
select
{
case
<-
daemonShutdownSignal
:
...
...
@@ -50,13 +55,13 @@ func Start(tps uint) {
return
default
:
s
entCounter
++
currentS
entCounter
++
totalSentCounter
++
tx
:=
value_transaction
.
New
()
tx
.
SetHead
(
true
)
tx
.
SetTail
(
true
)
tx
.
Set
Value
(
totalSentCounter
)
tx
.
Set
Address
(
targetAddress
)
tx
.
SetBranchTransactionHash
(
tipselection
.
GetRandomTip
())
tx
.
SetTrunkTransactionHash
(
tipselection
.
GetRandomTip
())
tx
.
SetTimestamp
(
uint
(
time
.
Now
()
.
Unix
()))
...
...
@@ -67,7 +72,12 @@ func Start(tps uint) {
gossip
.
Events
.
TransactionReceived
.
Trigger
(
&
gossip
.
TransactionReceivedEvent
{
Data
:
tx
.
GetBytes
(),
Peer
:
&
local
.
GetInstance
()
.
Peer
})
if
sentCounter
>=
tps
{
if
totalSentCounter
%
logEveryNTransactions
==
0
{
log
.
Infof
(
"spammed %d transactions"
,
totalSentCounter
)
}
// rate limit to the specified TPS
if
currentSentCounter
>=
tps
{
duration
:=
time
.
Since
(
start
)
if
duration
<
time
.
Second
{
...
...
@@ -75,8 +85,7 @@ func Start(tps uint) {
}
start
=
time
.
Now
()
sentCounter
=
0
currentSentCounter
=
0
}
}
}
...
...
This diff is collapsed.
Click to expand it.
plugins/webapi/spammer/plugin.go
+
1
−
1
View file @
65a91713
...
...
@@ -61,5 +61,5 @@ type Response struct {
type
Request
struct
{
Cmd
string
`json:"cmd"`
Tps
uint
`json:"tps"`
Tps
uint
64
`json:"tps"`
}
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