-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pass the version to payload, and payload can decide how to Deserialize. Signed-off-by: luodanwg <[email protected]>
- Loading branch information
1 parent
bda569e
commit 6bd4f3b
Showing
10 changed files
with
76 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,93 @@ | ||
package payload | ||
|
||
import ( | ||
. "DNA/core/code" | ||
"DNA/common/serialization" | ||
. "DNA/core/code" | ||
"io" | ||
) | ||
|
||
const DeployCodePayloadVersion byte = 0x00 | ||
|
||
type DeployCode struct { | ||
Code *FunctionCode | ||
Name string | ||
CodeVersion string | ||
Author string | ||
Email string | ||
Description string | ||
Code *FunctionCode | ||
Name string | ||
CodeVersion string | ||
Author string | ||
Email string | ||
Description string | ||
} | ||
|
||
func (dc *DeployCode) Data() []byte { | ||
func (dc *DeployCode) Data(version byte) []byte { | ||
// TODO: Data() | ||
|
||
return []byte{0} | ||
} | ||
|
||
func (dc *DeployCode) Serialize(w io.Writer) error { | ||
func (dc *DeployCode) Serialize(w io.Writer, version byte) error { | ||
|
||
err := dc.Code.Serialize(w) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = serialization.WriteVarString(w,dc.Name) | ||
err = serialization.WriteVarString(w, dc.Name) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = serialization.WriteVarString(w,dc.CodeVersion) | ||
err = serialization.WriteVarString(w, dc.CodeVersion) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = serialization.WriteVarString(w,dc.Author) | ||
err = serialization.WriteVarString(w, dc.Author) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = serialization.WriteVarString(w,dc.Email) | ||
err = serialization.WriteVarString(w, dc.Email) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = serialization.WriteVarString(w,dc.Description) | ||
err = serialization.WriteVarString(w, dc.Description) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (dc *DeployCode) Deserialize(r io.Reader) error { | ||
func (dc *DeployCode) Deserialize(r io.Reader, version byte) error { | ||
err := dc.Code.Deserialize(r) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
dc.Name,err = serialization.ReadVarString(r) | ||
dc.Name, err = serialization.ReadVarString(r) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
dc.CodeVersion,err = serialization.ReadVarString(r) | ||
dc.CodeVersion, err = serialization.ReadVarString(r) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
dc.Author,err = serialization.ReadVarString(r) | ||
dc.Author, err = serialization.ReadVarString(r) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
dc.Email,err = serialization.ReadVarString(r) | ||
dc.Email, err = serialization.ReadVarString(r) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
dc.Description,err = serialization.ReadVarString(r) | ||
dc.Description, err = serialization.ReadVarString(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
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
Oops, something went wrong.