hamster-provider

command module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

README

github: https://github.com/hamster-shared/hamster-provider

hamster is a blockchain-based blockchain infrastructure service. Any computing device can easily access the Hamster network.

Project Guidelines

1. Basic Introduction

1.1 Project Introduction

Hamster-Provider is a blockchain compute node based on go-libp2p and libvirt-go, which provide trusted infrastructure services. It can provide users' idle resources to the Hamster Market in the form of virtual machines.

1.2 Contributing Guide

Hi! Thank you for choosing Hamster.

Hamster is a blockchain that providers infrastructure service.

We are excited that you are interested in contributing to Hamster. Before submitting your contribution though, please make sure to take a moment and read through the following guidelines.

1.2.1 Issue Guidelines
  • Issues are exclusively for bug reports, feature requests and design-related topics. Other questions may be closed directly.

  • Before submitting an issue, please check if similar problems have already been issued.

1.2.2 Pull Request Guidelines
  • Fork this repository to your own account. Do not create branches here.

  • Commit info should be formatted as [File Name]: Info about commit. (e.g. README.md: Fix xxx bug)

  • If your PR fixes a bug, please provide a description about the related bug.

  • Merging a PR takes two maintainers: one approves the changes after reviewing, and then the other reviews and merges.

1.3 Version list
  • main: 1.0.0 code, for prod
  • develop: 2.0.0 dev code, for test

2. Getting started

- node version > v16.0.0
- golang version >= v1.17
- IDE recommendation: Goland
2.1 server project

# install package dependency

## ubuntu
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager libvirt-dev
sudo systemctl is-active libvirtd

## centos
yum install -y qemu-kvm libvirt virt-install libvirt-dev
systemctl start libvirtd && systemctl enable libvirtd


# clone the project
git clone https://github.com/hamster-shared/hamster-provider.git

# open frontend directory
cd frontend

# install frontend dependency
npm install

# build frontend 
npm run build

# go to root directory
cd ..

# use go mod And install the go dependency package
go mod tidy

# Compile 
go build

# Run init config
./hamster-provider init (windows The run command is hamster-provider.exe)

# Run Daemon 
./hamster-provider daemon (windows The run command is hamster-provider.exe)

3. Technical selection

  • Frontend: using Vue-Vben-Admin based on Vue,to code the page.
  • Backend: using Gin to quickly build basic RESTful API. Ginis a web framework written in Go (Golang).
  • Config: using cobra and viper to implement json config file。
  • Virtualization: linux using libvirt-go to manage virtual machines , windows using hyper-v

4. Project Architecture

4.1 Architecture Diagram

Architecture diagram

4.3 Project Layout
    ├─cmd                (command line)
    ├─core
    │  ├─context         (server context)
    │  ├─corehttp        (gin route) 
    │  └─modules      
    │      ├─chain       (chain transaction sdk)
    │      ├─config      (config)
    │      ├─event       (chain event impl) 
    │      ├─listener    (chain listener)
    │      ├─p2p         (p2p util)
    │      ├─pk          (keypair manager)
    │      ├─utils       (utils)
    │      └─vm          (Virtualization impl with docker、libvirt、hyper-v)
    ├─doc                (doc directory)
    ├─frontend        
    │  ├─build           
    │  ├─mock            (api mock) 
    │  ├─public          (deploy templates)
    │  ├─src
    │  │  ├─api          (frontend apis)
    │  │  ├─assets       (static files)
    │  │  ├─components   (components)
    │  │  ├─design
    │  │  ├─directives
    │  │  ├─enums
    │  │  ├─hooks
    │  │  ├─layouts      (layouts)
    │  │  ├─locales      (locale i18n)
    │  │  ├─logics       
    │  │  ├─router       (vue routers)
    │  │  ├─settings     
    │  │  ├─store        (vuex state management)  
    │  │  ├─utils        (frontend common utilitie)
    │  │  └─views        (pages)
    │  ├─tests
    │  └─types
    └─test               (provider integration test)
            

5. Features

  • Configuration management: Provider parameters can be managed through configuration files and pages
  • Blockchain communication: monitor blockchain events, accept orders on the chain, and establish a heartbeat
  • Virtualized resource management: Create virtualized resources according to order requirements and complete corresponding order agreements
  • p2p link management: coordinate the hamster client to establish peer-to-peer communication, so that the control side can access the created virtual machine

6. Knowledge base

6.1 Team blog

https://github.com/hamster-shared

7. Contributors

Thank you for considering your contribution to hamster!

8. Commercial considerations

If you use this project for commercial purposes, please comply with the Apache2.0 agreement and retain the author's technical support statement.

Documentation

Overview

Copyright © 2021 NAME HERE <EMAIL ADDRESS>

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.

Directories

Path Synopsis
Package cmd /* Copyright © 2021 NAME HERE <EMAIL ADDRESS> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
Package cmd /* Copyright © 2021 NAME HERE <EMAIL ADDRESS> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL