Revert the order of transactions in socket.io interface
This commit is contained in:
parent
b3b8512958
commit
526b7534d6
@ -249,17 +249,20 @@ func unmarshalGetAddressRequest(params []byte) (addr []string, opts addrOpts, er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func uniqueTxids(txids []string) []string {
|
// bitcore returns txids from the newest to the oldest, we have to revert the order
|
||||||
uniqueTxids := make([]string, 0, len(txids))
|
func uniqueTxidsInReverse(txids []string) []string {
|
||||||
|
i := len(txids)
|
||||||
|
ut := make([]string, i)
|
||||||
txidsMap := make(map[string]struct{})
|
txidsMap := make(map[string]struct{})
|
||||||
for _, txid := range txids {
|
for _, txid := range txids {
|
||||||
_, e := txidsMap[txid]
|
_, e := txidsMap[txid]
|
||||||
if !e {
|
if !e {
|
||||||
uniqueTxids = append(uniqueTxids, txid)
|
i--
|
||||||
|
ut[i] = txid
|
||||||
txidsMap[txid] = struct{}{}
|
txidsMap[txid] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return uniqueTxids
|
return ut[i:]
|
||||||
}
|
}
|
||||||
|
|
||||||
type resultAddressTxids struct {
|
type resultAddressTxids struct {
|
||||||
@ -296,7 +299,7 @@ func (s *SocketIoServer) getAddressTxids(addr []string, opts *addrOpts) (res res
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.Result = uniqueTxids(txids)
|
res.Result = uniqueTxidsInReverse(txids)
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user