Skip to content

Commit

Permalink
vms/platformvm: Initialize txs in Transactions field for `BanffPr…
Browse files Browse the repository at this point in the history
…oposalBlock` (#2419)
  • Loading branch information
dhrubabasu authored Dec 4, 2023
1 parent c11accd commit 6aa20fc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions vms/platformvm/block/proposal_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ type BanffProposalBlock struct {
ApricotProposalBlock `serialize:"true"`
}

func (b *BanffProposalBlock) initialize(bytes []byte) error {
if err := b.ApricotProposalBlock.initialize(bytes); err != nil {
return err
}
for _, tx := range b.Transactions {
if err := tx.Initialize(txs.Codec); err != nil {
return fmt.Errorf("failed to initialize tx: %w", err)
}
}
return nil
}

func (b *BanffProposalBlock) InitCtx(ctx *snow.Context) {
for _, tx := range b.Transactions {
tx.Unsigned.InitCtx(ctx)
Expand All @@ -39,6 +51,14 @@ func (b *BanffProposalBlock) Timestamp() time.Time {
return time.Unix(int64(b.Time), 0)
}

func (b *BanffProposalBlock) Txs() []*txs.Tx {
l := len(b.Transactions)
txs := make([]*txs.Tx, l+1)
copy(txs, b.Transactions)
txs[l] = b.Tx
return txs
}

func (b *BanffProposalBlock) Visit(v Visitor) error {
return v.BanffProposalBlock(b)
}
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/block/standard_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (b *ApricotStandardBlock) initialize(bytes []byte) error {
b.CommonBlock.initialize(bytes)
for _, tx := range b.Transactions {
if err := tx.Initialize(txs.Codec); err != nil {
return fmt.Errorf("failed to sign block: %w", err)
return fmt.Errorf("failed to initialize tx: %w", err)
}
}
return nil
Expand Down

0 comments on commit 6aa20fc

Please sign in to comment.