updated block types

This commit is contained in:
Jae Kwon
2014-06-05 02:34:45 -07:00
parent 2c97c84c6e
commit eda3965d6a
9 changed files with 439 additions and 440 deletions

View File

@@ -5,64 +5,6 @@ import (
"io"
)
type AccountId interface {
Binary
Type() Byte
}
const (
ACCOUNT_TYPE_NUMBER = Byte(0x00)
ACCOUNT_TYPE_PUBKEY = Byte(0x01)
)
/* AccountNumber < AccountId */
type AccountNumber uint64
func (self AccountNumber) Type() Byte {
return ACCOUNT_TYPE_NUMBER
}
func (self AccountNumber) Equals(o Binary) bool {
return self == o
}
func (self AccountNumber) ByteSize() int {
return 1 + 8
}
func (self AccountNumber) WriteTo(w io.Writer) (n int64, err error) {
var n_ int64
n_, err = self.Type().WriteTo(w)
n += n_; if err != nil { return n, err }
n_, err = UInt64(self).WriteTo(w)
n += n_; return
}
/* AccountPubKey < AccountId */
type AccountPubKey []byte
func (self AccountPubKey) Type() Byte {
return ACCOUNT_TYPE_PUBKEY
}
func (self AccountPubKey) Equals(o Binary) bool {
return ByteSlice(self).Equals(o)
}
func (self AccountPubKey) ByteSize() int {
return 1 + ByteSlice(self).ByteSize()
}
func (self AccountPubKey) WriteTo(w io.Writer) (n int64, err error) {
var n_ int64
n_, err = self.Type().WriteTo(w)
n += n_; if err != nil { return n, err }
n_, err = ByteSlice(self).WriteTo(w)
n += n_; return
}
/*
Signature message wire format:
@@ -81,6 +23,10 @@ type Signature struct {
SigBytes ByteSlice
}
func ReadSignature(r io.Reader) *Signature {
return nil
}
func (self *Signature) Equals(other Binary) bool {
if o, ok := other.(*Signature); ok {
return self.Signer.Equals(o.Signer) &&
@@ -90,11 +36,6 @@ func (self *Signature) Equals(other Binary) bool {
}
}
func (self *Signature) ByteSize() int {
return self.Signer.ByteSize() +
self.SigBytes.ByteSize()
}
func (self *Signature) WriteTo(w io.Writer) (n int64, err error) {
var n_ int64
n_, err = self.Signer.WriteTo(w)
@@ -106,8 +47,3 @@ func (self *Signature) WriteTo(w io.Writer) (n int64, err error) {
func (self *Signature) Verify(msg ByteSlice) bool {
return false
}
func ReadSignature(buf []byte, start int) (*Signature, int) {
return nil, 0
}