Add transactionCount to block

This commit is contained in:
Nick Johnson 2018-10-14 15:33:39 +01:00
parent c46a697c26
commit ed02332148

View file

@ -606,6 +606,14 @@ func (b *Block) Coinbase(ctx context.Context, args BlockNumberArgs) (*Account, e
}, nil }, nil
} }
func (b *Block) TransactionCount(ctx context.Context) (int32, error) {
block, err := b.resolve(ctx)
if err != nil {
return 0, err
}
return int32(len(block.Transactions())), nil
}
func (b *Block) Transactions(ctx context.Context) ([]*Transaction, error) { func (b *Block) Transactions(ctx context.Context) ([]*Transaction, error) {
block, err := b.resolve(ctx) block, err := b.resolve(ctx)
if err != nil { if err != nil {
@ -768,6 +776,7 @@ func NewHandler(n *node.Node) (http.Handler, error) {
extra: HexBytes! extra: HexBytes!
totalDifficulty: BigNum! totalDifficulty: BigNum!
coinbase(block: Int): Account! coinbase(block: Int): Account!
transactionCount: Int!
transactions: [Transaction]! transactions: [Transaction]!
} }