Skip to content

Commit

Permalink
include active_schedule in v2 blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
fschoell committed Jul 30, 2024
1 parent 9bbf44c commit 88ba56d
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions codec/consolereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,11 @@ func (ctx *parseCtx) readAcceptedBlock(line string) (*pbcodec.Block, error) {

// Line format:
//
// ACCEPTED_BLOCK_V2 ${block_id} ${block_num} ${lib} ${block_state_hex} ${finality_data_hex}
// ACCEPTED_BLOCK_V2 ${block_id} ${block_num} ${lib} ${blk} ${finality_data_hex} ${proposer_policy} ${finalizer_policy_with_string_key}
func (ctx *parseCtx) readAcceptedBlockV2(line string) (*pbcodec.Block, error) {
chunks := strings.SplitN(line, " ", 6)
if len(chunks) != 6 {
return nil, fmt.Errorf("expected 6 fields, got %d", len(chunks))
chunks := strings.SplitN(line, " ", 8)
if len(chunks) != 8 {
return nil, fmt.Errorf("expected 8 fields, got %d", len(chunks))
}

blockNum, err := strconv.ParseInt(chunks[2], 10, 64)
Expand Down Expand Up @@ -549,6 +549,22 @@ func (ctx *parseCtx) readAcceptedBlockV2(line string) (*pbcodec.Block, error) {
}
block.DposIrreversibleBlocknum = uint32(lib)

proposerPolicyHex, err := hex.DecodeString(chunks[6])
if err != nil {
return nil, fmt.Errorf("unable to decode proposer policy hex: %w", err)
}

type ProposerPolicy struct {
ActiveTime eos.BlockTimestamp `json:"active_time"`
ProducerSchedule *eos.ProducerAuthoritySchedule `json:"proposer_schedule"`
}

proposerPolicy := &ProposerPolicy{}
if err := unmarshalBinary(proposerPolicyHex, proposerPolicy); err != nil {
return nil, fmt.Errorf("unmarshalling binary proposer policy: %w", err)
}
block.ActiveScheduleV2 = eosio.ProducerAuthorityScheduleToDEOS(proposerPolicy.ProducerSchedule)

zlog.Debug("blocking until abi decoder has decoded every transaction pushed to it")
err = ctx.abiDecoder.endBlock(ctx.block)
if err != nil {
Expand Down

0 comments on commit 88ba56d

Please sign in to comment.