Skip to content

Commit 6aa20fc

Browse files
authored
vms/platformvm: Initialize txs in Transactions field for BanffProposalBlock (#2419)
1 parent c11accd commit 6aa20fc

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

vms/platformvm/block/proposal_block.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ type BanffProposalBlock struct {
2828
ApricotProposalBlock `serialize:"true"`
2929
}
3030

31+
func (b *BanffProposalBlock) initialize(bytes []byte) error {
32+
if err := b.ApricotProposalBlock.initialize(bytes); err != nil {
33+
return err
34+
}
35+
for _, tx := range b.Transactions {
36+
if err := tx.Initialize(txs.Codec); err != nil {
37+
return fmt.Errorf("failed to initialize tx: %w", err)
38+
}
39+
}
40+
return nil
41+
}
42+
3143
func (b *BanffProposalBlock) InitCtx(ctx *snow.Context) {
3244
for _, tx := range b.Transactions {
3345
tx.Unsigned.InitCtx(ctx)
@@ -39,6 +51,14 @@ func (b *BanffProposalBlock) Timestamp() time.Time {
3951
return time.Unix(int64(b.Time), 0)
4052
}
4153

54+
func (b *BanffProposalBlock) Txs() []*txs.Tx {
55+
l := len(b.Transactions)
56+
txs := make([]*txs.Tx, l+1)
57+
copy(txs, b.Transactions)
58+
txs[l] = b.Tx
59+
return txs
60+
}
61+
4262
func (b *BanffProposalBlock) Visit(v Visitor) error {
4363
return v.BanffProposalBlock(b)
4464
}

vms/platformvm/block/standard_block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (b *ApricotStandardBlock) initialize(bytes []byte) error {
5858
b.CommonBlock.initialize(bytes)
5959
for _, tx := range b.Transactions {
6060
if err := tx.Initialize(txs.Codec); err != nil {
61-
return fmt.Errorf("failed to sign block: %w", err)
61+
return fmt.Errorf("failed to initialize tx: %w", err)
6262
}
6363
}
6464
return nil

0 commit comments

Comments
 (0)