accountpendingpayout

package
v0.0.0-...-d7bcf31 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2016 License: MIT Imports: 10 Imported by: 0

README

MapReduce: account_pending_payout

This MapReduce collects pending payouts for all stories by the given author. No curation or comment rewards, this is really just about the story upvotes.

KoolAid: This MapReduce supports incremental updates.

Usage

Fist we need to set the path to the data directory. The default path is ./steemreduce_data/account_pending_payout in the current working directory, but it can be changed:

export STEEMREDUCE_PARAMS_DATA_DIR=./data

But let's just assume we use the default value for now and let's create the MapReduce JSON file ./steemreduce_data/account_pending_payout/mapreduce.json:

{
  "config": {
    "author": "void"
  }
}

In case you want to limit the block range and not go through the whole blockchain, insert the following as well, filling your own values:

  "state": {
    "block_range_from": 1000000,
    "block_range_to": 1500000
  }

Now you are ready to run MapReduce:

steemreduce \
	-rpc_endpoint="ws:$(docker-machine ip default):8090"
	-mapreduce_id=account_pending_payout

The output will be located in output.txt in the data directory:

Block   Title                                               Pending Payout
=====   =====                                               ==============
1268905	The Body Knows                                      2.4
1325197	Let it Go, Let it Happen                            418.7
1473920	So Much Energy is Wasted                            0
1548838	Accessing steemd RPC endpoint using Golang          0.2
1592040	The Evolution of Consciousness                      20.5
1605795	Nobody Has to Be Anybody!                           0
1728062	We Are Taught, Yet We Do Not Understand             20.3
1786011	Dockerfile for steemd, Tuned for Performance        33.7
1851608	Evaluating Martial Arts                             45.6
1872747	go-steem/rpc: Golang RPC Client Library for Steem   672
1907611	steemreduce: You Personal MapReduce for Steem       1060.5

Total pending payout: 2273.9

The context will be stored in mapreduce.json created before:

{
  "config": {
    "author": "void"
  },
  "state": {
    "next_block": 1933756
  },
  "accumulator": {
    "stories": [
      {
        "block_number": 1268905,
        "title": "The Body Knows",
        "permlink": "the-body-knows",
        "pending_payout": 2.4
      },
      {
        "block_number": 1325197,
        "title": "Let it Go, Let it Happen",
        "permlink": "let-it-go-let-it-happen",
        "pending_payout": 418.7
      },
      {
        "block_number": 1473920,
        "title": "So Much Energy is Wasted",
        "permlink": "so-much-energy-is-wasted",
        "pending_payout": 0
      },
      {
        "block_number": 1548838,
        "title": "Accessing steemd RPC endpoint using Golang",
        "permlink": "accessing-steemd-rpc-endpoint-using-golang",
        "pending_payout": 0.2
      },
      {
        "block_number": 1592040,
        "title": "The Evolution of Consciousness",
        "permlink": "the-evolution-of-consciousness",
        "pending_payout": 20.5
      },
      {
        "block_number": 1605795,
        "title": "Nobody Has to Be Anybody!",
        "permlink": "nobody-has-to-be-anybody",
        "pending_payout": 0
      },
      {
        "block_number": 1728062,
        "title": "We Are Taught, Yet We Do Not Understand",
        "permlink": "we-are-taught-yet-we-do-not-understand",
        "pending_payout": 20.3
      },
      {
        "block_number": 1786011,
        "title": "Dockerfile for steemd, Tuned for Performance",
        "permlink": "dockerfile-for-steemd-tuned-for-performance",
        "pending_payout": 33.7
      },
      {
        "block_number": 1851608,
        "title": "Evaluating Martial Arts",
        "permlink": "evaluating-martial-arts",
        "pending_payout": 45.6
      },
      {
        "block_number": 1872747,
        "title": "go-steem/rpc: Golang RPC Client Library for Steem",
        "permlink": "go-steemrpc-golang-rpc-client-library-for-steem",
        "pending_payout": 672
      },
      {
        "block_number": 1907611,
        "title": "steemreduce: You Personal MapReduce for Steem",
        "permlink": "steemreduce-you-personal-mapreduce-for-steem",
        "pending_payout": 1060.5
      }
    ],
    "total_pending_payout": 2273.9
  }
}

Next time you run the the same command again, MapReduce will start at next_block as stored in mapreduce.json, only processing new blocks, which can save massive amount of time.

Documentation

Index

Constants

View Source
const (
	StateFilename  = "mapreduce.json"
	OutputFilename = "output.txt"
)
View Source
const DataDirectoryEnvironmentKey = "STEEMREDUCE_PARAMS_DATA_DIR"
View Source
const Id = "account_pending_payout"

Variables

View Source
var DefaultDataDirectoryPath = filepath.Join("steemreduce_data", Id)

Functions

This section is empty.

Types

type Accumulator

type Accumulator struct {
	Stories            []*Story          `json:"stories"`
	ProcessedStories   map[string]*Story `json:"-"`
	TotalPendingPayout float64           `json:"total_pending_payout"`
}

type AccumulatorData

type AccumulatorData struct {
	*Accumulator
}

func (*AccumulatorData) UnmarshalJSON

func (accData *AccumulatorData) UnmarshalJSON(data []byte) error

type BlockMapReducer

type BlockMapReducer struct {
	// contains filtered or unexported fields
}

BlockMapReducer implements runner.BlockMapReducer interface.

func NewBlockMapReducer

func NewBlockMapReducer() *BlockMapReducer

func (*BlockMapReducer) BlockRange

func (reducer *BlockMapReducer) BlockRange() (from, to uint32)

func (*BlockMapReducer) Initialise

func (reducer *BlockMapReducer) Initialise(client *rpc.Client) (interface{}, error)

func (*BlockMapReducer) Map

func (reducer *BlockMapReducer) Map(client *rpc.Client, emit func(interface{}) error, block *rpc.Block) error

Map in this case emits a value for every story operation by the given author.

func (*BlockMapReducer) ProcessResults

func (reducer *BlockMapReducer) ProcessResults(_acc interface{}, nextBlockToProcess uint32) error

WriteResults is used to generate output for the resulting accumulator. This implementation uses a text/tabwriter to format the output.

func (*BlockMapReducer) Reduce

func (reducer *BlockMapReducer) Reduce(client *rpc.Client, _acc, _next interface{}) (interface{}, error)

Reduce stores the story in the map in case it is a new story operation and adds the story pending payout to the sum of all pending payouts.

type Config

type Config struct {
	Author string `json:"author"`
}

type Data

type Data struct {
	Config *Config          `json:"config,omitempty"`
	State  *State           `json:"state,omitempty"`
	Acc    *AccumulatorData `json:"accumulator,omitempty"`
}

func (*Data) WriteOutput

func (data *Data) WriteOutput(writer io.Writer) error

type State

type State struct {
	BlockRangeFrom     uint32 `json:"block_range_from,omitempty"`
	BlockRangeTo       uint32 `json:"block_range_to,omitempty"`
	NextBlockToProcess uint32 `json:"next_block,omitempty"`
}

type Story

type Story struct {
	BlockNum      uint32  `json:"block_number"`
	Title         string  `json:"title"`
	Permlink      string  `json:"permlink"`
	PendingPayout float64 `json:"pending_payout"`
}

Jump to

Keyboard shortcuts

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