-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #17 Initial update for Conway network protocol, VotingProcedure…
…s cddl object
- Loading branch information
Showing
17 changed files
with
196 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
core/src/main/java/com/bloxbean/cardano/yaci/core/model/conway/Anchor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.bloxbean.cardano.yaci.core.model.conway; | ||
|
||
import lombok.*; | ||
|
||
/** | ||
* anchor = | ||
* [ anchor_url : url | ||
* , anchor_data_hash : $hash32 | ||
* ] | ||
*/ | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@ToString | ||
@EqualsAndHashCode | ||
@Builder | ||
public class Anchor { | ||
private String anchor_url; | ||
private String anchor_data_hash; | ||
} |
14 changes: 14 additions & 0 deletions
14
core/src/main/java/com/bloxbean/cardano/yaci/core/model/conway/GovActionId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.bloxbean.cardano.yaci.core.model.conway; | ||
|
||
import lombok.*; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@ToString | ||
@EqualsAndHashCode | ||
@Builder | ||
public class GovActionId { | ||
private String transactionId; | ||
private Integer gov_action_index; | ||
} |
10 changes: 10 additions & 0 deletions
10
core/src/main/java/com/bloxbean/cardano/yaci/core/model/conway/Vote.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.bloxbean.cardano.yaci.core.model.conway; | ||
|
||
public enum Vote { | ||
NO(0), YES(1), ABSTAIN(2); | ||
|
||
private final int value; | ||
Vote(int value) { | ||
this.value = value; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
core/src/main/java/com/bloxbean/cardano/yaci/core/model/conway/Voter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.bloxbean.cardano.yaci.core.model.conway; | ||
|
||
import lombok.*; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@ToString | ||
@EqualsAndHashCode | ||
@Builder | ||
public class Voter { | ||
private VoterType type; | ||
private String hash; //key hash or script hash | ||
} |
9 changes: 9 additions & 0 deletions
9
core/src/main/java/com/bloxbean/cardano/yaci/core/model/conway/VoterType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.bloxbean.cardano.yaci.core.model.conway; | ||
|
||
public enum VoterType { | ||
CONSTITUTIONAL_COMMITTEE_HOT_KEY_HASH, //0 | ||
CONSTITUTIONAL_COMMITTEE_HOT_SCRIPT_HASH, //1 | ||
DREP_KEY_HASH, //2 | ||
DREP_SCRIPT_HASH, //3 | ||
STAKING_POOL_KEY_HASH, //4 | ||
} |
18 changes: 18 additions & 0 deletions
18
core/src/main/java/com/bloxbean/cardano/yaci/core/model/conway/VotingProcedure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.bloxbean.cardano.yaci.core.model.conway; | ||
|
||
import lombok.*; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@ToString | ||
@EqualsAndHashCode | ||
@Builder | ||
/** | ||
* voting_procedure = | ||
* [ vote, anchor / null] | ||
*/ | ||
public class VotingProcedure { | ||
private Vote vote; | ||
private Anchor anchor; | ||
} |
18 changes: 18 additions & 0 deletions
18
core/src/main/java/com/bloxbean/cardano/yaci/core/model/conway/VotingProcedures.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.bloxbean.cardano.yaci.core.model.conway; | ||
|
||
import lombok.*; | ||
|
||
import java.util.Map; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@ToString | ||
@EqualsAndHashCode | ||
@Builder | ||
/** | ||
* voting_procedures = { + voter => { + gov_action_id => voting_procedure } } | ||
*/ | ||
public class VotingProcedures { | ||
private Map<Voter, Map<GovActionId, VotingProcedure>> voting; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...ain/java/com/bloxbean/cardano/yaci/core/model/serializers/VotingProceduresSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.bloxbean.cardano.yaci.core.model.serializers; | ||
|
||
import co.nstant.in.cbor.model.DataItem; | ||
import com.bloxbean.cardano.yaci.core.model.conway.VotingProcedures; | ||
import com.bloxbean.cardano.yaci.core.protocol.Serializer; | ||
|
||
public enum VotingProceduresSerializer implements Serializer<VotingProcedures> { | ||
INSTANCE; | ||
|
||
@Override | ||
public VotingProcedures deserializeDI(DataItem di) { | ||
System.out.println("VotingProceduresSerializer.deserializeDI ------"); | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
helper/src/integrationTest/java/com/bloxbean/cardano/yaci/helper/ConwayBlockSyncIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.bloxbean.cardano.yaci.helper; | ||
|
||
import com.bloxbean.cardano.yaci.core.common.Constants; | ||
import com.bloxbean.cardano.yaci.core.model.Block; | ||
import com.bloxbean.cardano.yaci.core.model.Era; | ||
import com.bloxbean.cardano.yaci.core.model.byron.ByronEbBlock; | ||
import com.bloxbean.cardano.yaci.core.model.byron.ByronMainBlock; | ||
import com.bloxbean.cardano.yaci.core.protocol.chainsync.messages.Point; | ||
import com.bloxbean.cardano.yaci.helper.listener.BlockChainDataListener; | ||
import com.bloxbean.cardano.yaci.helper.model.Transaction; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
public class ConwayBlockSyncIT extends BaseTest{ | ||
|
||
@Test | ||
void syncTest() throws Exception { | ||
BlockSync blockSync = new BlockSync(Constants.SANCHONET_PUBLIC_RELAY_ADDR, Constants.SANCHONET_PUBLIC_RELAY_PORT, Constants.SANCHONET_PROTOCOL_MAGIC, Constants.WELL_KNOWN_SANCHONET_POINT); | ||
|
||
blockSync.startSync(Point.ORIGIN, new BlockChainDataListener() { | ||
public void onBlock(Era era, Block block, List<Transaction> transactions) { | ||
System.out.println(block.getHeader().getHeaderBody().getBlockNumber()); | ||
System.out.println("# of transactions >> " + transactions.size()); | ||
} | ||
|
||
@Override | ||
public void onByronBlock(ByronMainBlock byronBlock) { | ||
System.out.println("Byron block: " + byronBlock); | ||
} | ||
|
||
@Override | ||
public void onByronEbBlock(ByronEbBlock byronEbBlock) { | ||
System.out.println("Byron EB block: " + byronEbBlock); | ||
} | ||
}); | ||
|
||
while (true) | ||
Thread.sleep(5000); | ||
} | ||
} |