interop/block: update documentation, fix GetTransaction

GetTransaction never worked with hash, it works with indexes.
This commit is contained in:
Roman Khimov 2020-05-17 21:59:20 +03:00
parent 7abd35b358
commit d09c3b1e27

View file

@ -1,25 +1,30 @@
/*
Package block provides getters for Neo Block structure.
*/
package block package block
import "github.com/nspcc-dev/neo-go/pkg/interop/transaction" import "github.com/nspcc-dev/neo-go/pkg/interop/transaction"
// Package block provides function signatures that can be used inside // Block represents a NEO block, it's an opaque data structure that you can get
// smart contracts that are written in the neo-go framework. // data from only using functions from this package. It's similar in function to
// the Block class in the Neo .net framework. To use it you need to get it via
// Block stubs a NEO block type. // blockchain.GetBlock function call.
type Block struct{} type Block struct{}
// GetTransactionCount returns the number of recorded transactions in the given block. // GetTransactionCount returns the number of recorded transactions in the given
// block. It uses `Neo.Block.GetTransactionCount` syscall internally.
func GetTransactionCount(b Block) int { func GetTransactionCount(b Block) int {
return 0 return 0
} }
// GetTransactions returns a slice of transactions recorded in the given block. // GetTransactions returns a slice of transactions recorded in the given block.
// It uses `Neo.Block.GetTransactions` syscall internally.
func GetTransactions(b Block) []transaction.Transaction { func GetTransactions(b Block) []transaction.Transaction {
return []transaction.Transaction{} return []transaction.Transaction{}
} }
// GetTransaction returns a transaction from the given a block hash of the // GetTransaction returns transaction from the given block by its index. It
// transaction. // uses `Neo.Block.GetTransaction` syscall internally.
func GetTransaction(b Block, hash []byte) transaction.Transaction { func GetTransaction(b Block, index int) transaction.Transaction {
return transaction.Transaction{} return transaction.Transaction{}
} }