mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-25 01:26:45 +00:00
introduce general purpose hash index record
This commit is contained in:
parent
083288061f
commit
3a557e3af8
3 changed files with 7 additions and 28 deletions
|
@ -26,8 +26,8 @@ if(os.macOsX) {
|
|||
osName = "osx"
|
||||
}
|
||||
|
||||
sourceCompatibility = 11
|
||||
targetCompatibility = 11
|
||||
sourceCompatibility = 16
|
||||
targetCompatibility = 16
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package com.sparrowwallet.drongo.protocol;
|
||||
|
||||
public record HashIndex(Sha256Hash hash, long index) {}
|
|
@ -1,12 +1,12 @@
|
|||
package com.sparrowwallet.drongo.wallet;
|
||||
|
||||
import com.sparrowwallet.drongo.protocol.HashIndex;
|
||||
import com.sparrowwallet.drongo.protocol.Sha256Hash;
|
||||
import com.sparrowwallet.drongo.protocol.Transaction;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BlockTransaction extends BlockTransactionHash implements Comparable<BlockTransaction> {
|
||||
|
@ -67,7 +67,7 @@ public class BlockTransaction extends BlockTransactionHash implements Comparable
|
|||
}
|
||||
|
||||
return blockchainTransaction.getTransaction().getInputs().stream()
|
||||
.map(txInput -> new HashIndex(txInput.getOutpoint().getHash(), (int)txInput.getOutpoint().getIndex()))
|
||||
.map(txInput -> new HashIndex(txInput.getOutpoint().getHash(), txInput.getOutpoint().getIndex()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -80,28 +80,4 @@ public class BlockTransaction extends BlockTransactionHash implements Comparable
|
|||
.map(txOutput -> new HashIndex(blockchainTransaction.getHash(), txOutput.getIndex()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static class HashIndex {
|
||||
public Sha256Hash hash;
|
||||
public int index;
|
||||
|
||||
public HashIndex(Sha256Hash hash, int index) {
|
||||
this.hash = hash;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
HashIndex hashIndex = (HashIndex) o;
|
||||
return index == hashIndex.index &&
|
||||
hash.equals(hashIndex.hash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(hash, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue