Skip to content

Commit

Permalink
Merged in coinplugin/go-metadium (pull request #16)
Browse files Browse the repository at this point in the history
Master

Approved-by: Uh Sado <sadoc@metadium.com>
  • Loading branch information
sadoci committed Mar 16, 2019
2 parents 4f39919 + c576625 commit f34532f
Show file tree
Hide file tree
Showing 35 changed files with 30,758 additions and 521 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ vendor/*

# Metadium
/metadium/admin_abi.go
/metadium/governance_abi.go
64 changes: 57 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.PHONY: geth-linux-arm geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
.PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
.PHONY: geth-windows geth-windows-386 geth-windows-amd64
.PHONY: gmet-linux

GOBIN = $(shell pwd)/build/bin
GO ?= latest
Expand Down Expand Up @@ -34,18 +35,18 @@ endif
metadium: gmet logrot
@[ -d build/conf ] || mkdir -p build/conf
@cp -p metadium/scripts/gmet.sh metadium/scripts/solc.sh build/bin/
@cp -p metadium/scripts/config.json.example \
metadium/scripts/genesis-template.json \
metadium/contracts/MetadiumAdmin-template.sol build/conf/
@cp -p metadium/scripts/config.json.example \
metadium/scripts/genesis-template.json \
metadium/contracts/MetadiumGovernance.js build/conf/
@(cd build; tar cfz metadium.tar.gz bin conf)
@echo "Done building build/metadium.tar.gz"

gmet: vendor rocksdb metadium/admin_abi.go
gmet: vendor rocksdb metadium/governance_abi.go
ifeq ($(USE_ROCKSDB), NO)
build/env.sh go run build/ci.go install $(ROCKSDB_TAG) ./cmd/gmet
else
CGO_CFLAGS=-I$(ROCKSDB_DIR)/include \
CGO_LDFLAGS="-L$(ROCKSDB_DIR) -lstdc++ -lrocksdb -lm $(shell awk '/PLATFORM_LDFLAGS/ {sub("PLATFORM_LDFLAGS=", ""); print} /JEMALLOC=1/ {print "-ljemalloc"}' < $(ROCKSDB_DIR)/make_config.mk)" \
CGO_LDFLAGS="-L$(ROCKSDB_DIR) -lrocksdb -lm -lstdc++ $(shell awk '/PLATFORM_LDFLAGS/ {sub("PLATFORM_LDFLAGS=", ""); print} /JEMALLOC=1/ {print "-ljemalloc"}' < $(ROCKSDB_DIR)/make_config.mk)" \
build/env.sh go run build/ci.go install $(ROCKSDB_TAG) ./cmd/gmet
endif
@echo "Done building."
Expand Down Expand Up @@ -88,7 +89,7 @@ lint: ## Run linters.

clean:
./build/clean_go_build_cache.sh
rm -fr build/_workspace/pkg/ $(GOBIN)/* build/conf metadium/admin_abi.go
rm -fr build/_workspace/pkg/ $(GOBIN)/* build/conf metadium/admin_abi.go metadium/governance_abi.go
@ROCKSDB_DIR=$(shell pwd)/build/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/facebook/rocksdb; \
if [ -d $${ROCKSDB_DIR} ]; then \
cd $${ROCKSDB_DIR}; \
Expand Down Expand Up @@ -203,6 +204,29 @@ geth-windows-amd64:
@echo "Windows amd64 cross compilation done:"
@ls -ld $(GOBIN)/geth-windows-* | grep amd64

gmet-linux:
ifeq ($(shell uname), Linux)
@docker --version > /dev/null 2>&1; \
if [ ! $$? = 0 ]; then \
echo "Docker not found."; \
else \
docker run -e HOME=/tmp -it --rm \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-v ~/src:/home/$${USER}/src \
-v $(shell pwd):/data -u $$(id -u):$$(id -g) \
-w /data metadium/bobthe:latest make; \
fi
else
@docker --version > /dev/null 2>&1; \
if [ ! $$? = 0 ]; then \
echo "Docker not found."; \
else \
docker run -e HOME=/tmp -it --rm -v $(shell pwd):/data \
-w /data metadium/bobthe:latest make; \
fi
endif

vendor:
@build/env.sh test 1;
@export GOPATH=$(shell pwd)/build/_workspace; \
Expand All @@ -226,7 +250,7 @@ else
rocksdb: vendor
@build/env.sh test 1;
@cd $(shell pwd)/build/_workspace/src/github.com/ethereum/go-ethereum/vendor/github.com/facebook/rocksdb; \
make -j24 static_lib;
make -j8 static_lib;
endif

AWK_CODE=' \
Expand All @@ -248,6 +272,32 @@ metadium/admin_abi.go: metadium/contracts/MetadiumAdmin-template.sol build/bin/s
cat /tmp/junk.$$$$ | awk $(AWK_CODE) > $@; \
rm -f /tmp/junk.$$$$;

AWK_CODE_2=' \
BEGIN { print "package metadium"; } \
/^var Registry_contract/ { \
sub("^var[^(]*\\(","",$$0); sub("\\);$$","",$$0); \
n = "Registry"; \
print "var " n "Abi = `{ \"contractName\": \"" n "\", \"abi\": " $$0 "}`"; \
} \
/^var Staking_contract/ { \
sub("^var[^(]*\\(","",$$0); sub("\\);$$","",$$0); \
n = "Staking"; \
print "var " n "Abi = `{ \"contractName\": \"" n "\", \"abi\": " $$0 "}`"; \
} \
/^var EnvStorageImp_contract/ { \
sub("^var[^(]*\\(","",$$0); sub("\\);$$","",$$0); \
n = "EnvStorageImp"; \
print "var " n "Abi = `{ \"contractName\": \"" n "\", \"abi\": " $$0 "}`"; \
} \
/^var Gov_contract/ { \
sub("^var[^(]*\\(","",$$0); sub("\\);$$","",$$0); \
n = "Gov"; \
print "var " n "Abi = `{ \"contractName\": \"" n "\", \"abi\": " $$0 "}`"; \
}'

metadium/governance_abi.go: metadium/contracts/MetadiumGovernance.js
@cat $< | awk $(AWK_CODE_2) > $@

ifneq ($(shell uname), Linux)

build/bin/solc:
Expand Down
3 changes: 1 addition & 2 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,11 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
if err != nil {
utils.Fatalf("Failed to create the protocol stack: %v", err)
}
utils.SetMetadiumConfig(ctx, stack, &cfg.Eth)
utils.SetEthConfig(ctx, stack, &cfg.Eth)
if ctx.GlobalIsSet(utils.EthStatsURLFlag.Name) {
cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name)
}
utils.SetMetadiumConfig(ctx, stack, &cfg.Eth)

utils.SetShhConfig(ctx, stack, &cfg.Shh)
utils.SetDashboardConfig(ctx, &cfg.Dashboard)

Expand Down
Loading

0 comments on commit f34532f

Please sign in to comment.