diff --git a/multiepoch-getBlock.go b/multiepoch-getBlock.go index 01ba243d..14686c59 100644 --- a/multiepoch-getBlock.go +++ b/multiepoch-getBlock.go @@ -249,6 +249,26 @@ func (multi *MultiEpoch) handleGetBlock(ctx context.Context, conn *requestContex } tim.time("get entries") + if slot == 0 { + // NOTE: we assume this is on mainnet. + blockZeroBlocktime := uint64(1584368940) + zeroBlockHeight := uint64(0) + blockZeroBlockHash := lastEntryHash.String() + var blockResp GetBlockResponse + blockResp.Transactions = make([]GetTransactionResponse, 0) + blockResp.BlockTime = &blockZeroBlocktime + blockResp.Blockhash = lastEntryHash.String() + blockResp.ParentSlot = uint64(0) + blockResp.Rewards = make([]any, 0) + blockResp.BlockHeight = &zeroBlockHeight + blockResp.PreviousBlockhash = &blockZeroBlockHash // NOTE: this is what solana RPC does. Should it be nil instead? Or should it be the genesis hash? + return nil, conn.ReplyRaw( + ctx, + req.ID, + blockResp, + ) + } + var allTransactions []GetTransactionResponse var rewards any hasRewards := !block.Rewards.(cidlink.Link).Cid.Equals(DummyCID) @@ -391,6 +411,7 @@ func (multi *MultiEpoch) handleGetBlock(ctx context.Context, conn *requestContex allTransactions = append(allTransactions, txResp) } } + sort.Slice(allTransactions, func(i, j int) bool { return allTransactions[i].Position < allTransactions[j].Position }) @@ -401,25 +422,6 @@ func (multi *MultiEpoch) handleGetBlock(ctx context.Context, conn *requestContex blockResp.Blockhash = lastEntryHash.String() blockResp.ParentSlot = uint64(block.Meta.Parent_slot) blockResp.Rewards = rewards - if slot == 0 { - // NOTE: we assume this is on mainnet. - blockZeroBlocktime := uint64(1584368940) - zeroBlockHeight := uint64(0) - blockZeroBlockHash := lastEntryHash.String() - var blockResp GetBlockResponse - blockResp.Transactions = make([]GetTransactionResponse, 0) - blockResp.BlockTime = &blockZeroBlocktime - blockResp.Blockhash = lastEntryHash.String() - blockResp.ParentSlot = uint64(0) - blockResp.Rewards = make([]any, 0) - blockResp.BlockHeight = &zeroBlockHeight - blockResp.PreviousBlockhash = &blockZeroBlockHash // NOTE: this is what solana RPC does. Should it be nil instead? Or should it be the genesis hash? - return nil, conn.ReplyRaw( - ctx, - req.ID, - blockResp, - ) - } { blockHeight, ok := block.GetBlockHeight()