Exemplo n.º 1
0
// PreviewCommitTxBatchBlock retrieves a preview copy of the block that would be inserted into the ledger if CommitTxBatch were invoked.
// As a preview copy, it only guarantees that the hashable portions of the block will match the committed block.  Consequently,
// this preview block should only be used for hash computations and never distributed, passed into PutBlock, etc..
// The guarantee of hashable equality will be violated if additional ExecTXs calls are invoked.
func (h *Helper) PreviewCommitTxBatchBlock(id interface{}, txs []*pb.Transaction, metadata []byte) (*pb.Block, error) {
	ledger, err := ledger.GetLedger()
	if err != nil {
		return nil, fmt.Errorf("Failed to get the ledger: %v", err)
	}
	block, err := ledger.GetTXBatchPreviewBlock(id, txs, metadata)
	if err != nil {
		return nil, fmt.Errorf("Failed to commit transaction to the ledger: %v", err)
	}
	return block, err
}
Exemplo n.º 2
0
// PreviewCommitTxBatch retrieves a preview copy of the block that would be inserted into the ledger if CommitTxBatch were invoked.
// As a preview copy, it only guarantees that the hashable portions of the block will match the committed block.  Consequently,
// this preview block should only be used for hash computations and never distributed, passed into PutBlock, etc..
// The guarantee of hashable equality will be violated if additional ExecTXs calls are invoked.
func (h *Helper) PreviewCommitTxBatch(id interface{}, metadata []byte) (*pb.Block, error) {
	ledger, err := ledger.GetLedger()
	if err != nil {
		return nil, fmt.Errorf("Failed to get the ledger: %v", err)
	}
	// TODO fix this once the underlying API is fixed
	block, err := ledger.GetTXBatchPreviewBlock(id, h.curBatch, metadata)
	if err != nil {
		return nil, fmt.Errorf("Failed to commit transaction to the ledger: %v", err)
	}
	return block, err
}