<commit_before>// Copyright (c) 2014-2017 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package rpc

import (
	"github.com/bitmark-inc/bitmarkd/merkle"
	"github.com/bitmark-inc/bitmarkd/reservoir"
	"github.com/bitmark-inc/logger"
	"time"
)

// Transaction is a rpc entry for transaction related functions
type Transaction struct {
	log   *logger.L
	start time.Time
}

// TransactionArguments is the arguments for statuc rpc request
type TransactionArguments struct {
	Id string `json:"txId"`
}

// TransactionStatus is a struct for an rpc reply
type TransactionStatus struct {
	Status string `json:"status"`
}

// Status is an rpc api for query transaction status
func (t *Transaction) Status(arguments *TransactionArguments, reply *TransactionStatus) error {
	var txId merkle.Digest
	err := txId.UnmarshalText([]byte(arguments.Id))
	if err != nil {
		return err
	}
	reply.Status = reservoir.TransactionStatus(txId).String()
	return nil
}<commit_msg>[rpc] fix tx id decoding<commit_after>// Copyright (c) 2014-2017 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package rpc

import (
	"github.com/bitmark-inc/bitmarkd/merkle"
	"github.com/bitmark-inc/bitmarkd/reservoir"
	"github.com/bitmark-inc/logger"
	"time"
)

// Transaction is a rpc entry for transaction related functions
type Transaction struct {
	log   *logger.L
	start time.Time
}

// TransactionArguments is the arguments for statuc rpc request
type TransactionArguments struct {
	TxId merkle.Digest `json:"txId"`
}

// TransactionStatus is a struct for an rpc reply
type TransactionStatusReply struct {
	Status string `json:"status"`
}

// Status is an rpc api for query transaction status
func (t *Transaction) Status(arguments *TransactionArguments, reply *TransactionStatusReply) error {
	reply.Status = reservoir.TransactionStatus(arguments.TxId).String()
	return nil
}
{'fraction_non_alphanumeric': 0.09400406504065041, 'fraction_numerical': 0.008130081300813009, 'mean_word_length': 4.40934065934066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '306543', 'n_tokens_mistral': 607, 'n_tokens_neox': 589, 'n_words': 208}