OSDN Git Service

merge order from pool (#432)
[bytom/vapor.git] / application / mov / common / type.go
index 9f55f2f..570f8a7 100644 (file)
@@ -23,6 +23,18 @@ type Order struct {
        Rate        float64
 }
 
+type OrderSlice []*Order
+
+func (o OrderSlice) Len() int {
+       return len(o)
+}
+func (o OrderSlice) Swap(i, j int) {
+       o[i], o[j] = o[j], o[i]
+}
+func (o OrderSlice) Less(i, j int) bool {
+       return o[i].Rate < o[j].Rate
+}
+
 func NewOrderFromOutput(tx *types.Tx, outputIndex int) (*Order, error) {
        outputID := tx.OutputID(outputIndex)
        output, err := tx.IntraChainOutput(*outputID)