-
Notifications
You must be signed in to change notification settings - Fork 370
White flag #1806
base: white-flag
Are you sure you want to change the base?
White flag #1806
Changes from 2 commits
80655fa
d05b6bc
0a70b70
7c430ce
6a2653f
a0532cb
2d4cc70
192670c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -863,6 +863,30 @@ public void isMilestone(Tangle tangle, Snapshot initialSnapshot, final boolean i | |
} | ||
} | ||
|
||
/** | ||
* This method sets the {@link Transaction#conflicting} flag. | ||
* | ||
* It first checks if the {@link Transaction#conflicting} flag has changed. If so, it issues a database update. | ||
* @param tangle Tangle instance | ||
* @param initialSnapshot The snapshot representing the start of the ledger | ||
* @param isConflicting True if the transaction is conflicting and ignored during balance computation | ||
* @throws Exception If something goes wrong | ||
*/ | ||
public void isConflicting(Tangle tangle, Snapshot initialSnapshot, final boolean isConflicting) throws Exception { | ||
if(isConflicting != transaction.conflicting){ | ||
transaction.conflicting = isConflicting; | ||
update(tangle, initialSnapshot, "conflicting"); | ||
} | ||
} | ||
|
||
/** | ||
* Checks if a transaction is empty. | ||
* @return True if empty. False otherwise. | ||
*/ | ||
public boolean isEmpty(){ | ||
return Arrays.equals(getBytes(), new byte[SIZE]); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently we are just check for But it will be more awful if we have more than one way to do this check... |
||
/** | ||
* This method gets the {@link Transaction#milestone}. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,11 @@ public class Transaction implements Persistable { | |
*/ | ||
public static final int IS_MILESTONE_BITMASK = 0b10; | ||
|
||
/** | ||
* Bitmask used to access and store the conflicting flag. | ||
*/ | ||
public static final int IS_CONFLICTING_BITMASK = 0b100; | ||
|
||
public byte[] bytes; | ||
|
||
public Hash address; | ||
|
@@ -75,6 +80,11 @@ public class Transaction implements Persistable { | |
*/ | ||
public boolean solid = false; | ||
|
||
/** | ||
* This flag indicates whether the transaction is conflicting and was ignored in balance computation | ||
*/ | ||
public boolean conflicting = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you branched off Technically |
||
|
||
/** | ||
* This flag indicates if the transaction is a coordinator issued milestone. | ||
*/ | ||
|
@@ -142,6 +152,7 @@ public byte[] metadata() { | |
byte flags = 0; | ||
flags |= solid ? IS_SOLID_BITMASK : 0; | ||
flags |= milestone ? IS_MILESTONE_BITMASK : 0; | ||
flags |= conflicting ? IS_CONFLICTING_BITMASK : 0; | ||
buffer.put(flags); | ||
|
||
buffer.put(Serializer.serialize(snapshot)); | ||
|
@@ -205,6 +216,7 @@ public void readMetadata(byte[] bytes) { | |
// decode the boolean byte by checking the bitmasks | ||
solid = (bytes[i] & IS_SOLID_BITMASK) != 0; | ||
milestone = (bytes[i] & IS_MILESTONE_BITMASK) != 0; | ||
conflicting = (bytes[i] & IS_CONFLICTING_BITMASK) != 0; | ||
i++; | ||
|
||
snapshot = Serializer.getInteger(bytes, i); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a scenario for invalid bundles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already done in my PR, theyre in the disabled regression tests file in machine 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was just about to tag you here @kwek20 but I see you are very alert :-)