Skip to content
Snippets Groups Projects
Commit 821e9fb6 authored by capossele's avatar capossele
Browse files

:construction: WIP

parent 23b1d72a
No related branches found
No related tags found
No related merge requests found
......@@ -3,11 +3,11 @@ package gossip
import (
"net"
"github.com/capossele/gossip/neighbor"
pb "github.com/capossele/gossip/proto"
"github.com/capossele/gossip/transport"
"github.com/golang/protobuf/proto"
"github.com/iotaledger/autopeering-sim/peer"
"github.com/iotaledger/goshimmer/packages/gossip/neighbor"
pb "github.com/iotaledger/goshimmer/packages/gossip/proto"
"github.com/iotaledger/goshimmer/packages/gossip/transport"
"github.com/iotaledger/hive.go/events"
"github.com/pkg/errors"
"go.uber.org/zap"
......
......@@ -6,11 +6,11 @@ import (
"testing"
"time"
pb "github.com/capossele/gossip/proto"
"github.com/capossele/gossip/transport"
"github.com/golang/protobuf/proto"
"github.com/iotaledger/autopeering-sim/peer"
"github.com/iotaledger/autopeering-sim/peer/service"
pb "github.com/iotaledger/goshimmer/packages/gossip/proto"
"github.com/iotaledger/goshimmer/packages/gossip/transport"
"github.com/iotaledger/hive.go/events"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
......
......@@ -3,8 +3,8 @@ package neighbor
import (
"sync"
"github.com/capossele/gossip/transport"
"github.com/iotaledger/autopeering-sim/peer"
"github.com/iotaledger/goshimmer/packages/gossip/transport"
)
// Neighbor defines a neighbor
......
syntax = "proto3";
option go_package = "github.com/capossele/gossip/proto";
option go_package = "github.com/iotaledger/goshimmer/packages/gossip/proto";
package proto;
......
......@@ -4,9 +4,9 @@ import (
"bytes"
"time"
pb "github.com/capossele/gossip/transport/proto"
"github.com/golang/protobuf/proto"
"github.com/iotaledger/autopeering-sim/server"
pb "github.com/iotaledger/goshimmer/packages/gossip/transport/proto"
)
const (
......
syntax = "proto3";
option go_package = "github.com/capossele/gossip/transport/proto";
option go_package = "github.com/iotaledger/goshimmer/packages/gossip/transport/proto";
package proto;
......
......@@ -4,8 +4,9 @@ import (
"sync"
"time"
"github.com/iotaledger/goshimmer/plugins/gossip"
"github.com/golang/protobuf/proto"
"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/tipselection"
"github.com/iotaledger/hive.go/daemon"
......@@ -50,7 +51,9 @@ func Start(tps uint) {
tx.SetBranchTransactionHash(tipselection.GetRandomTip())
tx.SetTrunkTransactionHash(tipselection.GetRandomTip())
gossip.Events.ReceiveTransaction.Trigger(tx.MetaTransaction)
mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()}
b, _ := proto.Marshal(mtx)
gossip.Event.NewTransaction.Trigger(b)
if sentCounter >= tps {
duration := time.Since(start)
......
package autopeering
import (
"net"
"github.com/iotaledger/autopeering-sim/discover"
"github.com/iotaledger/autopeering-sim/peer/service"
"github.com/iotaledger/autopeering-sim/selection"
"github.com/iotaledger/goshimmer/packages/gossip"
"github.com/iotaledger/goshimmer/packages/gossip/neighbor"
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger"
......@@ -29,37 +26,12 @@ func run(plugin *node.Plugin) {
}
func configureLogging(plugin *node.Plugin) {
gossip.Event.DropNeighbor.Attach(events.NewClosure(func(peer *gossip.Neighbor) {
gossip.Event.DropNeighbor.Attach(events.NewClosure(func(peer *neighbor.Neighbor) {
if Selection != nil {
Selection.DropPeer(peer.Peer)
}
}))
selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) {
log.Info("neighbor removed: " + ev.DroppedID.String())
gossip.RemoveNeighbor(ev.DroppedID.String())
}))
selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) {
log.Info("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String())
log.Info("services: " + ev.Peer.Services().CreateRecord().String())
gossipService := ev.Peer.Services().Get(service.GossipKey)
if gossipService != nil {
address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String())
gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port))
}
}))
selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) {
log.Info("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String())
log.Info("services: " + ev.Peer.Services().CreateRecord().String())
gossipService := ev.Peer.Services().Get(service.GossipKey)
if gossipService != nil {
address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String())
gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port))
}
}))
discover.Events.PeerDiscovered.Attach(events.NewClosure(func(ev *discover.DiscoveredEvent) {
log.Info("new peer discovered: " + ev.Peer.Address() + " / " + ev.Peer.ID().String())
}))
......
package gossip
import (
"github.com/iotaledger/goshimmer/packages/gossip/transport"
"github.com/iotaledger/goshimmer/packages/model/meta_transaction"
gp "github.com/iotaledger/goshimmer/packages/gossip"
pb "github.com/iotaledger/goshimmer/packages/gossip/proto"
"github.com/iotaledger/goshimmer/plugins/autopeering/local"
"github.com/iotaledger/autopeering-sim/peer/service"
"github.com/iotaledger/autopeering-sim/selection"
"github.com/iotaledger/goshimmer/plugins/tangle"
"go.uber.org/zap"
......@@ -58,13 +60,21 @@ func configureEvents() {
}))
selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) {
log.Debug("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String())
AddInbound(ev.Peer)
gossipService := ev.Peer.Services().Get(service.GossipKey)
if gossipService != nil {
log.Debug("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String())
//address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String())
AddInbound(ev.Peer)
}
}))
selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) {
log.Debug("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String())
AddOutbound(ev.Peer)
gossipService := ev.Peer.Services().Get(service.GossipKey)
if gossipService != nil {
log.Debug("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String())
//address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String())
AddOutbound(ev.Peer)
}
}))
// mgr.Events.NewTransaction.Attach(events.NewClosure(func(ev *gp.NewTransactionEvent) {
......
......@@ -3,9 +3,8 @@ package metrics
import (
"time"
"github.com/iotaledger/goshimmer/packages/model/meta_transaction"
"github.com/iotaledger/goshimmer/packages/gossip"
"github.com/iotaledger/goshimmer/packages/timeutil"
"github.com/iotaledger/goshimmer/plugins/gossip"
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/node"
......@@ -15,7 +14,7 @@ var PLUGIN = node.NewPlugin("Metrics", node.Enabled, configure, run)
func configure(plugin *node.Plugin) {
// increase received TPS counter whenever we receive a new transaction
gossip.Events.ReceiveTransaction.Attach(events.NewClosure(func(_ *meta_transaction.MetaTransaction) { increaseReceivedTPSCounter() }))
gossip.Event.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { increaseReceivedTPSCounter() }))
}
func run(plugin *node.Plugin) {
......
......@@ -5,9 +5,8 @@ import (
"sync/atomic"
"time"
"github.com/iotaledger/goshimmer/packages/model/meta_transaction"
"github.com/iotaledger/goshimmer/packages/gossip"
"github.com/iotaledger/goshimmer/packages/model/value_transaction"
"github.com/iotaledger/goshimmer/plugins/gossip"
"github.com/iotaledger/goshimmer/plugins/statusscreen"
"github.com/iotaledger/goshimmer/plugins/tangle"
"github.com/iotaledger/hive.go/daemon"
......@@ -24,7 +23,7 @@ var receivedTps uint64
var solidTps uint64
var PLUGIN = node.NewPlugin("Statusscreen TPS", node.Enabled, func(plugin *node.Plugin) {
gossip.Events.ReceiveTransaction.Attach(events.NewClosure(func(_ *meta_transaction.MetaTransaction) {
gossip.Event.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) {
atomic.AddUint64(&receivedTpsCounter, 1)
}))
......
......@@ -4,12 +4,12 @@ import (
"runtime"
"github.com/iotaledger/goshimmer/packages/errors"
"github.com/iotaledger/goshimmer/packages/gossip"
"github.com/iotaledger/goshimmer/packages/model/approvers"
"github.com/iotaledger/goshimmer/packages/model/meta_transaction"
"github.com/iotaledger/goshimmer/packages/model/transactionmetadata"
"github.com/iotaledger/goshimmer/packages/model/value_transaction"
"github.com/iotaledger/goshimmer/packages/workerpool"
"github.com/iotaledger/goshimmer/plugins/gossip"
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/node"
......@@ -27,8 +27,10 @@ func configureSolidifier(plugin *node.Plugin) {
task.Return(nil)
}, workerpool.WorkerCount(WORKER_COUNT), workerpool.QueueSize(10000))
gossip.Events.ReceiveTransaction.Attach(events.NewClosure(func(rawTransaction *meta_transaction.MetaTransaction) {
workerPool.Submit(rawTransaction)
gossip.Event.NewTransaction.Attach(events.NewClosure(func(ev *gossip.NewTransactionEvent) {
tx := ev.Body
metaTx := meta_transaction.FromBytes(tx)
workerPool.Submit(metaTx)
}))
daemon.Events.Shutdown.Attach(events.NewClosure(func() {
......
package tangle
import (
"github.com/iotaledger/hive.go/parameter"
"os"
"sync"
"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/goshimmer/plugins/gossip"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/node"
"github.com/iotaledger/iota.go/trinary"
)
func TestMain(m *testing.M) {
parameter.FetchConfig()
parameter.FetchConfig(false)
os.Exit(m.Run())
}
......@@ -43,10 +46,21 @@ func TestSolidifier(t *testing.T) {
// issue transactions
wg.Add(4)
gossip.Events.ReceiveTransaction.Trigger(transaction1.MetaTransaction)
gossip.Events.ReceiveTransaction.Trigger(transaction2.MetaTransaction)
gossip.Events.ReceiveTransaction.Trigger(transaction3.MetaTransaction)
gossip.Events.ReceiveTransaction.Trigger(transaction4.MetaTransaction)
tx := &pb.Transaction{Body: transaction1.MetaTransaction.GetBytes()}
b, _ := proto.Marshal(tx)
gossip.Event.NewTransaction.Trigger(b)
tx = &pb.Transaction{Body: transaction2.MetaTransaction.GetBytes()}
b, _ = proto.Marshal(tx)
gossip.Event.NewTransaction.Trigger(b)
tx = &pb.Transaction{Body: transaction3.MetaTransaction.GetBytes()}
b, _ = proto.Marshal(tx)
gossip.Event.NewTransaction.Trigger(b)
tx = &pb.Transaction{Body: transaction4.MetaTransaction.GetBytes()}
b, _ = proto.Marshal(tx)
gossip.Event.NewTransaction.Trigger(b)
// wait until all are solid
wg.Wait()
......
......@@ -6,9 +6,8 @@ import (
"sync/atomic"
"time"
"github.com/iotaledger/goshimmer/packages/model/meta_transaction"
"github.com/iotaledger/goshimmer/packages/gossip"
"github.com/iotaledger/goshimmer/packages/model/value_transaction"
"github.com/iotaledger/goshimmer/plugins/gossip"
"github.com/iotaledger/goshimmer/plugins/tangle"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/daemon"
......@@ -35,7 +34,7 @@ func configure(plugin *node.Plugin) {
return c.JSON(http.StatusOK, tpsQueue)
})
gossip.Events.ReceiveTransaction.Attach(events.NewClosure(func(_ *meta_transaction.MetaTransaction) {
gossip.Event.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) {
atomic.AddUint64(&receivedTpsCounter, 1)
}))
tangle.Events.TransactionSolid.Attach(events.NewClosure(func(_ *value_transaction.ValueTransaction) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment