From d09c3b1e27d438a68596d88aca78c40b8bc169e5 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Sun, 17 May 2020 21:59:20 +0300 Subject: [PATCH] interop/block: update documentation, fix GetTransaction GetTransaction never worked with hash, it works with indexes. --- pkg/interop/block/block.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pkg/interop/block/block.go b/pkg/interop/block/block.go index e7171614a..98cd3a50d 100644 --- a/pkg/interop/block/block.go +++ b/pkg/interop/block/block.go @@ -1,25 +1,30 @@ +/* +Package block provides getters for Neo Block structure. +*/ package block import "github.com/nspcc-dev/neo-go/pkg/interop/transaction" -// Package block provides function signatures that can be used inside -// smart contracts that are written in the neo-go framework. - -// Block stubs a NEO block type. +// Block represents a NEO block, it's an opaque data structure that you can get +// 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 +// blockchain.GetBlock function call. 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 { return 0 } // GetTransactions returns a slice of transactions recorded in the given block. +// It uses `Neo.Block.GetTransactions` syscall internally. func GetTransactions(b Block) []transaction.Transaction { return []transaction.Transaction{} } -// GetTransaction returns a transaction from the given a block hash of the -// transaction. -func GetTransaction(b Block, hash []byte) transaction.Transaction { +// GetTransaction returns transaction from the given block by its index. It +// uses `Neo.Block.GetTransaction` syscall internally. +func GetTransaction(b Block, index int) transaction.Transaction { return transaction.Transaction{} }