Skip to content
Snippets Groups Projects
Commit 7e81eac9 authored by capossele's avatar capossele
Browse files

:construction: WIP

parent a8c0a045
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ import (
"github.com/iotaledger/goshimmer/packages/gossip"
pb "github.com/iotaledger/goshimmer/packages/gossip/proto"
"github.com/iotaledger/goshimmer/packages/model/value_transaction"
"github.com/iotaledger/goshimmer/plugins/autopeering/local"
"github.com/iotaledger/goshimmer/plugins/tipselection"
"github.com/iotaledger/hive.go/daemon"
)
......@@ -53,7 +54,7 @@ func Start(tps uint) {
mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()}
b, _ := proto.Marshal(mtx)
gossip.Events.NewTransaction.Trigger(b)
gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b, Peer: &local.INSTANCE.Peer})
if sentCounter >= tps {
duration := time.Since(start)
......
package bundleprocessor
import (
"github.com/iotaledger/hive.go/parameter"
"os"
"sync"
"testing"
"github.com/iotaledger/goshimmer/packages/client"
"github.com/iotaledger/goshimmer/packages/model/bundle"
"github.com/iotaledger/goshimmer/packages/model/value_transaction"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/goshimmer/plugins/tangle"
"github.com/iotaledger/goshimmer/plugins/tipselection"
"github.com/iotaledger/goshimmer/packages/client"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/node"
"github.com/iotaledger/goshimmer/plugins/tangle"
"github.com/iotaledger/hive.go/parameter"
"github.com/iotaledger/iota.go/consts"
"github.com/magiconair/properties/assert"
)
......@@ -49,7 +45,7 @@ func BenchmarkValidateSignatures(b *testing.B) {
}
func TestMain(m *testing.M) {
parameter.FetchConfig()
parameter.FetchConfig(false)
os.Exit(m.Run())
}
......
......@@ -2,6 +2,7 @@ package gossip
import (
"github.com/golang/protobuf/proto"
zL "github.com/iotaledger/autopeering-sim/logger"
"github.com/iotaledger/autopeering-sim/peer/service"
"github.com/iotaledger/autopeering-sim/selection"
gp "github.com/iotaledger/goshimmer/packages/gossip"
......@@ -14,7 +15,29 @@ import (
"go.uber.org/zap"
)
const defaultZLC = `{
"level": "info",
"development": false,
"outputPaths": ["stdout"],
"errorOutputPaths": ["stderr"],
"encoding": "console",
"encoderConfig": {
"timeKey": "ts",
"levelKey": "level",
"nameKey": "logger",
"callerKey": "caller",
"messageKey": "msg",
"stacktraceKey": "stacktrace",
"lineEnding": "",
"levelEncoder": "",
"timeEncoder": "iso8601",
"durationEncoder": "",
"callerEncoder": ""
}
}`
var (
debugLevel = "debug"
zLogger *zap.SugaredLogger
mgr *gp.Manager
SendTransaction = mgr.SendTransaction
......@@ -24,14 +47,6 @@ var (
DropNeighbor = mgr.DropNeighbor
)
func init() {
l, err := zap.NewDevelopment()
if err != nil {
log.Fatalf("cannot initialize logger: %v", err)
}
zLogger = l.Sugar()
}
func getTransaction(h []byte) ([]byte, error) {
tx := &pb.TransactionRequest{
Hash: []byte("testTx"),
......@@ -41,7 +56,7 @@ func getTransaction(h []byte) ([]byte, error) {
}
func configureGossip() {
defer func() { _ = zLogger.Sync() }() // ignore the returned error
zLogger = zL.NewLogger(defaultZLC, debugLevel)
trans, err := transport.Listen(local.INSTANCE, zLogger)
if err != nil {
......@@ -56,7 +71,7 @@ func configureEvents() {
selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) {
log.Info("neighbor removed: " + ev.DroppedID.String())
mgr.DropNeighbor(ev.DroppedID)
go mgr.DropNeighbor(ev.DroppedID)
}))
selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) {
......@@ -78,6 +93,7 @@ func configureEvents() {
}))
tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *meta_transaction.MetaTransaction) {
log.Info("Tx solidified")
t := &pb.Transaction{
Body: tx.GetBytes(),
}
......
......@@ -11,8 +11,7 @@ var PLUGIN = node.NewPlugin("Gossip", node.Enabled, configure, run)
var log = logger.NewLogger("Gossip")
var (
debugLevel = "debug"
close = make(chan struct{}, 1)
close = make(chan struct{}, 1)
)
func configure(plugin *node.Plugin) {
......
package tangle
import (
"github.com/iotaledger/goshimmer/packages/model/meta_transaction"
"github.com/iotaledger/goshimmer/packages/model/value_transaction"
"github.com/iotaledger/hive.go/events"
)
......@@ -16,5 +16,5 @@ type pluginEvents struct {
}
func transactionCaller(handler interface{}, params ...interface{}) {
handler.(func(*meta_transaction.MetaTransaction))(params[0].(*meta_transaction.MetaTransaction))
handler.(func(*value_transaction.ValueTransaction))(params[0].(*value_transaction.ValueTransaction))
}
......@@ -3,8 +3,10 @@ package tangle
import (
"runtime"
"github.com/golang/protobuf/proto"
"github.com/iotaledger/goshimmer/packages/errors"
"github.com/iotaledger/goshimmer/packages/gossip"
pb "github.com/iotaledger/goshimmer/packages/gossip/proto"
"github.com/iotaledger/goshimmer/packages/model/approvers"
"github.com/iotaledger/goshimmer/packages/model/meta_transaction"
"github.com/iotaledger/goshimmer/packages/model/transactionmetadata"
......@@ -28,8 +30,10 @@ func configureSolidifier(plugin *node.Plugin) {
}, workerpool.WorkerCount(WORKER_COUNT), workerpool.QueueSize(10000))
gossip.Events.NewTransaction.Attach(events.NewClosure(func(ev *gossip.NewTransactionEvent) {
tx := ev.Body
metaTx := meta_transaction.FromBytes(tx)
//log.Info("New Transaction", ev.Body)
pTx := &pb.Transaction{}
proto.Unmarshal(ev.Body, pTx)
metaTx := meta_transaction.FromBytes(pTx.GetBody())
workerPool.Submit(metaTx)
}))
......
......@@ -6,13 +6,12 @@ import (
"testing"
"github.com/golang/protobuf/proto"
"github.com/iotaledger/hive.go/parameter"
"github.com/iotaledger/goshimmer/packages/gossip"
pb "github.com/iotaledger/goshimmer/packages/gossip/proto"
"github.com/iotaledger/goshimmer/packages/model/value_transaction"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/node"
"github.com/iotaledger/hive.go/parameter"
"github.com/iotaledger/iota.go/trinary"
)
......@@ -48,19 +47,19 @@ func TestSolidifier(t *testing.T) {
wg.Add(4)
tx := &pb.Transaction{Body: transaction1.MetaTransaction.GetBytes()}
b, _ := proto.Marshal(tx)
gossip.Event.NewTransaction.Trigger(b)
gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b})
tx = &pb.Transaction{Body: transaction2.MetaTransaction.GetBytes()}
b, _ = proto.Marshal(tx)
gossip.Event.NewTransaction.Trigger(b)
gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b})
tx = &pb.Transaction{Body: transaction3.MetaTransaction.GetBytes()}
b, _ = proto.Marshal(tx)
gossip.Event.NewTransaction.Trigger(b)
gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b})
tx = &pb.Transaction{Body: transaction4.MetaTransaction.GetBytes()}
b, _ = proto.Marshal(tx)
gossip.Event.NewTransaction.Trigger(b)
gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b})
// wait until all are solid
wg.Wait()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment