"fmt"
"github.com/jhalter/mobius/concat"
"math/rand"
- "net"
)
const (
}, tranLen, nil
}
-func readN(conn net.Conn, n int) ([]Transaction, error) {
- buf := make([]byte, 1400)
- i := 0
- for {
- readLen, err := conn.Read(buf)
- if err != nil {
- return nil, err
- }
-
- transactions, _, err := readTransactions(buf[:readLen])
- // spew.Fdump(os.Stderr, transactions)
- if err != nil {
- return nil, err
- }
-
- i += len(transactions)
-
- if n == i {
- return transactions, nil
- }
- }
-}
-
func readTransactions(buf []byte) ([]Transaction, int, error) {
var transactions []Transaction
return fields, nil
}
-func (t Transaction) MarshalBinary() (data []byte, err error) {
+func (t *Transaction) MarshalBinary() (data []byte, err error) {
payloadSize := t.Size()
fieldCount := make([]byte, 2)
}
// Size returns the total size of the transaction payload
-func (t Transaction) Size() []byte {
+func (t *Transaction) Size() []byte {
bs := make([]byte, 4)
fieldSize := 0
return bs
}
-func (t Transaction) GetField(id int) Field {
+func (t *Transaction) GetField(id int) Field {
for _, field := range t.Fields {
if id == int(binary.BigEndian.Uint16(field.ID)) {
return field