Skip to content

Commit

Permalink
[cgo] refs fibercrypto#116 Finalized transaction.choose
Browse files Browse the repository at this point in the history
  • Loading branch information
Maykel Arias Torres committed Jan 18, 2020
1 parent 628e3ac commit 86b0bae
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
21 changes: 8 additions & 13 deletions include/transaction.choose.go.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
/**
* Skycoin transaction.
*
* Instances of this struct are included in blocks.
*/
typedef struct {
cipher__SHA256 Hash; ///< Hash of underlying UxOut.
GoUint64_ BkSeq; ///< Block height corresponding to the
///< moment balance calculation is performed at.
cipher__Address Address; ///< Account holder address.
GoUint64_ Coins; ///< Coins amount (e.g. in SKY).
GoUint64_ Hours; ///< Balance of Coin Hours generated by underlying UxOut, depending on UxOut's head time.
typedef struct{
cipher__SHA256 Hash;
GoUint64_ BkSeq;
GoUint64_ Time;
cipher__Address Address;
GoUint64_ Coins;
GoUint64_ InitialHours;
GoUint64_ Hours;
cipher__SHA256 SrcTransaction;
} transaction__UxBalance;
} transaction__UxBalance;
54 changes: 34 additions & 20 deletions lib/cgo/transaction.choose.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"unsafe"

coin "github.com/SkycoinProject/skycoin/src/coin"
"github.com/SkycoinProject/skycoin/src/transaction"
transaction "github.com/SkycoinProject/skycoin/src/transaction"
)

/*
Expand All @@ -14,23 +14,34 @@ import (
#include <stdlib.h>
#include "skytypes.h"
#include "skyfee.h"
#include "skyfee.h"
*/
import "C"

//export SKY_transaction_ChooseSpendsMaximizeUxOuts
func SKY_transaction_ChooseSpendsMaximizeUxOuts(_uxa []C.transaction__UxBalance, _coins, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) {
txa := *(*[]transaction.UxBalance)(unsafe.Pointer(&_uxa))
coins := _coins
hours := _hours
__arg2, ____return_err := transaction.ChooseSpendsMaximizeUxOuts(txa, coins, hours)
//export SKY_transaction_NewUxBalances
func SKY_transaction_NewUxBalances(_uxa *C.coin__UxArray, _headTime uint64, _arg2 *C.GoSlice_) (____error_code uint32) {
uxa := *(*coin.UxArray)(unsafe.Pointer(_uxa))
headTime := _headTime
__arg2, ____return_err := transaction.NewUxBalances(uxa, headTime)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyToGoSlice(reflect.ValueOf(__arg2), _arg2)
}
return
}

//export SKY_transaction_NewUxBalance
func SKY_transaction_NewUxBalance(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.transaction__UxBalance) (____error_code uint32) {
headTime := _headTime
ux := *(*coin.UxOut)(unsafe.Pointer(_ux))
__arg2, ____return_err := transaction.NewUxBalance(headTime, ux)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg2 = *(*C.transaction__UxBalance)(unsafe.Pointer(&__arg2))
}
return
}

//export SKY_transaction_ChooseSpendsMinimizeUxOuts
func SKY_transaction_ChooseSpendsMinimizeUxOuts(_uxa []C.transaction__UxBalance, _coins, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) {
uxa := *(*[]transaction.UxBalance)(unsafe.Pointer(&_uxa))
Expand All @@ -44,26 +55,29 @@ func SKY_transaction_ChooseSpendsMinimizeUxOuts(_uxa []C.transaction__UxBalance,
return
}

//export SKY_transaction_NewUxBalance
func SKY_transaction_NewUxBalance(_headTime uint64, _ux *C.coin__UxOut, _arg2 *C.transaction__UxBalance) (____error_code uint32) {
headTime := _headTime
ux := *(*coin.UxOut)(unsafe.Pointer(_ux))
__arg2, ____return_err := transaction.NewUxBalance(headTime, ux)
//export SKY_transaction_ChooseSpendsMaximizeUxOuts
func SKY_transaction_ChooseSpendsMaximizeUxOuts(_uxa []C.transaction__UxBalance, _coins, _hours uint64, _arg2 *C.GoSlice_) (____error_code uint32) {
uxa := *(*[]transaction.UxBalance)(unsafe.Pointer(&_uxa))
coins := _coins
hours := _hours
__arg2, ____return_err := transaction.ChooseSpendsMaximizeUxOuts(uxa, coins, hours)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg2 = *(*C.transaction__UxBalance)(unsafe.Pointer(&__arg2))
copyToGoSlice(reflect.ValueOf(__arg2), _arg2)
}
return
}

//export SKY_transaction_NewUxBalances
func SKY_transaction_NewUxBalances(_headTime uint64, _uxa *C.coin__UxArray, _arg2 *C.GoSlice_) (____error_code uint32) {
headTime := _headTime
uxa := *(*coin.UxArray)(unsafe.Pointer(_uxa))
__arg2, ____return_err := transaction.NewUxBalances(uxa, headTime)
//export SKY_transaction_ChooseSpends
func SKY_transaction_ChooseSpends(_uxa []C.transaction__UxBalance, _coins, _hours uint64, _sortStrategy, _arg3 *C.GoSlice_) (____error_code uint32) {
uxa := *(*[]transaction.UxBalance)(unsafe.Pointer(&_uxa))
coins := _coins
hours := _hours
sortStrategy := copyToFunc(_sortStrategy)
__arg3, ____return_err := transaction.ChooseSpends(uxa, coins, hours, sortStrategy)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
copyToGoSlice(reflect.ValueOf(__arg2), _arg2)
copyToGoSlice(reflect.ValueOf(__arg3), _arg3)
}
return
}

0 comments on commit 86b0bae

Please sign in to comment.