Skip to content
Snippets Groups Projects
Commit 97cfb525 authored by Hans Moog's avatar Hans Moog
Browse files

Feat: txspammer issues bundles + bundleprocessor triggers events

parent 542ec108
No related branches found
No related tags found
No related merge requests found
......@@ -182,7 +182,7 @@ func (this *ValueTransaction) SetTimestamp(timestamp uint) bool {
this.timestamp = &timestamp
this.BlockHasher()
copy(this.trits[TIMESTAMP_OFFSET:TIMESTAMP_END], trinary.IntToTrits(int64(timestamp))[:TIMESTAMP_SIZE])
copy(this.trits[TIMESTAMP_OFFSET:TIMESTAMP_END], trinary.PadTrits(trinary.IntToTrits(int64(timestamp)), TIMESTAMP_SIZE)[:TIMESTAMP_SIZE])
this.UnblockHasher()
this.SetModified(true)
......
......@@ -18,6 +18,8 @@ var shutdownSignal chan int
var sentCounter = uint(0)
var totalSentCounter = uint(0)
func Start(tps uint) {
startMutex.Lock()
......@@ -28,7 +30,6 @@ func Start(tps uint) {
daemon.BackgroundWorker("Transaction Spammer", func() {
for {
start := time.Now()
totalSentCounter := int64(0)
for {
select {
......@@ -39,15 +40,9 @@ func Start(tps uint) {
return
default:
sentCounter++
totalSentCounter++
tx := value_transaction.New()
tx.SetValue(totalSentCounter)
tx.SetBranchTransactionHash(tipselection.GetRandomTip())
tx.SetTrunkTransactionHash(tipselection.GetRandomTip())
gossip.Events.ReceiveTransaction.Trigger(tx.MetaTransaction)
for _, bundleTransaction := range GenerateBundle(3) {
gossip.Events.ReceiveTransaction.Trigger(bundleTransaction.MetaTransaction)
}
if sentCounter >= tps {
duration := time.Since(start)
......@@ -90,10 +85,13 @@ func GenerateBundle(bundleLength int) (result []*value_transaction.ValueTransact
trunk := tipselection.GetRandomTip()
for i := 0; i < bundleLength; i++ {
sentCounter++
totalSentCounter++
tx := value_transaction.New()
tx.SetTail(i == 0)
tx.SetHead(i == bundleLength - 1)
tx.SetTimestamp(sentCounter)
tx.SetHead(i == bundleLength-1)
tx.SetTimestamp(totalSentCounter)
tx.SetBranchTransactionHash(branch)
tx.SetTrunkTransactionHash(trunk)
......
......@@ -15,6 +15,9 @@ import (
)
func TestProcessSolidBundleHead(t *testing.T) {
// show all error messages for tests
*node.LOG_LEVEL.Value = node.LOG_LEVEL_DEBUG
// start a test node
node.Start(tangle.PLUGIN, PLUGIN)
......
......@@ -69,5 +69,5 @@ type webResponse struct {
type webRequest struct {
Cmd string `json:"cmd"`
Tps int64 `json:"tps"`
Tps uint `json:"tps"`
}
......@@ -16,6 +16,7 @@ var Server = echo.New()
func configure(plugin *node.Plugin) {
Server.HideBanner = true
Server.HidePort = true
Server.GET("/", IndexRequest)
daemon.Events.Shutdown.Attach(events.NewClosure(func() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment