implement verifier.

This commit is contained in:
fiatjaf
2023-09-28 14:57:03 -03:00
parent 3e702d758e
commit 7084284622
4 changed files with 61 additions and 17 deletions

22
ots.go
View File

@@ -100,6 +100,17 @@ func (a Instruction) Equal(b Instruction) bool {
type Sequence []Instruction
func (seq Sequence) Compute(initial []byte) []byte {
current := initial
for _, inst := range seq {
if inst.Operation == nil {
break
}
current = inst.Operation.Apply(current, inst.Argument)
}
return current
}
func (ts Timestamp) GetPendingSequences() []Sequence {
bitcoin := ts.GetBitcoinAttestedSequences()
@@ -238,14 +249,3 @@ func (att Attestation) Human() string {
return "unknown/broken"
}
}
func ComputeSequence(initial []byte, seq []Instruction) []byte {
current := initial
for _, inst := range seq {
if inst.Operation == nil {
break
}
current = inst.Operation.Apply(current, inst.Argument)
}
return current
}