diff --git a/go.sum b/go.sum index 1da9fea97ffc0a20bb5d1d0a281501f7e2e57bf5..a2c19ed86cd5a11420bb4b632c35096a60cd532f 100644 --- a/go.sum +++ b/go.sum @@ -215,6 +215,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= +github.com/nikkolasg/hexjson v0.0.0-20181101101858-78e39397e00c h1:5bFTChQxSKNwy8ALwOebjekYExl9HTT9urdawqC95tA= +github.com/nikkolasg/hexjson v0.0.0-20181101101858-78e39397e00c/go.mod h1:7qN3Y0BvzRUf4LofcoJplQL10lsFDb4PYlePTVwrP28= +github.com/nikkolasg/slog v0.0.0-20170921200349-3c8d441d7a1e h1:07zdEcJ4Fble5uWsqKpjW19699kQWRLXP+RZh1a6ZRg= +github.com/nikkolasg/slog v0.0.0-20170921200349-3c8d441d7a1e/go.mod h1:79GLCU4P87rYvYYACbNwVyc1WmRvkwQbYnybpCmRXzg= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= diff --git a/packages/binary/drng/dispatcher.go b/packages/binary/drng/dispatcher.go index 52ce355b76d5583b5139a2145b06a5aa9e8f7df4..15a7826f8530bef43c07ccfb45fddea774e850bb 100644 --- a/packages/binary/drng/dispatcher.go +++ b/packages/binary/drng/dispatcher.go @@ -9,11 +9,11 @@ import ( "github.com/iotaledger/goshimmer/packages/binary/drng/subtypes/collectiveBeacon" "github.com/iotaledger/goshimmer/packages/binary/drng/subtypes/collectiveBeacon/events" cb "github.com/iotaledger/goshimmer/packages/binary/drng/subtypes/collectiveBeacon/payload" - "github.com/iotaledger/goshimmer/packages/binary/signature/ed25119" + "github.com/iotaledger/hive.go/crypto/ed25519" "github.com/iotaledger/hive.go/marshalutil" ) -func (drng *Instance) Dispatch(issuer ed25119.PublicKey, timestamp time.Time, payload *payload.Payload) error { +func (drng *Instance) Dispatch(issuer ed25519.PublicKey, timestamp time.Time, payload *payload.Payload) error { switch payload.SubType() { case header.CollectiveBeaconType(): // parse as CollectiveBeaconType diff --git a/packages/binary/drng/dispatcher_test.go b/packages/binary/drng/dispatcher_test.go index 8c9acaa60791e3c67b9e3d4ba8e223f1f2bacc14..19479799e7a6e1a05db4653c18710813708033c4 100644 --- a/packages/binary/drng/dispatcher_test.go +++ b/packages/binary/drng/dispatcher_test.go @@ -11,7 +11,7 @@ import ( "github.com/iotaledger/goshimmer/packages/binary/drng/subtypes/collectiveBeacon" "github.com/iotaledger/goshimmer/packages/binary/drng/subtypes/collectiveBeacon/events" cbPayload "github.com/iotaledger/goshimmer/packages/binary/drng/subtypes/collectiveBeacon/payload" - "github.com/iotaledger/goshimmer/packages/binary/signature/ed25119" + "github.com/iotaledger/hive.go/crypto/ed25519" "github.com/iotaledger/hive.go/marshalutil" "github.com/stretchr/testify/require" ) @@ -21,7 +21,7 @@ var ( prevSignatureTest []byte signatureTest []byte dpkTest []byte - issuerPK ed25119.PublicKey + issuerPK ed25519.PublicKey committeeTest *state.Committee timestampTest time.Time randomnessTest *state.Randomness @@ -40,13 +40,13 @@ func init() { Timestamp: timestampTest, } - kp := ed25119.GenerateKeyPair() + kp := ed25519.GenerateKeyPair() issuerPK = kp.PublicKey committeeTest = &state.Committee{ InstanceID: 1, Threshold: 3, - Identities: []ed25119.PublicKey{issuerPK}, + Identities: []ed25519.PublicKey{issuerPK}, DistributedPK: dpkTest, } } diff --git a/packages/binary/drng/payload/payload.go b/packages/binary/drng/payload/payload.go index 0c6117c50f8f799cee91032750a28a42c2325df9..b61f0f23682456618b35dd8fc8319c2269814a3a 100644 --- a/packages/binary/drng/payload/payload.go +++ b/packages/binary/drng/payload/payload.go @@ -4,7 +4,7 @@ import ( "sync" "github.com/iotaledger/goshimmer/packages/binary/drng/payload/header" - "github.com/iotaledger/goshimmer/packages/binary/tangle/model/message/payload" + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/payload" "github.com/iotaledger/hive.go/marshalutil" "github.com/iotaledger/hive.go/stringify" ) diff --git a/packages/binary/drng/state/state.go b/packages/binary/drng/state/state.go index f29f2253f764e2420a731addcfe28a4a8e4173c0..595fd91d1fd8390f619fb04c9d22002d08c57d95 100644 --- a/packages/binary/drng/state/state.go +++ b/packages/binary/drng/state/state.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "github.com/iotaledger/goshimmer/packages/binary/signature/ed25119" + "github.com/iotaledger/hive.go/crypto/ed25519" ) type Randomness struct { @@ -22,7 +22,7 @@ func (r Randomness) Float64() float64 { type Committee struct { InstanceID uint32 Threshold uint8 - Identities []ed25119.PublicKey + Identities []ed25519.PublicKey DistributedPK []byte } type State struct { diff --git a/packages/binary/drng/state/state_test.go b/packages/binary/drng/state/state_test.go index ac8c881bba65d4b3c4178509ec57d9ec68d7a13c..64a7a8cd14de97c078b1471caebe3617776d8389 100644 --- a/packages/binary/drng/state/state_test.go +++ b/packages/binary/drng/state/state_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/iotaledger/goshimmer/packages/binary/signature/ed25119" + "github.com/iotaledger/hive.go/crypto/ed25519" "github.com/stretchr/testify/require" ) @@ -19,7 +19,7 @@ func dummyCommittee() *Committee { return &Committee{ InstanceID: 0, Threshold: 0, - Identities: []ed25119.PublicKey{}, + Identities: []ed25519.PublicKey{}, DistributedPK: []byte{}, } } @@ -31,7 +31,7 @@ func TestState(t *testing.T) { require.Equal(t, *dummyCommittee(), stateTest.Committee()) // committee setters - getters - newCommittee := &Committee{1, 1, []ed25119.PublicKey{}, []byte{11}} + newCommittee := &Committee{1, 1, []ed25519.PublicKey{}, []byte{11}} stateTest.SetCommittee(newCommittee) require.Equal(t, *newCommittee, stateTest.Committee()) diff --git a/packages/binary/drng/subtypes/collectiveBeacon/collective_beacon.go b/packages/binary/drng/subtypes/collectiveBeacon/collective_beacon.go index 3e5d8fa0a3867116cd634a96ea4bfd41a5f2d0cc..d6734b7632c1bf4eda9d55841f9cb30b24d509d2 100644 --- a/packages/binary/drng/subtypes/collectiveBeacon/collective_beacon.go +++ b/packages/binary/drng/subtypes/collectiveBeacon/collective_beacon.go @@ -9,7 +9,7 @@ import ( "github.com/drand/drand/key" "github.com/iotaledger/goshimmer/packages/binary/drng/state" "github.com/iotaledger/goshimmer/packages/binary/drng/subtypes/collectiveBeacon/events" - "github.com/iotaledger/goshimmer/packages/binary/signature/ed25119" + "github.com/iotaledger/hive.go/crypto/ed25519" ) // ProcessTransaction performs the following tasks: @@ -68,7 +68,7 @@ func VerifyCollectiveBeacon(state *state.State, data *events.CollectiveBeaconEve } // verifyIssuer checks the given issuer is a member of the committee -func verifyIssuer(state *state.State, issuer ed25119.PublicKey) error { +func verifyIssuer(state *state.State, issuer ed25519.PublicKey) error { for _, member := range state.Committee().Identities { if member == issuer { return nil diff --git a/packages/binary/drng/subtypes/collectiveBeacon/collective_beacon_test.go b/packages/binary/drng/subtypes/collectiveBeacon/collective_beacon_test.go index 749a161b89f30522aac309916c38729f9aca1393..bb46da739728b1e26de1a22845b130be3675e7ca 100644 --- a/packages/binary/drng/subtypes/collectiveBeacon/collective_beacon_test.go +++ b/packages/binary/drng/subtypes/collectiveBeacon/collective_beacon_test.go @@ -6,7 +6,7 @@ import ( "github.com/iotaledger/goshimmer/packages/binary/drng/state" "github.com/iotaledger/goshimmer/packages/binary/drng/subtypes/collectiveBeacon/events" - "github.com/iotaledger/goshimmer/packages/binary/signature/ed25119" + "github.com/iotaledger/hive.go/crypto/ed25519" "github.com/stretchr/testify/require" ) @@ -15,7 +15,7 @@ var ( prevSignatureTest []byte signatureTest []byte dpkTest []byte - issuerPK ed25119.PublicKey + issuerPK ed25519.PublicKey stateTest *state.State ) @@ -23,7 +23,7 @@ func init() { prevSignatureTest, _ = hex.DecodeString("ae9ba6d1445bffea8e66cb7d28fe5924e0a8d31b11b62a8710204e56e1ba84bc3694a3033e5793fcee6e75e956e5da3016cd0e22aa46fa419cd06343a7ff9d1e9c5c08f660f0bdec099e97ef99f470bb8c607ce9667a165e9caa474710f62ffd") signatureTest, _ = hex.DecodeString("8dee56fae60dcad960f7176d0813d5415b930cf6e20c299ec2c2dfc5f2ad4903916fd462ba1abf5c32a5bfd94dcc8eba062d011a548d99df7fa1e3bbbc9a0455663d60f6ccc736c1d5b6de727dbe4427e21fb660925518be386265913f447c94") dpkTest, _ = hex.DecodeString("a02fcd15edd52c8e134027491a43b597505b466d1679e88f70f927e57c45a93ae0765ff02fc2d015e3a02fd8748e2103") - kp := ed25119.GenerateKeyPair() + kp := ed25519.GenerateKeyPair() issuerPK = kp.PublicKey eventTest = &events.CollectiveBeaconEvent{ @@ -39,7 +39,7 @@ func init() { &state.Committee{ InstanceID: 1, Threshold: 3, - Identities: []ed25119.PublicKey{issuerPK}, + Identities: []ed25519.PublicKey{issuerPK}, DistributedPK: dpkTest, })) } diff --git a/packages/binary/drng/subtypes/collectiveBeacon/events/events.go b/packages/binary/drng/subtypes/collectiveBeacon/events/events.go index bb05a6d136169df5f456c53ef8a0fd3c88b06a9f..c14e637b9b6cb19c6eb0d651aff0f7fe0dadbbd6 100644 --- a/packages/binary/drng/subtypes/collectiveBeacon/events/events.go +++ b/packages/binary/drng/subtypes/collectiveBeacon/events/events.go @@ -3,7 +3,7 @@ package events import ( "time" - "github.com/iotaledger/goshimmer/packages/binary/signature/ed25119" + "github.com/iotaledger/hive.go/crypto/ed25519" "github.com/iotaledger/hive.go/events" ) @@ -14,7 +14,7 @@ func NewCollectiveBeaconEvent() *events.Event { } type CollectiveBeaconEvent struct { - IssuerPublicKey ed25119.PublicKey // public key of the issuer + IssuerPublicKey ed25519.PublicKey // public key of the issuer Timestamp time.Time // timestamp when the beacon was issued InstanceID uint32 // instanceID of the beacon Round uint64 // round of the current beacon diff --git a/packages/binary/drng/subtypes/collectiveBeacon/payload/payload.go b/packages/binary/drng/subtypes/collectiveBeacon/payload/payload.go index 02463d9b2cf92f91e60b65dedb7c77e72f85456e..97e1b45539415762cc37f014f42cc6910906ccfe 100644 --- a/packages/binary/drng/subtypes/collectiveBeacon/payload/payload.go +++ b/packages/binary/drng/subtypes/collectiveBeacon/payload/payload.go @@ -7,7 +7,7 @@ import ( drngPayload "github.com/iotaledger/goshimmer/packages/binary/drng/payload" "github.com/iotaledger/goshimmer/packages/binary/drng/payload/header" - "github.com/iotaledger/goshimmer/packages/binary/tangle/model/message/payload" + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/payload" "github.com/iotaledger/hive.go/marshalutil" ) diff --git a/plugins/drng/plugin.go b/plugins/drng/plugin.go index 3e732c1334bbe7f49a701eb0a9b4982d33f70ebf..30cf1239fd7bc485dbbe92f094a69087e9233db4 100644 --- a/plugins/drng/plugin.go +++ b/plugins/drng/plugin.go @@ -3,9 +3,9 @@ package drng import ( "github.com/iotaledger/goshimmer/packages/binary/drng" "github.com/iotaledger/goshimmer/packages/binary/drng/payload" - "github.com/iotaledger/goshimmer/packages/binary/tangle/model/message" - "github.com/iotaledger/goshimmer/packages/binary/tangle/model/transactionmetadata" - "github.com/iotaledger/goshimmer/plugins/tangle" + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/message" + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle" + "github.com/iotaledger/goshimmer/plugins/messagelayer" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/marshalutil" "github.com/iotaledger/hive.go/node" @@ -25,17 +25,17 @@ func configure(*node.Plugin) { func run(*node.Plugin) {} func configureEvents() { - tangle.Instance.Events.TransactionSolid.Attach(events.NewClosure(func(cachedTransaction *message.CachedTransaction, cachedTransactionMetadata *transactionmetadata.CachedTransactionMetadata) { - cachedTransactionMetadata.Release() + messagelayer.Tangle.Events.TransactionSolid.Attach(events.NewClosure(func(cachedMessage *message.CachedMessage, cachedMessageMetadata *tangle.CachedMessageMetadata) { + cachedMessageMetadata.Release() - cachedTransaction.Consume(func(transaction *message.Transaction) { - marshalUtil := marshalutil.New(transaction.GetPayload().Bytes()) + cachedMessage.Consume(func(msg *message.Message) { + marshalUtil := marshalutil.New(msg.GetPayload().Bytes()) parsedPayload, err := payload.Parse(marshalUtil) if err != nil { //TODO: handle error return } - if err := Instance.Dispatch(transaction.IssuerPublicKey(), transaction.IssuingTime(), parsedPayload); err != nil { + if err := Instance.Dispatch(msg.IssuerPublicKey(), msg.IssuingTime(), parsedPayload); err != nil { //TODO: handle error } })