Skip to content
Snippets Groups Projects
Unverified Commit 85d860f5 authored by jonastheis's avatar jonastheis
Browse files

Bones

parent 376cba20
No related branches found
No related tags found
No related merge requests found
package tangle package tangle
import ( import (
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/branchmanager"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/payload" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/payload"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/tipmanager" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/tipmanager"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction"
"github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/events"
) )
// ValueObjectFactory acts as a factory to create new value objects.
type ValueObjectFactory struct { type ValueObjectFactory struct {
branchManager *branchmanager.BranchManager tipManager *tipmanager.TipManager
tipManager *tipmanager.TipManager Events *ValueObjectFactoryEvents
Events *ValueObjectFactoryEvents
} }
func NewValueObjectFactory(branchManager *branchmanager.BranchManager, tipManager *tipmanager.TipManager) *ValueObjectFactory { // NewValueObjectFactory creates a new ValueObjectFactory.
func NewValueObjectFactory(tipManager *tipmanager.TipManager) *ValueObjectFactory {
return &ValueObjectFactory{ return &ValueObjectFactory{
branchManager: branchManager, tipManager: tipManager,
tipManager: tipManager,
Events: &ValueObjectFactoryEvents{ Events: &ValueObjectFactoryEvents{
ValueObjectConstructed: events.NewEvent(valueObjectConstructedEvent), ValueObjectConstructed: events.NewEvent(valueObjectConstructedEvent),
}, },
} }
} }
// IssueTransaction creates a new value object including tip selection and returns it.
// It also triggers the ValueObjectConstructed event once it's done.
func (v *ValueObjectFactory) IssueTransaction(tx *transaction.Transaction) *payload.Payload { func (v *ValueObjectFactory) IssueTransaction(tx *transaction.Transaction) *payload.Payload {
// TODO: we need a way to get the currently liked branches. e.g. branchManager.LikedBranches()
parent1, parent2 := v.tipManager.Tips() parent1, parent2 := v.tipManager.Tips()
valueObject := payload.New(parent1, parent2, tx) valueObject := payload.New(parent1, parent2, tx)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment