diff --git a/frontend/service.go b/frontend/service.go index 9195116..f446026 100644 --- a/frontend/service.go +++ b/frontend/service.go @@ -120,7 +120,7 @@ func (s *SqlStreamer) GetTransaction(ctx context.Context, txf *rpc.TxFilter) (*r if txf.Hash != nil { leHashString := hex.EncodeToString(txf.Hash) - txBytes, err = storage.GetFullTxByHash(ctx, s.db, leHashString) + txBytes, err = storage.GetTxByHash(ctx, s.db, leHashString) if err != nil { return nil, err } @@ -130,7 +130,7 @@ func (s *SqlStreamer) GetTransaction(ctx context.Context, txf *rpc.TxFilter) (*r if txf.Block.Hash != nil { leHashString := hex.EncodeToString(txf.Hash) - txBytes, err = storage.GetFullTxByHashAndIndex(ctx, s.db, leHashString, int(txf.Index)) + txBytes, err = storage.GetTxByHashAndIndex(ctx, s.db, leHashString, int(txf.Index)) if err != nil { return nil, err } @@ -138,7 +138,7 @@ func (s *SqlStreamer) GetTransaction(ctx context.Context, txf *rpc.TxFilter) (*r } // A totally unset protobuf will attempt to fetch the genesis coinbase tx. - txBytes, err = storage.GetFullTxByHeightAndIndex(ctx, s.db, int(txf.Block.Height), int(txf.Index)) + txBytes, err = storage.GetTxByHeightAndIndex(ctx, s.db, int(txf.Block.Height), int(txf.Index)) if err != nil { return nil, err } diff --git a/storage/sqlite3.go b/storage/sqlite3.go index 70bbbc2..831677f 100644 --- a/storage/sqlite3.go +++ b/storage/sqlite3.go @@ -163,7 +163,7 @@ func SetCurrentHeight(conn *sql.DB, height int) error { return nil } -func StoreFullTx(db *sql.DB, blockHeight int, blockHash string, txIndex int, txHash string, txBytes []byte) error { +func StoreTransaction(db *sql.DB, blockHeight int, blockHash string, txIndex int, txHash string, txBytes []byte) error { insertTx := "INSERT INTO transactions (block_height, block_hash, tx_index, tx_hash, tx_bytes) VALUES (?,?,?,?,?)" _, err := db.Exec(insertTx, blockHeight, blockHash, txIndex, txHash, txBytes) if err != nil { @@ -172,8 +172,8 @@ func StoreFullTx(db *sql.DB, blockHeight int, blockHash string, txIndex int, txH return nil } -// GetFulTxByHash retrieves a full transaction by its little-endian hash. -func GetFullTxByHash(ctx context.Context, db *sql.DB, txHash string) ([]byte, error) { +// GetTxByHash retrieves a full transaction by its little-endian hash. +func GetTxByHash(ctx context.Context, db *sql.DB, txHash string) ([]byte, error) { var txBytes []byte // avoid a copy with *RawBytes query := "SELECT bytes from transactions WHERE tx_hash = ?" err := db.QueryRowContext(ctx, query, txHash).Scan(&txBytes) @@ -183,8 +183,8 @@ func GetFullTxByHash(ctx context.Context, db *sql.DB, txHash string) ([]byte, er return txBytes, nil } -// GetFullTxByHeightAndIndex retrieves a full transaction by its parent block height and index -func GetFullTxByHeightAndIndex(ctx context.Context, db *sql.DB, blockHeight, txIndex int) ([]byte, error) { +// GetTxByHeightAndIndex retrieves a full transaction by its parent block height and index +func GetTxByHeightAndIndex(ctx context.Context, db *sql.DB, blockHeight, txIndex int) ([]byte, error) { var txBytes []byte // avoid a copy with *RawBytes query := "SELECT bytes from transactions WHERE (block_height = ? AND tx_index = ?)" err := db.QueryRowContext(ctx, query, blockHeight, txIndex).Scan(&txBytes) @@ -194,8 +194,8 @@ func GetFullTxByHeightAndIndex(ctx context.Context, db *sql.DB, blockHeight, txI return txBytes, nil } -// GetFullTxByHashAndIndex retrieves a full transaction by its parent block hash and index -func GetFullTxByHashAndIndex(ctx context.Context, db *sql.DB, blockHash string, txIndex int) ([]byte, error) { +// GetTxByHashAndIndex retrieves a full transaction by its parent block hash and index +func GetTxByHashAndIndex(ctx context.Context, db *sql.DB, blockHash string, txIndex int) ([]byte, error) { var txBytes []byte // avoid a copy with *RawBytes query := "SELECT bytes from transactions WHERE (block_hash = ? AND tx_index = ?)" err := db.QueryRowContext(ctx, query, blockHash, txIndex).Scan(&txBytes)