diff --git a/client/message.go b/client/message.go index 267dbb343a8bea0f7c9601a3e2823babc82b697d..68485359b24b697e06f7d6ed937a16bd99105254 100644 --- a/client/message.go +++ b/client/message.go @@ -7,7 +7,8 @@ import ( ) const ( - routeFindByID = "message/findById" + routeFindByID = "message/findById" + routeSendPayload = "message/sendPayload" ) // FindMessageByID finds messages by the given base58 encoded IDs. The messages are returned in the same order as @@ -26,3 +27,14 @@ func (api *GoShimmerAPI) FindMessageByID(base58EncodedIDs []string) (*webapi_mes return res, nil } + +func (api *GoShimmerAPI) SendPayload(payload []byte) (string, error) { + + res := &webapi_message.MessageResponse{} + if err := api.do(http.MethodPost, routeSendPayload, + &webapi_message.MessageRequest{Payload: payload}, res); err != nil { + return "", err + } + + return res.ID, nil +} diff --git a/plugins/analysis/dashboard/fpc_storage.go b/plugins/analysis/dashboard/fpc_storage.go index e32becb1f1c689ef9b65f825c3cf64a39e3b5e50..72f9d3c9aab113901865b9468899e0b5f2c148ba 100644 --- a/plugins/analysis/dashboard/fpc_storage.go +++ b/plugins/analysis/dashboard/fpc_storage.go @@ -23,19 +23,16 @@ type FPCRecord struct { var ( db *mongo.Database ctxDisconnectDB context.Context - // cancelDB context.CancelFunc - clientDB *mongo.Client - dbOnce sync.Once + clientDB *mongo.Client + dbOnce sync.Once ) func shutdownMongoDB() { - //cancelDB() clientDB.Disconnect(ctxDisconnectDB) } func mongoDB() *mongo.Database { dbOnce.Do(func() { - log.Info("ONCEEEEEEE") username := config.Node.GetString(CfgMongoDBUsername) password := config.Node.GetString(CfgMongoDBPassword) bindAddr := config.Node.GetString(CfgMongoDBBindAddress) diff --git a/plugins/webapi/message/plugin.go b/plugins/webapi/message/plugin.go index 1ebbf8b7fb31be52efa6c59984a81e56c8218ca2..bdba4f3740deaf17d000969693b531de05c9cd5e 100644 --- a/plugins/webapi/message/plugin.go +++ b/plugins/webapi/message/plugin.go @@ -23,6 +23,7 @@ var ( func configure(plugin *node.Plugin) { log = logger.NewLogger(PluginName) webapi.Server.POST("message/findById", findMessageByID) + webapi.Server.POST("message/sendPayload", sendPayload) } // findMessageByID returns the array of messages for the diff --git a/tools/double-spend/double-spend.go b/tools/double-spend/double-spend.go index 5d68760990dd12f597d119a14200a7be645bf813..cab37ea885be28bcfb8a47cce91812cf0b73b44d 100644 --- a/tools/double-spend/double-spend.go +++ b/tools/double-spend/double-spend.go @@ -9,6 +9,7 @@ import ( "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address/signaturescheme" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance" + valuepayload "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/payload" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/wallet" "github.com/mr-tron/base58" @@ -32,13 +33,13 @@ func main() { // issue transactions which spend the same genesis output in all partitions conflictingTxs := make([]*transaction.Transaction, 2) conflictingTxIDs := make([]string, 2) - receiverWallets := make([]*wallet.Wallet, 2) + receiverSeeds := make([]*wallet.Seed, 2) for i := range conflictingTxs { // create a new receiver wallet for the given conflict - receiverWallet := wallet.New() - destAddr := receiverWallet.Seed().Address(0) - receiverWallets[i] = receiverWallet + receiverSeeds[i] = wallet.NewSeed() + destAddr := receiverSeeds[i].Address(0) + tx := transaction.New( transaction.NewInputs(genesisOutputID), transaction.NewOutputs(map[address.Address][]*balance.Balance{ @@ -49,12 +50,15 @@ func main() { tx = tx.Sign(signaturescheme.ED25519(*genesisWallet.Seed().KeyPair(0))) conflictingTxs[i] = tx - // issue the transaction - txID, err := client.SendTransaction(tx.Bytes()) + valueObject := valuepayload.New(valuepayload.GenesisID, valuepayload.GenesisID, tx) + + // issue the value object + txID, err := client.SendPayload(valueObject.Bytes()) if err != nil { fmt.Println(err) } conflictingTxIDs[i] = txID fmt.Printf("issued conflict transaction %s\n", txID) + //time.Sleep(7 * time.Second) } }