Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: testnet ipfs files hashes #217

Merged
merged 3 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ RUN url="https://dist.ipfs.io/ipget/v${IPGET_VERSION}/ipget_v${IPGET_VERSION}_${
rm ipget.tgz

WORKDIR /ipget
#replace with valid IPFS hash
RUN ./ipget QmeeLUVdiSTTKQqhWqsffYDtNvvvcTfJdotkNyi1KDEJtQ -o /genesis.json
#replace with valid IPFS hash
RUN ./ipget QmeeLUVdiSTTKQqhWqsffYDtNvvvcTfJdotkNyi1KDEJtQ -o /links
#replace with valid IPFS hash
RUN ./ipget QmeeLUVdiSTTKQqhWqsffYDtNvvvcTfJdotkNyi1KDEJtQ -o /config.toml
#replace with actual IPFS hash
RUN ./ipget Qmdxny6h8ntcMQjs9FH5F4YPXm6qTBBqBQ2fpgUy72U4bJ -o /genesis.json
#replace with actual IPFS hash
RUN ./ipget QmeupYarwzd7kZzg7faEXZZPPk5cbzbwC71YXJvTHFoUXe -o /links
#replace with actual IPFS hash
RUN ./ipget QmdFQTmeUswfeDRsKw1MrqLmTapkV4sks1Q3ZtBVG8uec6 -o /config.toml

WORKDIR /

Expand Down
7 changes: 7 additions & 0 deletions types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
CodeCidNotFound sdk.CodeType = 3
CodeNotEnoughBandwidth sdk.CodeType = 4
CodeDuplicatedLink sdk.CodeType = 5
CodeZeroLinks sdk.CodeType = 6

// Code space
CodespaceCbd sdk.CodespaceType = "cyberd"
Expand All @@ -30,6 +31,8 @@ func codeToDefaultMsg(code sdk.CodeType) string {
return "not enough bandwidth to make transaction"
case CodeDuplicatedLink:
return "duplicated link"
case CodeZeroLinks:
return "no links found"
default:
return fmt.Sprintf("unknown error: code %d", code)
}
Expand All @@ -54,6 +57,10 @@ func ErrDuplicatedLink() sdk.Error {
return newError(CodespaceCbd, CodeDuplicatedLink)
}

func ErrZeroLinks() sdk.Error {
return newError(CodespaceCbd, CodeZeroLinks)
}

func newError(codespace sdk.CodespaceType, code sdk.CodeType) sdk.Error {
msg := codeToDefaultMsg(code)
return sdk.NewError(codespace, code, msg)
Expand Down
3 changes: 2 additions & 1 deletion x/bandwidth/cost.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
func MsgBandwidthCosts(msg sdk.Msg) int64 {
switch msg.(type) {
case link.Msg:
return LinkMsgCost
linkMsg := msg.(link.Msg)
return int64(len(linkMsg.Links)) * LinkMsgCost
default:
return NonLinkMsgCost
}
Expand Down
4 changes: 4 additions & 0 deletions x/link/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func (msg Msg) ValidateBasic() sdk.Error {
return sdk.ErrInvalidAddress(msg.Address.String())
}

if len(msg.Links) == 0 {
return cbd.ErrZeroLinks()
}

var filter = make(CidsFilter)

for _, link := range msg.Links {
Expand Down