Allowing the BlockData to be updated
This commit is contained in:
parent
96ce9c4722
commit
737bb5b4a6
1 changed files with 43 additions and 12 deletions
|
@ -45,27 +45,58 @@ public class BlockData implements ByteSerializable {
|
||||||
for(int i = 0; i < 8; i = i + 2){
|
for(int i = 0; i < 8; i = i + 2){
|
||||||
builder.append(hashData.substring(6 - i, 8 - i));
|
builder.append(hashData.substring(6 - i, 8 - i));
|
||||||
}
|
}
|
||||||
this.refBlockNum = ((int) head_block_number ) & 0xFFFF;
|
this.setRefBlockNum(head_block_number);
|
||||||
this.refBlockPrefix = Long.parseLong(builder.toString(), 16);
|
this.setRefBlockPrefix(head_block_id);
|
||||||
this.relativeExpiration = relative_expiration;
|
this.relativeExpiration = relative_expiration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plain setter for the ref_block_num field, assuming its value is exactly the one passed in the argument.
|
||||||
|
* @param refBlockNum: The 'ref_block_num' field.
|
||||||
|
*/
|
||||||
|
public void setRefBlockNum(int refBlockNum) {
|
||||||
|
this.refBlockNum = refBlockNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter that receives the block number, and takes the 16 lower bits of it to obtain the
|
||||||
|
* 'ref_block_num' value.
|
||||||
|
* @param blockNumber: The block number.
|
||||||
|
*/
|
||||||
|
public void setRefBlockNum(long blockNumber){
|
||||||
|
this.refBlockNum = ((int) blockNumber ) & 0xFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plain setter fot the 'ref_block_prefix' field, assumint its value is exactly the one passed in the argument.
|
||||||
|
* @param refBlockPrefix
|
||||||
|
*/
|
||||||
|
public void setRefBlockPrefix(long refBlockPrefix) {
|
||||||
|
this.refBlockPrefix = refBlockPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter that receives the head block id, and turns it into the little format required for the
|
||||||
|
* 'ref_block_prefix' field.
|
||||||
|
* @param headBlockId: The head block id as obtained from the network updates.
|
||||||
|
*/
|
||||||
|
public void setRefBlockPrefix(String headBlockId){
|
||||||
|
String hashData = headBlockId.substring(8, 16);
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for(int i = 0; i < 8; i = i + 2){
|
||||||
|
builder.append(hashData.substring(6 - i, 8 - i));
|
||||||
|
}
|
||||||
|
this.refBlockPrefix = Long.parseLong(builder.toString(), 16);
|
||||||
|
}
|
||||||
|
|
||||||
public int getRefBlockNum() {
|
public int getRefBlockNum() {
|
||||||
return refBlockNum;
|
return refBlockNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRefBlockNum(int refBlockNum) {
|
|
||||||
this.refBlockNum = refBlockNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getRefBlockPrefix() {
|
public long getRefBlockPrefix() {
|
||||||
return refBlockPrefix;
|
return refBlockPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRefBlockPrefix(long refBlockPrefix) {
|
|
||||||
this.refBlockPrefix = refBlockPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getRelativeExpiration() {
|
public long getRelativeExpiration() {
|
||||||
return relativeExpiration;
|
return relativeExpiration;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue