Skip to content

Commit

Permalink
Merge pull request #41 from TransferChain/development
Browse files Browse the repository at this point in the history
 Fix: broadcast structure
  • Loading branch information
akdilsiz authored Feb 15, 2024
2 parents 1986698 + 62c633e commit 30f625d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
14 changes: 8 additions & 6 deletions broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import (
)

type Broadcast struct {
ID string `json:"id"`
Version int `json:"version"`
Type Type `json:"type"`
Data []byte `json:"data"`
Sign []byte `json:"sign"`
Fee int `json:"fee"`
ID string `json:"id"` //Hash of the transaction
Version uint32 `json:"version"`
Type Type `json:"type"`
SenderAddr string `json:"sender_addr"`
RecipientAddr string `json:"recipient_addr"`
Data []byte `json:"data"`
Sign []byte `json:"sign"`
Fee uint64 `json:"fee"`
}

func (b *Broadcast) URI() string {
Expand Down
20 changes: 11 additions & 9 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type Client interface {
LastBlock() (*LastBlock, error)
TxSummary(summary *Summary) (lastBlockHeight uint64, lastTransaction *Transaction, totalCount uint64, err error)
TxSearch(search *Search) (txs []*Transaction, totalCount uint64, err error)
Broadcast(id string, version int, typ Type, data []byte, senderAddress, recipientAddress string, sign []byte, fee int) (*BroadcastResponse, error)
Broadcast(id string, version uint32, typ Type, data []byte, senderAddress, recipientAddress string, sign []byte, fee uint64) (*BroadcastResponse, error)
}

type client struct {
Expand Down Expand Up @@ -104,7 +104,7 @@ type sendMsg struct {
// NewClient make ws client
func NewClient(address string, wsAddress string) (Client, error) {
c := new(client)
c.version = "v1.2.0"
c.version = "v1.2.1"
c.address = address
c.wsAddress = wsAddress

Expand Down Expand Up @@ -689,18 +689,20 @@ func (c *client) TxSearch(search *Search) (txs []*Transaction, totalCount uint64
}

// Broadcast ...
func (c *client) Broadcast(id string, version int, typ Type, data []byte, senderAddress, recipientAddress string, sign []byte, fee int) (*BroadcastResponse, error) {
func (c *client) Broadcast(id string, version uint32, typ Type, data []byte, senderAddress, recipientAddress string, sign []byte, fee uint64) (*BroadcastResponse, error) {
if !typ.IsValid() {
return nil, errors.New("invalid type")
}

broadcast := &Broadcast{
ID: id,
Version: version,
Type: typ,
Data: data,
Sign: sign,
Fee: fee,
ID: id,
Version: version,
Type: typ,
SenderAddr: senderAddress,
RecipientAddr: recipientAddress,
Data: data,
Sign: sign,
Fee: fee,
}

var err error
Expand Down

0 comments on commit 30f625d

Please sign in to comment.