X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=wallet%2Funconfirmed.go;fp=wallet%2Funconfirmed.go;h=5b04b1baa06106c97f4bb01fdf1dcb5cbf3b95a2;hb=041a74394dd18dc0abbee21dd6e6e18bbdbd630a;hp=b616518f08ba69618feffb29f881a731aeb3cf27;hpb=e3f88c0fd58293b5d6651ba83c908c6fb2788ce0;p=bytom%2Fbytom.git diff --git a/wallet/unconfirmed.go b/wallet/unconfirmed.go index b616518f..5b04b1ba 100644 --- a/wallet/unconfirmed.go +++ b/wallet/unconfirmed.go @@ -33,6 +33,13 @@ func (a SortByTimestamp) Len() int { return len(a) } func (a SortByTimestamp) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a SortByTimestamp) Less(i, j int) bool { return a[i].Timestamp > a[j].Timestamp } +// SortByHeight implements sort.Interface for AnnotatedTx slices +type SortByHeight []*query.AnnotatedTx + +func (a SortByHeight) Len() int { return len(a) } +func (a SortByHeight) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a SortByHeight) Less(i, j int) bool { return a[i].BlockHeight > a[j].BlockHeight } + // AddUnconfirmedTx handle wallet status update when tx add into txpool func (w *Wallet) AddUnconfirmedTx(txD *protocol.TxDesc) { if err := w.saveUnconfirmedTx(txD.Tx); err != nil {