mirror of
				https://github.com/Qortal/altcoinj.git
				synced 2025-11-03 05:57:21 +00:00 
			
		
		
		
	Sort keys by age when printing them. Also fix a generics warning.
This commit is contained in:
		@@ -90,9 +90,21 @@ import static com.google.common.base.Preconditions.*;
 | 
			
		||||
public class ECKey implements EncryptableItem, Serializable {
 | 
			
		||||
    private static final Logger log = LoggerFactory.getLogger(ECKey.class);
 | 
			
		||||
 | 
			
		||||
    /** Compares pub key bytes using {@link com.google.common.primitives.UnsignedBytes#lexicographicalComparator()} **/
 | 
			
		||||
    /** Sorts oldest keys first, newest last. */
 | 
			
		||||
    public static final Comparator<ECKey> AGE_COMPARATOR = new Comparator<ECKey>() {
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public int compare(ECKey k1, ECKey k2) {
 | 
			
		||||
            if (k1.creationTimeSeconds == k2.creationTimeSeconds)
 | 
			
		||||
                return 0;
 | 
			
		||||
            else
 | 
			
		||||
                return k1.creationTimeSeconds > k2.creationTimeSeconds ? 1 : -1;
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /** Compares pub key bytes using {@link com.google.common.primitives.UnsignedBytes#lexicographicalComparator()} */
 | 
			
		||||
    public static final Comparator<ECKey> PUBKEY_COMPARATOR = new Comparator<ECKey>() {
 | 
			
		||||
        private Comparator comparator = UnsignedBytes.lexicographicalComparator();
 | 
			
		||||
        private Comparator<byte[]> comparator = UnsignedBytes.lexicographicalComparator();
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public int compare(ECKey k1, ECKey k2) {
 | 
			
		||||
 
 | 
			
		||||
@@ -726,7 +726,9 @@ public class KeyChainGroup implements KeyBag {
 | 
			
		||||
    public String toString(boolean includePrivateKeys) {
 | 
			
		||||
        final StringBuilder builder = new StringBuilder();
 | 
			
		||||
        if (basic != null) {
 | 
			
		||||
            for (ECKey key : basic.getKeys())
 | 
			
		||||
            List<ECKey> keys = basic.getKeys();
 | 
			
		||||
            Collections.sort(keys, ECKey.AGE_COMPARATOR);
 | 
			
		||||
            for (ECKey key : keys)
 | 
			
		||||
                key.formatKeyWithAddress(includePrivateKeys, builder, params);
 | 
			
		||||
        }
 | 
			
		||||
        List<String> chainStrs = Lists.newLinkedList();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user