|
|
@ -2,6 +2,7 @@ package types |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"encoding/hex" |
|
|
|
"encoding/hex" |
|
|
|
|
|
|
|
"encoding/json" |
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
"sort" |
|
|
|
"sort" |
|
|
|
|
|
|
|
|
|
|
@ -24,16 +25,6 @@ type CrossLink struct { |
|
|
|
EpochF *big.Int |
|
|
|
EpochF *big.Int |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// RPCCrossLink is used for returning data to RPC calls, converting byte arrays to hex encoded strings
|
|
|
|
|
|
|
|
type RPCCrossLink struct { |
|
|
|
|
|
|
|
HashF common.Hash `json:"parentHash"` |
|
|
|
|
|
|
|
BlockNumberF *big.Int `json:"blockNumber"` |
|
|
|
|
|
|
|
SignatureF string `json:"signature"` |
|
|
|
|
|
|
|
BitmapF string `json:"signatureBitmap"` |
|
|
|
|
|
|
|
ShardIDF uint32 `json:"shardId"` |
|
|
|
|
|
|
|
EpochF *big.Int `json:"epochNumber"` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NewCrossLink returns a new cross link object
|
|
|
|
// NewCrossLink returns a new cross link object
|
|
|
|
// epoch is the parentHeader's epoch
|
|
|
|
// epoch is the parentHeader's epoch
|
|
|
|
func NewCrossLink(header *block.Header, epoch *big.Int) CrossLink { |
|
|
|
func NewCrossLink(header *block.Header, epoch *big.Int) CrossLink { |
|
|
@ -80,16 +71,23 @@ func (cl CrossLink) Signature() [96]byte { |
|
|
|
return cl.SignatureF |
|
|
|
return cl.SignatureF |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ConvertForRPC converts CrossLink into RPCCrossLink
|
|
|
|
// MarshalJSON ..
|
|
|
|
func (cl CrossLink) ConvertForRPC() *RPCCrossLink { |
|
|
|
func (cl CrossLink) MarshalJSON() ([]byte, error) { |
|
|
|
return &RPCCrossLink{ |
|
|
|
return json.Marshal(struct { |
|
|
|
HashF: cl.HashF, |
|
|
|
Hash common.Hash `json:"hash"` |
|
|
|
BlockNumberF: cl.BlockNumberF, |
|
|
|
BlockNumber *big.Int `json:"block-number"` |
|
|
|
SignatureF: hex.EncodeToString(cl.SignatureF[:]), |
|
|
|
Signature string `json:"signature"` |
|
|
|
BitmapF: hex.EncodeToString(cl.BitmapF), |
|
|
|
Bitmap string `json:"signature-bitmap"` |
|
|
|
ShardIDF: cl.ShardIDF, |
|
|
|
ShardID uint32 `json:"shard-id"` |
|
|
|
EpochF: cl.EpochF, |
|
|
|
EpochNumber *big.Int `json:"epoch-number"` |
|
|
|
} |
|
|
|
}{ |
|
|
|
|
|
|
|
cl.HashF, |
|
|
|
|
|
|
|
cl.BlockNumberF, |
|
|
|
|
|
|
|
hex.EncodeToString(cl.SignatureF[:]), |
|
|
|
|
|
|
|
hex.EncodeToString(cl.BitmapF), |
|
|
|
|
|
|
|
cl.ShardIDF, |
|
|
|
|
|
|
|
cl.EpochF, |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Serialize returns bytes of cross link rlp-encoded content
|
|
|
|
// Serialize returns bytes of cross link rlp-encoded content
|
|
|
|