Documentation ¶
Overview ¶
NodeID 和 publicKey 之间的互相转换参见 /p2p/discover 下的 node.go func PubkeyID(pub *ecdsa.PublicKey) NodeID {} func (id NodeID) Pubkey() (*ecdsa.PublicKey, error) {} 两个函数
Index ¶
- Constants
- func BlizHash(data []byte) []byte
- func CommonHash(x interface{}) (h common.Hash)
- func CommonSender(h common.Hash, sign []byte) (common.Address, error)
- func CommonSign(h common.Hash, prv *ecdsa.PrivateKey) ([]byte, error)
- func EcRecover(data, sig []byte) (common.Address, error)
- func ErrorToUInt8(e error) uint8
- func RecoverBase(addr common.Address, deadline uint64, r, s, v *big.Int) (common.Address, error)
- func RlpHash(x interface{}) (h common.Hash)
- func SignWop(wop *WriteOperReqData, prv *ecdsa.PrivateKey) error
- type BlizObjectMeta
- type BuffFromSharerCSData
- type DataQuery
- type DiscReason
- type ErrCode
- type FarmerSliceOp
- type FarmerSliceOpReq
- type FarmerSliceOpRsp
- type GetBuffFromSharerCSData
- type GetHeaderHashMsgData
- type GetSegmentDataMsgData
- type GetSliceInfoMsgData
- type GetSliceMetaFromFarmerReqData
- type GetWriteDataMsgData
- type GetWriteOpMsgData
- type HeaderHashMsgData
- type HeartBeatMsgData
- type ReadOperReqData
- type ReadOperRspData
- type SegmentDataMsgData
- type SliceInfo
- type SliceInfoMsgData
- type SliceWopProg
- type WopData
- type WopInfo
- type WriteDataInfoS
- type WriteDataMsgData
- type WriteOpMsgData
- type WriteOperReqData
- func (req *WriteOperReqData) AuthSender() (common.Address, error)
- func (wop *WriteOperReqData) AuthVerifySeal(tenant common.Address) error
- func (req *WriteOperReqData) Hash() common.Hash
- func (req *WriteOperReqData) Sender() (common.Address, error)
- func (wop *WriteOperReqData) SignatureValues(sig []byte) (r, s, v *big.Int, err error)
- func (wop *WriteOperReqData) VerifySeal(tenant common.Address) error
- func (wop *WriteOperReqData) WithSignature(sig []byte) error
- type WriteOperRspData
Constants ¶
const ( ReqData = 0 ReqHash = 1 )
Variables ¶
This section is empty.
Functions ¶
func CommonSign ¶
func ErrorToUInt8 ¶
func RecoverBase ¶
func SignWop ¶
func SignWop(wop *WriteOperReqData, prv *ecdsa.PrivateKey) error
SignTx signs the transaction using the given signer and private key
Types ¶
type BlizObjectMeta ¶
type BlizObjectMeta struct { Name string // 名称 Length uint64 // 长度 Permission uint64 // (rw)权限 Owner common.Address // 对象属主(tenant) // 根据 length 可以计算出当前占用了多少个 slice SliceInfos []SliceInfo // 内容所在的所有slice信息 }
BlizObjectMeta 包含在该对象对应的 chunk:slice 世界状态 指向的存储区域,从该存储区域的一个slice(1M)获取到所有的 对象信息
func (*BlizObjectMeta) Equal ¶
func (a *BlizObjectMeta) Equal(b *BlizObjectMeta) bool
type BuffFromSharerCSData ¶
type BuffFromSharerCSData struct {}
type DiscReason ¶
type DiscReason uint
const ( DiscRequested DiscReason = iota DiscNetworkError DiscProtocolError DiscUselessPeer DiscTooManyPeers DiscAlreadyConnected DiscIncompatibleVersion DiscInvalidIdentity DiscQuitting DiscUnexpectedIdentity DiscSelf DiscReadTimeout DiscSubprotocolError = 0x10 )
func (DiscReason) Error ¶
func (d DiscReason) Error() string
func (DiscReason) String ¶
func (d DiscReason) String() string
type ErrCode ¶
type ErrCode int
const ( ErrMsgTooLarge ErrCode = iota ErrDecode ErrInvalidMsgCode ErrInvalidMsgParameter ErrProtocolVersionMismatch ErrNetworkIdMismatch ErrGenesisBlockMismatch ErrNoStatusMsg ErrExtraStatusMsg ErrSuspendedPeer ErrNoDailChunkInfo ErrNoShakeHandsChunkInfo ErrChunkMismatch ErrLocalNotChunkFarmer ErrPartnerNotChunkFarmer ErrAssoAlreadyExist ErrRetriveFarmerFail ErrInsufficientFarmers ErrQueryShardingMinerTimeout ErrQueryFarmerTimeout ErrQueryObjectMetaTimeout ErrObjectSpaceInsufficient ErrWouldBlock ErrParameter ErrHash ErrFarmer ErrNetwork ErrWopIdNotValid ErrWopInvalidPermission ErrInvalidSig ErrOutOfRange ErrTimeout ErrNoEnoughFarmer ErrLackOfData ErrCapacityNotEnough ErrWriteOperRsp ErrFarmerSlice ErrReadOperRsp ErrSliceHeader ErrRsv ErrRsvTimeout ErrUnknown // 务必放在最后 )
func UInt8ToErrorCode ¶
type FarmerSliceOp ¶
type FarmerSliceOpReq ¶
type FarmerSliceOpRsp ¶
type FarmerSliceOpRsp struct { ObjUId string FarmerSliceOps []FarmerSliceOp NodeId discover.NodeID }
type GetBuffFromSharerCSData ¶
type GetBuffFromSharerCSData struct {}
type GetHeaderHashMsgData ¶
type GetSegmentDataMsgData ¶
type GetSegmentDataMsgData struct { Chunk uint64 Slice uint32 Segment uint32 // 获取的起始 Segment index Count uint32 // 获取 Segment 数量 QueryId uint64 }
func (*GetSegmentDataMsgData) SetQuerId ¶
func (query *GetSegmentDataMsgData) SetQuerId(queryId uint64)
type GetSliceInfoMsgData ¶
func (*GetSliceInfoMsgData) SetQuerId ¶
func (query *GetSliceInfoMsgData) SetQuerId(queryId uint64)
type GetWriteDataMsgData ¶
type GetWriteOpMsgData ¶
type GetWriteOpMsgData struct { Chunk uint64 Slice uint32 FromWopId uint64 Count uint32 // 暂时不考虑,默认为1 QueryId uint64 }
func (*GetWriteOpMsgData) SetQuerId ¶
func (query *GetWriteOpMsgData) SetQuerId(queryId uint64)
type HeaderHashMsgData ¶
type HeaderHashMsgData struct { Rsp *GetHeaderHashMsgData HeaderHash common.Hash OpId uint64 }
type HeartBeatMsgData ¶
type HeartBeatMsgData struct { Ts uint64 ChunkId uint64 Progs []*SliceWopProg // Signature values( for Id & Hash(Datas) & Infos & Chunk & Slice) Signature []byte }
func (*HeartBeatMsgData) Hash ¶
func (hbdata *HeartBeatMsgData) Hash() common.Hash
Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.
func (*HeartBeatMsgData) SignHeartbeat ¶
func (hbdata *HeartBeatMsgData) SignHeartbeat(prv *ecdsa.PrivateKey) error
type ReadOperReqData ¶
type ReadOperRspData ¶
type ReadOperRspData struct { ReadOperReqData ErrBytes []byte Data []byte }
type SegmentDataMsgData ¶
type SliceInfoMsgData ¶
type SliceInfoMsgData struct { Chunk uint64 Slice uint32 QueryId uint64 WopProg uint64 // 当前slice的 wopId 进度 SegmentHashs [][]byte // 当前slice中所有 segment 的 hash 值列表 Signature []byte // tenant 为 WopProg + Hash(SegmentHashs) 的签名,可以由上面两个值来计算校验 }
func (*SliceInfoMsgData) Verify ¶
func (msgdata *SliceInfoMsgData) Verify() error
校验 Signature 和 WopProg + Hash(SegmentHashs) 是否对的上
type SliceWopProg ¶
type WopInfo ¶
type WopInfo struct { WopId uint64 WopTs uint64 Chunk uint64 // 该 Wop 涉及的Chunk:Slice Slice uint32 Infos *[]*WriteDataInfoS // 一组写入数据的相关Info Type uint8 // 0: write data, 1: checked header hash HeaderHash common.Hash // Signature values( for Id & Hash(Datas) & Infos & Chunk & Slice) V *big.Int //`json:"v" gencodec:"required"` R *big.Int //`json:"r" gencodec:"required"` S *big.Int //`json:"s" gencodec:"required"` AuthAddress common.Address AuthDeadlineC uint64 RC *big.Int // comming from client SC *big.Int // comming from client VC *big.Int // comming from client }
type WriteDataInfoS ¶
WOP 定义
type WriteDataMsgData ¶
type WriteDataMsgData struct { Rsp *GetWriteDataMsgData Header *storagecore.SliceHeader Data []byte }
type WriteOpMsgData ¶
基本跟 WriteOperReqData 一样
type WriteOperReqData ¶
type WriteOperReqData struct { Info *WopInfo Datas [][]byte // 一组写入数据(跟Infos一一对应) ObjUId string Sign []byte }
func (*WriteOperReqData) AuthSender ¶
func (req *WriteOperReqData) AuthSender() (common.Address, error)
func (*WriteOperReqData) AuthVerifySeal ¶
func (wop *WriteOperReqData) AuthVerifySeal(tenant common.Address) error
func (*WriteOperReqData) Hash ¶
func (req *WriteOperReqData) Hash() common.Hash
Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.
func (*WriteOperReqData) SignatureValues ¶
func (wop *WriteOperReqData) SignatureValues(sig []byte) (r, s, v *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
func (*WriteOperReqData) VerifySeal ¶
func (wop *WriteOperReqData) VerifySeal(tenant common.Address) error
计算 Datas 的hash值
func (*WriteOperReqData) WithSignature ¶
func (wop *WriteOperReqData) WithSignature(sig []byte) error
WithSignature returns a new transaction with the given signature. This signature needs to be formatted as described in the yellow paper (v+27).