-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into jae/fixrmssubstores
- Loading branch information
Showing
14 changed files
with
258 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Dockerfile | ||
Vagrantfile | ||
|
||
build/ | ||
coverage.txt |
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,28 +1,34 @@ | ||
FROM alpine:3.5 | ||
# Simple usage with a mounted data directory: | ||
# > docker build -t gaia . | ||
# > docker run -v $HOME/.gaiad:/root/.gaiad gaia init | ||
# > docker run -v $HOME/.gaiad:/root/.gaiad gaia start | ||
|
||
# BCHOME is where your genesis.json, key.json and other files including state are stored. | ||
ENV BCHOME /basecoin | ||
FROM alpine:edge | ||
|
||
# Create a basecoin user and group first so the IDs get set the same way, even | ||
# as the rest of this may change over time. | ||
RUN addgroup basecoin && \ | ||
adduser -S -G basecoin basecoin | ||
# Set up dependencies | ||
ENV PACKAGES go glide make git libc-dev bash | ||
|
||
RUN mkdir -p $BCHOME && \ | ||
chown -R basecoin:basecoin $BCHOME | ||
WORKDIR $BCHOME | ||
# Set up GOPATH & PATH | ||
|
||
# Expose the basecoin home directory as a volume since there's mutable state in there. | ||
VOLUME $BCHOME | ||
ENV GOPATH /root/go | ||
ENV BASE_PATH $GOPATH/src/github.com/cosmos | ||
ENV REPO_PATH $BASE_PATH/cosmos-sdk | ||
ENV WORKDIR /cosmos/ | ||
ENV PATH $GOPATH/bin:$PATH | ||
|
||
# jq and curl used for extracting `pub_key` from private validator while | ||
# deploying tendermint with Kubernetes. It is nice to have bash so the users | ||
# could execute bash commands. | ||
RUN apk add --no-cache bash curl jq | ||
# Link expected Go repo path | ||
|
||
COPY basecoin /usr/bin/basecoin | ||
RUN mkdir -p $WORKDIR $GOPATH/pkg $ $GOPATH/bin $BASE_PATH | ||
|
||
ENTRYPOINT ["basecoin"] | ||
# Add source files | ||
|
||
# By default you will get the basecoin with local MerkleEyes and in-proc Tendermint. | ||
CMD ["start", "--dir=${BCHOME}"] | ||
ADD . $REPO_PATH | ||
|
||
# Install minimum necessary dependencies, build Cosmos SDK, remove packages | ||
RUN apk add --no-cache $PACKAGES && \ | ||
cd $REPO_PATH && make get_tools && make get_vendor_deps && make all && make install && \ | ||
apk del $PACKAGES | ||
|
||
# Set entrypoint | ||
|
||
ENTRYPOINT ["gaiad"] |
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,27 +1,72 @@ | ||
package context | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/viper" | ||
|
||
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" | ||
rpcclient "github.com/tendermint/tendermint/rpc/client" | ||
tmtypes "github.com/tendermint/tendermint/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/core" | ||
) | ||
|
||
// NewCoreContextFromViper - return a new context with parameters from the command line | ||
func NewCoreContextFromViper() core.CoreContext { | ||
nodeURI := viper.GetString(client.FlagNode) | ||
var rpc rpcclient.Client | ||
if nodeURI != "" { | ||
rpc = rpcclient.NewHTTP(nodeURI, "/websocket") | ||
} | ||
chainID := viper.GetString(client.FlagChainID) | ||
// if chain ID is not specified manually, read default chain ID | ||
if chainID == "" { | ||
def, err := defaultChainID() | ||
if err != nil { | ||
chainID = def | ||
} | ||
} | ||
return core.CoreContext{ | ||
ChainID: viper.GetString(client.FlagChainID), | ||
ChainID: chainID, | ||
Height: viper.GetInt64(client.FlagHeight), | ||
TrustNode: viper.GetBool(client.FlagTrustNode), | ||
FromAddressName: viper.GetString(client.FlagName), | ||
NodeURI: nodeURI, | ||
Sequence: viper.GetInt64(client.FlagSequence), | ||
Client: rpc, | ||
Decoder: nil, | ||
AccountStore: "main", | ||
} | ||
} | ||
|
||
// read chain ID from genesis file, if present | ||
func defaultChainID() (string, error) { | ||
cfg, err := tcmd.ParseConfig() | ||
if err != nil { | ||
return "", err | ||
} | ||
doc, err := tmtypes.GenesisDocFromFile(cfg.GenesisFile()) | ||
if err != nil { | ||
return "", err | ||
} | ||
return doc.ChainID, nil | ||
} | ||
|
||
// EnsureSequence - automatically set sequence number if none provided | ||
func EnsureSequence(ctx core.CoreContext) (core.CoreContext, error) { | ||
if viper.IsSet(client.FlagSequence) { | ||
return ctx, nil | ||
} | ||
from, err := ctx.GetFromAddress() | ||
if err != nil { | ||
return ctx, err | ||
} | ||
seq, err := ctx.NextSequence(from) | ||
if err != nil { | ||
return ctx, err | ||
} | ||
fmt.Printf("Defaulting to next sequence number: %d\n", seq) | ||
ctx = ctx.WithSequence(seq) | ||
return ctx, 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.