-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #628 from iotaledger/split-context-inputs-and-inputs
Split Context Inputs and Inputs
- Loading branch information
Showing
15 changed files
with
350 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,41 @@ | ||
package mempool | ||
|
||
import iotago "github.com/iotaledger/iota.go/v4" | ||
import ( | ||
"github.com/iotaledger/hive.go/lo" | ||
iotago "github.com/iotaledger/iota.go/v4" | ||
) | ||
|
||
// A generic interface over a state (like an output or a commitment). | ||
type State interface { | ||
// The identifier of the state. | ||
StateID() StateID | ||
|
||
Type() iotago.StateType | ||
// The type of state. | ||
Type() StateType | ||
|
||
// Whether the state is read only. | ||
IsReadOnly() bool | ||
} | ||
|
||
// A thin wrapper around a resolved commitment. | ||
type CommitmentInputState struct { | ||
Commitment *iotago.Commitment | ||
} | ||
|
||
func (s CommitmentInputState) StateID() StateID { | ||
return iotago.IdentifierFromData(lo.PanicOnErr(s.Commitment.MustID().Bytes())) | ||
} | ||
|
||
func (s CommitmentInputState) Type() StateType { | ||
return StateTypeCommitment | ||
} | ||
|
||
func (s CommitmentInputState) IsReadOnly() bool { | ||
return true | ||
} | ||
|
||
func CommitmentInputStateFromCommitment(commitment *iotago.Commitment) CommitmentInputState { | ||
return CommitmentInputState{ | ||
Commitment: commitment, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,53 @@ | ||
package mempool | ||
|
||
import iotago "github.com/iotaledger/iota.go/v4" | ||
import ( | ||
"github.com/iotaledger/hive.go/lo" | ||
iotago "github.com/iotaledger/iota.go/v4" | ||
) | ||
|
||
// A reference to a state (like an output or a commitment). | ||
type StateReference interface { | ||
// The identifier of the state to which it resolves. | ||
ReferencedStateID() iotago.Identifier | ||
|
||
// Type returns the type of Input. | ||
Type() iotago.StateType | ||
// The type of state. | ||
Type() StateType | ||
} | ||
|
||
// A thin wrapper around a UTXO input. | ||
type UTXOInputStateRef struct { | ||
Input *iotago.UTXOInput | ||
} | ||
|
||
func (r UTXOInputStateRef) ReferencedStateID() iotago.Identifier { | ||
return iotago.IdentifierFromData(lo.PanicOnErr(r.Input.OutputID().Bytes())) | ||
} | ||
|
||
func (r UTXOInputStateRef) Type() StateType { | ||
return StateTypeUTXOInput | ||
} | ||
|
||
func UTXOInputStateRefFromInput(input *iotago.UTXOInput) UTXOInputStateRef { | ||
return UTXOInputStateRef{ | ||
Input: input, | ||
} | ||
} | ||
|
||
// A thin wrapper around a Commitment input. | ||
type CommitmentInputStateRef struct { | ||
Input *iotago.CommitmentInput | ||
} | ||
|
||
func (r CommitmentInputStateRef) ReferencedStateID() iotago.Identifier { | ||
return iotago.IdentifierFromData(lo.PanicOnErr(r.Input.CommitmentID.Bytes())) | ||
} | ||
|
||
func (r CommitmentInputStateRef) Type() StateType { | ||
return StateTypeCommitment | ||
} | ||
|
||
func CommitmentInputStateRefFromInput(input *iotago.CommitmentInput) CommitmentInputStateRef { | ||
return CommitmentInputStateRef{ | ||
Input: input, | ||
} | ||
} |
Oops, something went wrong.