-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
238 additions
and
3 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
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
65 changes: 65 additions & 0 deletions
65
src/main/java/com/algorand/algosdk/v2/client/algod/GetBlockHash.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,65 @@ | ||
package com.algorand.algosdk.v2.client.algod; | ||
|
||
import com.algorand.algosdk.v2.client.common.Client; | ||
import com.algorand.algosdk.v2.client.common.HttpMethod; | ||
import com.algorand.algosdk.v2.client.common.Query; | ||
import com.algorand.algosdk.v2.client.common.QueryData; | ||
import com.algorand.algosdk.v2.client.common.Response; | ||
import com.algorand.algosdk.v2.client.model.BlockHashResponse; | ||
|
||
|
||
/** | ||
* Get the block hash for the block on the given round. | ||
* /v2/blocks/{round}/hash | ||
*/ | ||
public class GetBlockHash extends Query { | ||
|
||
private Long round; | ||
|
||
/** | ||
* @param round The round from which to fetch block hash information. | ||
*/ | ||
public GetBlockHash(Client client, Long round) { | ||
super(client, new HttpMethod("get")); | ||
this.round = round; | ||
} | ||
|
||
/** | ||
* Execute the query. | ||
* @return the query response object. | ||
* @throws Exception | ||
*/ | ||
@Override | ||
public Response<BlockHashResponse> execute() throws Exception { | ||
Response<BlockHashResponse> resp = baseExecute(); | ||
resp.setValueType(BlockHashResponse.class); | ||
return resp; | ||
} | ||
|
||
/** | ||
* Execute the query with custom headers, there must be an equal number of keys and values | ||
* or else an error will be generated. | ||
* @param headers an array of header keys | ||
* @param values an array of header values | ||
* @return the query response object. | ||
* @throws Exception | ||
*/ | ||
@Override | ||
public Response<BlockHashResponse> execute(String[] headers, String[] values) throws Exception { | ||
Response<BlockHashResponse> resp = baseExecute(headers, values); | ||
resp.setValueType(BlockHashResponse.class); | ||
return resp; | ||
} | ||
|
||
protected QueryData getRequestString() { | ||
if (this.round == null) { | ||
throw new RuntimeException("round is not set. It is a required parameter."); | ||
} | ||
addPathSegment(String.valueOf("v2")); | ||
addPathSegment(String.valueOf("blocks")); | ||
addPathSegment(String.valueOf(round)); | ||
addPathSegment(String.valueOf("hash")); | ||
|
||
return qd; | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/algorand/algosdk/v2/client/model/BlockHashResponse.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,30 @@ | ||
package com.algorand.algosdk.v2.client.model; | ||
|
||
import java.util.Objects; | ||
|
||
import com.algorand.algosdk.v2.client.common.PathResponse; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* Hash of a block header. | ||
*/ | ||
public class BlockHashResponse extends PathResponse { | ||
|
||
/** | ||
* Block header hash. | ||
*/ | ||
@JsonProperty("blockHash") | ||
public String blockHash; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
|
||
if (this == o) return true; | ||
if (o == null) return false; | ||
|
||
BlockHashResponse other = (BlockHashResponse) o; | ||
if (!Objects.deepEquals(this.blockHash, other.blockHash)) return false; | ||
|
||
return true; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/algorand/algosdk/v2/client/model/ParticipationUpdates.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,33 @@ | ||
package com.algorand.algosdk.v2.client.model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import com.algorand.algosdk.v2.client.common.PathResponse; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* Participation account data that needs to be checked/acted on by the network. | ||
*/ | ||
public class ParticipationUpdates extends PathResponse { | ||
|
||
/** | ||
* (partupdrmv) a list of online accounts that needs to be converted to offline | ||
* since their participation key expired. | ||
*/ | ||
@JsonProperty("expired-participation-accounts") | ||
public List<String> expiredParticipationAccounts = new ArrayList<String>(); | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
|
||
if (this == o) return true; | ||
if (o == null) return false; | ||
|
||
ParticipationUpdates other = (ParticipationUpdates) o; | ||
if (!Objects.deepEquals(this.expiredParticipationAccounts, other.expiredParticipationAccounts)) return false; | ||
|
||
return true; | ||
} | ||
} |
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
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