-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,030 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright 2018 Frank V. Castellucci and Arthur Greef | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ----------------------------------------------------------------------------- | ||
|
||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.join( | ||
os.path.dirname(os.path.dirname(os.path.realpath(__file__))), | ||
'families/track/hashblock_track')) | ||
|
||
|
||
from processor.main import main | ||
|
||
if __name__ == '__main__': | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Copyright 2018 Frank V. Castellucci and Arthur Greef | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ------------------------------------------------------------------------------ | ||
|
||
# Description: | ||
# Builds a deployable production image for our hashblock-track-tp | ||
# | ||
# base image: | ||
# 1. Installs protobuf | ||
# 2. Generates protobuf files | ||
# final image: | ||
# 1. Installs sawtooth-sdk and crypto | ||
# 2. Copies relevant files from base | ||
# Build: | ||
# $ cd hashblock-exchange | ||
# $ docker build . -f docker/hashblock-track-tp -t hashblock/hashblock-track-tp:latest | ||
# | ||
|
||
FROM ubuntu:xenial as base | ||
LABEL maintainers="Frank V. Castellucci, Arthur Greef" | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y -q \ | ||
apt-transport-https \ | ||
python3-dev \ | ||
python3-pip | ||
|
||
RUN mkdir -p /builder && \ | ||
pip3 install \ | ||
grpcio-tools \ | ||
grpcio && \ | ||
rm -rf /var/lib/apt/lists/ | ||
|
||
WORKDIR /builder | ||
|
||
COPY bin bin | ||
COPY apps apps | ||
COPY modules modules | ||
COPY protos protos | ||
COPY families families | ||
|
||
RUN bin/protogen && \ | ||
pip3 uninstall -y grpcio grpcio-tools | ||
|
||
# The final image | ||
|
||
FROM ubuntu:xenial | ||
LABEL maintainers="Frank V. Castellucci, Arthur Greef" | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y -q \ | ||
apt-transport-https \ | ||
libssl-dev \ | ||
libffi-dev \ | ||
python3-dev \ | ||
python3-pip \ | ||
build-essential \ | ||
automake \ | ||
pkg-config \ | ||
libtool \ | ||
libffi-dev | ||
|
||
RUN pip3 install eciespy cryptography && \ | ||
SECP_BUNDLED_EXPERIMENTAL=1 pip3 --no-cache-dir install --no-binary secp256k1 secp256k1 && \ | ||
pip3 install sawtooth-sdk --upgrade && \ | ||
rm -r /root/.cache && \ | ||
apt-get remove -y build-essential automake && apt-get autoremove -y | ||
|
||
RUN mkdir -p /project/hashblock-exchange && \ | ||
mkdir -p /project/hashblock-exchange/bin && \ | ||
mkdir -p /project/hashblock-exchange/modules && \ | ||
mkdir -p /project/hashblock-exchange/families/track && \ | ||
mkdir -p /var/log/sawtooth | ||
|
||
COPY --from=base /builder/bin/track-tp /project/hashblock-exchange/bin | ||
COPY libs/hbzksnark /project/hashblock-exchange/bin | ||
COPY --from=base /builder/modules /project/hashblock-exchange/modules | ||
COPY --from=base /builder/families/track/hashblock_track /project/hashblock-exchange/families/track/hashblock_track | ||
|
||
WORKDIR /project/hashblock-exchange | ||
ENV PATH $PATH:/project/hashblock-exchange/bin |
Empty file.
Empty file.
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,14 @@ | ||
# Copyright 2017 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ------------------------------------------------------------------------------ |
14 changes: 14 additions & 0 deletions
14
families/track/hashblock_track/processor/config/__init__.py
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,14 @@ | ||
# Copyright 2017 Frank V. Castellucci | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ------------------------------------------------------------------------------ |
128 changes: 128 additions & 0 deletions
128
families/track/hashblock_track/processor/config/track.py
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,128 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright 2018 Frank V. Castellucci and Arthur Greef | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ------------------------------------------------------------------------------ | ||
|
||
import collections | ||
import logging | ||
import os | ||
|
||
import toml | ||
|
||
from sawtooth_sdk.processor.exceptions import LocalConfigurationError | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
def load_default_track_config(): | ||
""" | ||
Returns the default TrackConfig | ||
""" | ||
return TrackConfig( | ||
connect='tcp://localhost:4004' | ||
) | ||
|
||
|
||
def load_toml_track_config(filename): | ||
"""Returns a TrackConfig created by loading a TOML file from the | ||
filesystem. | ||
Args: | ||
filename (string): The name of the file to load the config from | ||
Returns: | ||
config (TrackConfig): The TrackConfig created from the stored | ||
toml file. | ||
Raises: | ||
LocalConfigurationError | ||
""" | ||
if not os.path.exists(filename): | ||
LOGGER.info( | ||
"Skipping transaction proccesor config loading from non-existent" | ||
" config file: %s", filename) | ||
return TrackConfig() | ||
|
||
LOGGER.info("Loading transaction processor information from config: %s", | ||
filename) | ||
|
||
try: | ||
with open(filename) as fd: | ||
raw_config = fd.read() | ||
except IOError as e: | ||
raise LocalConfigurationError( | ||
"Unable to load transaction processor configuration file:" | ||
" {}".format(str(e))) | ||
|
||
toml_config = toml.loads(raw_config) | ||
invalid_keys = set(toml_config.keys()).difference( | ||
['connect']) | ||
if invalid_keys: | ||
raise LocalConfigurationError( | ||
"Invalid keys in transaction processor config: " | ||
"{}".format(", ".join(sorted(list(invalid_keys))))) | ||
|
||
config = TrackConfig( | ||
connect=toml_config.get("connect", None) | ||
) | ||
|
||
return config | ||
|
||
|
||
def merge_track_config(configs): | ||
""" | ||
Given a list of TrackConfig objects, merges them into a single | ||
TrackConfig, giving priority in the order of the configs | ||
(first has highest priority). | ||
Args: | ||
config (list of TrackConfigs): The list of units configs that | ||
must be merged together | ||
Returns: | ||
config (TrackConfig): one TrackConfig that combines all of the | ||
passed in configs. | ||
""" | ||
connect = None | ||
|
||
for config in reversed(configs): | ||
if config.connect is not None: | ||
connect = config.connect | ||
|
||
return TrackConfig(connect=connect) | ||
|
||
|
||
class TrackConfig: | ||
def __init__(self, connect=None): | ||
self._connect = connect | ||
|
||
@property | ||
def connect(self): | ||
return self._connect | ||
|
||
def __repr__(self): | ||
# not including password for opentsdb | ||
return \ | ||
"{}(connect={})".format( | ||
self.__class__.__name__, | ||
repr(self._connect), | ||
) | ||
|
||
def to_dict(self): | ||
return collections.OrderedDict([ | ||
('connect', self._connect), | ||
]) | ||
|
||
def to_toml_string(self): | ||
return str(toml.dumps(self.to_dict())).strip().split('\n') |
Oops, something went wrong.