Skip to content
Snippets Groups Projects
Unverified Commit 4ae49c1d authored by capossele's avatar capossele
Browse files

:construction: WIP

parent 58bdc6fb
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......@@ -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)
......
......@@ -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
......
......@@ -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)
}
}
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