-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add nonce to BookKeeping transaction
add nonce to BookKeeping transaction to solve the bookKeeping Overwrite problem. Signed-off-by: luodanwg <[email protected]>
- Loading branch information
1 parent
933bbdd
commit fe0e9ab
Showing
5 changed files
with
61 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
package payload | ||
|
||
import "io" | ||
import ( | ||
"DNA/common/serialization" | ||
"io" | ||
) | ||
|
||
type BookKeeping struct { | ||
Nonce uint64 | ||
} | ||
|
||
func (a *BookKeeping) Data() []byte { | ||
return []byte{0} | ||
} | ||
|
||
func (a *BookKeeping) Serialize(w io.Writer) error { | ||
err := serialization.WriteUint64(w, a.Nonce) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (a *BookKeeping) Deserialize(r io.Reader) error { | ||
var err error | ||
a.Nonce, err = serialization.ReadUint64(r) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
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